line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
#=============================================================================== |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
# FILE: PwnedError.pm |
5
|
|
|
|
|
|
|
# |
6
|
|
|
|
|
|
|
# DESCRIPTION: Throw an exception for failure to check pwned password |
7
|
|
|
|
|
|
|
# |
8
|
|
|
|
|
|
|
# FILES: --- |
9
|
|
|
|
|
|
|
# BUGS: --- |
10
|
|
|
|
|
|
|
# NOTES: --- |
11
|
|
|
|
|
|
|
# AUTHOR: Pete Houston, cpan@openstrike.co.uk |
12
|
|
|
|
|
|
|
# ORGANIZATION: Openstrike |
13
|
|
|
|
|
|
|
# VERSION: See $VERSION in code |
14
|
|
|
|
|
|
|
# CREATED: 18/07/18 14:53:15 |
15
|
|
|
|
|
|
|
# REVISION: --- |
16
|
|
|
|
|
|
|
#=============================================================================== |
17
|
|
|
|
|
|
|
|
18
|
4
|
|
|
4
|
|
985
|
use strict; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
117
|
|
19
|
4
|
|
|
4
|
|
19
|
use warnings; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
152
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
package Password::Policy::Exception::PwnedError; |
22
|
|
|
|
|
|
|
|
23
|
4
|
|
|
4
|
|
40
|
use parent 'Password::Policy::Exception'; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
22
|
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
our $VERSION = '0.02'; |
26
|
|
|
|
|
|
|
|
27
|
3
|
|
|
3
|
1
|
3603
|
sub error { return 'Invalid response checking for pwned password'; } |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=head1 NAME |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
Password::Policy::Exception::PwnedError - Die if the password pwned API is unreachable |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=head1 SYNOPSIS |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
use Password::Policy; |
36
|
|
|
|
|
|
|
use Try::Tiny; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
my $pass = 'password1'; |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
my $pp = Password::Policy->new (config => 'policy.yaml'); |
41
|
|
|
|
|
|
|
try { |
42
|
|
|
|
|
|
|
$pp->process({ password => $pass }); |
43
|
|
|
|
|
|
|
} catch { |
44
|
|
|
|
|
|
|
warn "This password '$pass' is pwned - don't use it"; |
45
|
|
|
|
|
|
|
# Other actions |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=head1 DESCRIPTION |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
This exception is thrown when L |
51
|
|
|
|
|
|
|
cannot determine whether or not a password has been pwned. The |
52
|
|
|
|
|
|
|
determination depends on a remote service which may not be available for |
53
|
|
|
|
|
|
|
any number of reasons. |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head1 METHODS |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head2 error |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
$exception->error (); |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
This method is not expected to be called directly but rather via |
62
|
|
|
|
|
|
|
Cprocess>. It returns the text of an appropriate |
63
|
|
|
|
|
|
|
error which in this case is "Invalid response checking for pwned password". |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head1 SEE ALSO |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
For how to determine if passwords are pwned, see |
68
|
|
|
|
|
|
|
L. |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
To understand how to use this as part of a wider password policy |
71
|
|
|
|
|
|
|
enforcement program, see L. |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head1 REPOSITORY |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
L |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head1 MAINTAINER |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
This module is written and maintained by Pete Houston of Openstrike |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head1 COPYRIGHT INFORMATION |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
Copyright 2018 by Pete Houston. All Rights Reserved. |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
Permission to use, copy, and distribute is hereby granted, |
87
|
|
|
|
|
|
|
providing that the above copyright notice and this permission |
88
|
|
|
|
|
|
|
appear in all copies and in supporting documentation. |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head1 LICENCE |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
93
|
|
|
|
|
|
|
under the same terms as Perl itself. |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=cut |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
1; |