Debian Codegraph @

lib/Data/Password/zxcvbn/Match/BruteForce.pm

raw symbols SCIP
1 package Data::Password::zxcvbn::Match::BruteForcescip-perl cpan Data-Password-zxcvbn 1.1.3 Data/Password/zxcvbn/Match/BruteForce/;
2 use Mooscip-perl cpan Data-Password-zxcvbn 1.1.3 Moo/;
3 withscip-perl cpan Data-Password-zxcvbn 1.1.3 Data/Password/zxcvbn/Match/BruteForce/with(). 'Data::Password::zxcvbn::Match';
4 use List::AllUtilsscip-perl cpan Data-Password-zxcvbn 1.1.3 List/AllUtils/ qw(max);
5 our $VERSIONscip-perl cpan Data-Password-zxcvbn 1.1.3 Data/Password/zxcvbn/Match/BruteForce/$VERSION. = '1.1.3'; # VERSION
6 # ABSTRACT: special match class for brute-force guesses
7
8
9 my $BRUTEFORCE_CARDINALITY = 10;
10
11 sub estimate_guessesscip-perl cpan Data-Password-zxcvbn 1.1.3 Data/Password/zxcvbn/Match/BruteForce/estimate_guesses(). {
12 my ($self) = @_scip-perl cpan Data-Password-zxcvbn 1.1.3 Data/Password/zxcvbn/Match/BruteForce/`@_`.;
13
14 return $BRUTEFORCE_CARDINALITY ** lengthscip-perl cpan Data-Password-zxcvbn 1.1.3 Data/Password/zxcvbn/Match/BruteForce/length().($self->tokenscip-perl cpan Data-Password-zxcvbn 1.1.3 Data/Password/zxcvbn/Match/BruteForce/token().);
15 }
16
17 aroundscip-perl cpan Data-Password-zxcvbn 1.1.3 Data/Password/zxcvbn/Match/BruteForce/around(). guesses_for_password => sub {
18 my ($orig,$self,$password) = @_scip-perl cpan Data-Password-zxcvbn 1.1.3 Data/Password/zxcvbn/Match/BruteForce/`@_`.;
19
20 # small detail: make bruteforce matches at minimum one guess bigger than
21 # smallest allowed submatch guesses, such that non-bruteforce submatches
22 # over the same [i..j] take precedence.
23 my $min_guesses = $self->_min_guessesscip-perl cpan Data-Password-zxcvbn 1.1.3 Data/Password/zxcvbn/Match/BruteForce/_min_guesses().()+1;
24 my $guesses = $self->guessesscip-perl cpan Data-Password-zxcvbn 1.1.3 Data/Password/zxcvbn/Match/BruteForce/guesses().();
25
26 return maxscip-perl cpan Data-Password-zxcvbn 1.1.3 Data/Password/zxcvbn/Match/BruteForce/max().($min_guesses,$guesses);
27 };
28
29
30 around BUILDARGS => sub {
31 my ($orig,$class,@args) = @_scip-perl cpan Data-Password-zxcvbn 1.1.3 Data/Password/zxcvbn/Match/BruteForce/`@_`.;
32 my $args = $class->$origscip-perl cpan Data-Password-zxcvbn 1.1.3 Data/Password/zxcvbn/Match/BruteForce/$orig().(@args);
33
34 $args->{token} = substrscip-perl cpan Data-Password-zxcvbn 1.1.3 Data/Password/zxcvbn/Match/BruteForce/substr().(
35 deletescip-perl cpan Data-Password-zxcvbn 1.1.3 Data/Password/zxcvbn/Match/BruteForce/delete(). $args->{password},
36 $args->{i},
37 $args->{j} - $args->{i} +1,
38 );
39
40 return $args;
41 };
42
43 sub makescip-perl cpan Data-Password-zxcvbn 1.1.3 Data/Password/zxcvbn/Match/BruteForce/make(). {
44 requirescip-perl cpan Data-Password-zxcvbn 1.1.3 Data/Password/zxcvbn/Match/BruteForce/require(). Carp;
45 Carp::croakscip-perl cpan Data-Password-zxcvbn 1.1.3 Carp/croak().('BruteForce is a special case, its ->make constructor should never be called');
46 }
47
48
49 sub feedback_warningscip-perl cpan Data-Password-zxcvbn 1.1.3 Data/Password/zxcvbn/Match/BruteForce/feedback_warning(). { return undef }
50 sub feedback_suggestionsscip-perl cpan Data-Password-zxcvbn 1.1.3 Data/Password/zxcvbn/Match/BruteForce/feedback_suggestions(). { return [] }
51
52 1;
53
54 __END__
55
56 =pod
57
58 =encoding UTF-8
59
60 =head1 NAME
61
62 Data::Password::zxcvbn::Match::BruteForce - special match class for brute-force guesses
63
64 =head1 VERSION
65
66 version 1.1.3
67
68 =head1 DESCRIPTION
69
70 This class represents the guess that a certain substring of a password
71 can't be guessed any other way than by going through all the
72 characters combinations one by one.
73
74 This kind of matches is not generated by L<<
75 C<omnimatch>|Data::Password::zxcvbn::MatchList/omnimatch >>: it's used
76 internally by L<<
77 C<most_guessable_match_list>|Data::Password::zxcvbn::MatchList/most_guessable_match_list
78 >> to cover unmatched substrings, and as a fallback in the
79 calculations.
80
81 =head1 METHODS
82
83 =head2 C<estimate_guesses>
84
85 The number of guesses is exponential on the length of the token.
86
87 =head2 C<new>
88
89 my $match = Data::Password::zxcvbn::Match::BruteForce->new(
90 password => $password,
91 i => 2, j => 5,
92 );
93
94 Returns a match object covering the substring of C<$password> between
95 the C<i>th and C<j>th character.
96
97 =head2 C<feedback_warning>
98
99 =head2 C<feedback_suggestions>
100
101 This class does not provide any feedback.
102
103 =for Pod::Coverage BUILDARGS
104 make
105
106 =head1 AUTHOR
107
108 Gianni Ceccarelli <[email protected]>
109
110 =head1 COPYRIGHT AND LICENSE
111
112 This software is copyright (c) 2022 by BroadBean UK, a CareerBuilder Company.
113
114 This is free software; you can redistribute it and/or modify it under
115 the same terms as the Perl 5 programming language system itself.
116
117 =cut