File tree Expand file tree Collapse file tree 1 file changed +23
-19
lines changed
src/Component/KeyManagement/Analyzer Expand file tree Collapse file tree 1 file changed +23
-19
lines changed Original file line number Diff line number Diff line change 77use function is_string ;
88use Jose \Component \Core \JWK ;
99use ParagonIE \ConstantTime \Base64UrlSafe ;
10+ use Throwable ;
1011use ZxcvbnPhp \Zxcvbn ;
1112
1213final class ZxcvbnKeyAnalyzer implements KeyAnalyzer
@@ -27,25 +28,28 @@ public function analyze(JWK $jwk, MessageBag $bag): void
2728 return ;
2829 }
2930 $ 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. ' ));
4953 }
5054 }
5155}
You can’t perform that action at this time.
0 commit comments