File tree 1 file changed +23
-19
lines changed
src/Component/KeyManagement/Analyzer
1 file changed +23
-19
lines changed Original file line number Diff line number Diff line change 7
7
use function is_string ;
8
8
use Jose \Component \Core \JWK ;
9
9
use ParagonIE \ConstantTime \Base64UrlSafe ;
10
+ use Throwable ;
10
11
use ZxcvbnPhp \Zxcvbn ;
11
12
12
13
final class ZxcvbnKeyAnalyzer implements KeyAnalyzer
@@ -27,25 +28,28 @@ public function analyze(JWK $jwk, MessageBag $bag): void
27
28
return ;
28
29
}
29
30
$ zxcvbn = new Zxcvbn ();
30
- $ strength = $ zxcvbn ->passwordStrength ($ k );
31
-
32
- switch (true ) {
33
- case $ strength ['score ' ] < 3 :
34
- $ bag ->add (
35
- Message::high (
36
- 'The octet string is weak and easily guessable. Please change your key as soon as possible. '
37
- )
38
- );
39
-
40
- break ;
41
-
42
- case $ strength ['score ' ] === 3 :
43
- $ bag ->add (Message::medium ('The octet string is safe, but a longer key is preferable. ' ));
44
-
45
- break ;
46
-
47
- default :
48
- break ;
31
+ try {
32
+ $ strength = $ zxcvbn ->passwordStrength ($ k );
33
+ switch (true ) {
34
+ case $ strength ['score ' ] < 3 :
35
+ $ bag ->add (
36
+ Message::high (
37
+ 'The octet string is weak and easily guessable. Please change your key as soon as possible. '
38
+ )
39
+ );
40
+
41
+ break ;
42
+
43
+ case $ strength ['score ' ] === 3 :
44
+ $ bag ->add (Message::medium ('The octet string is safe, but a longer key is preferable. ' ));
45
+
46
+ break ;
47
+
48
+ default :
49
+ break ;
50
+ }
51
+ } catch (Throwable ) {
52
+ $ bag ->add (Message::medium ('The test of the weakness cannot be performed. ' ));
49
53
}
50
54
}
51
55
}
You can’t perform that action at this time.
0 commit comments