line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Carp::Parse::CallerInformation::Redacted; |
2
|
|
|
|
|
|
|
|
3
|
12
|
|
|
12
|
|
56040
|
use warnings; |
|
12
|
|
|
|
|
25
|
|
|
12
|
|
|
|
|
405
|
|
4
|
12
|
|
|
12
|
|
70
|
use strict; |
|
12
|
|
|
|
|
25
|
|
|
12
|
|
|
|
|
383
|
|
5
|
|
|
|
|
|
|
|
6
|
12
|
|
|
12
|
|
77
|
use Carp; |
|
12
|
|
|
|
|
30
|
|
|
12
|
|
|
|
|
896
|
|
7
|
12
|
|
|
12
|
|
8284
|
use Data::Dump; |
|
12
|
|
|
|
|
98809
|
|
|
12
|
|
|
|
|
1006
|
|
8
|
|
|
|
|
|
|
|
9
|
12
|
|
|
12
|
|
113
|
use base 'Carp::Parse::CallerInformation'; |
|
12
|
|
|
|
|
31
|
|
|
12
|
|
|
|
|
14865
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 NAME |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
Carp::Parse::CallerInformation::Redacted - Represent the parsed caller information for a line of the Carp stack trace. |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 DESCRIPTION |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
This module inherits from Carp::Parse::CallerInformation and adds the |
20
|
|
|
|
|
|
|
get_redacted_arguments_list() method to it. See C |
21
|
|
|
|
|
|
|
for the list of all the methods this module offers. |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
As a user, you should not have to create Carp::Parse::CallerInformation objects |
24
|
|
|
|
|
|
|
yourself, they will get created for you by C. |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=head1 VERSION |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
Version 1.1.5 |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=cut |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
our $VERSION = '1.1.5'; |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=head1 SYNOPSIS |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
# Retrieve the redacted arguments array. |
39
|
|
|
|
|
|
|
my $redacted_arguments_list = $caller_information->get_redacted_arguments_list(); |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=head1 METHODS |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=head2 new() |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
Create a new C object. |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
my $redacted_caller_information = Carp::Parse::CallerInformation::Redacted->new( |
49
|
|
|
|
|
|
|
{ |
50
|
|
|
|
|
|
|
arguments_string => $arguments_string, |
51
|
|
|
|
|
|
|
arguments_list => $arguments_list, |
52
|
|
|
|
|
|
|
redacted_arguments_list => $redacted_arguments_list, |
53
|
|
|
|
|
|
|
line => $line, |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
); |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=cut |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub new |
60
|
|
|
|
|
|
|
{ |
61
|
23
|
|
|
23
|
1
|
3997
|
my ( $class, $data ) = @_; |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
# Verify parameters. |
64
|
23
|
100
|
66
|
|
|
354
|
croak 'The first argument must be a hashref with the data to set on the object.' |
65
|
|
|
|
|
|
|
unless defined( $data ) && UNIVERSAL::isa( $data, 'HASH' ); ## no critic (BuiltinFunctions::ProhibitUniversalIsa) |
66
|
22
|
|
|
|
|
59
|
my $line = delete( $data->{'line'} ); |
67
|
22
|
|
|
|
|
58
|
my $arguments_string = delete( $data->{'arguments_string'} ); |
68
|
22
|
|
|
|
|
62
|
my $arguments_list = delete( $data->{'arguments_list'} ); |
69
|
22
|
|
|
|
|
47
|
my $redacted_arguments_list = delete( $data->{'redacted_arguments_list'} ); |
70
|
22
|
100
|
|
|
|
94
|
croak "The data hashref must contain the 'line' key with the original stack line" |
71
|
|
|
|
|
|
|
unless defined( $line ); |
72
|
21
|
50
|
|
|
|
84
|
croak "The following parameters are not supported: " . Data::Dump::dump( $data ) |
73
|
|
|
|
|
|
|
if scalar( keys %$data ) != 0; |
74
|
|
|
|
|
|
|
|
75
|
21
|
|
|
|
|
187
|
return bless( |
76
|
|
|
|
|
|
|
{ |
77
|
|
|
|
|
|
|
line => $line, |
78
|
|
|
|
|
|
|
arguments_string => $arguments_string, |
79
|
|
|
|
|
|
|
arguments_list => $arguments_list, |
80
|
|
|
|
|
|
|
redacted_arguments_list => $redacted_arguments_list, |
81
|
|
|
|
|
|
|
}, |
82
|
|
|
|
|
|
|
$class, |
83
|
|
|
|
|
|
|
); |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head2 get_redacted_arguments_list() |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
Return an arrayref of the arguments parsed for this caller, with the sensitive |
90
|
|
|
|
|
|
|
arguments redacted out. |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
my $redacted_arguments_list = $caller_information->get_redacted_arguments_list(); |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=cut |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
sub get_redacted_arguments_list |
97
|
|
|
|
|
|
|
{ |
98
|
14
|
|
|
14
|
1
|
7985
|
my ( $self ) = @_; |
99
|
|
|
|
|
|
|
|
100
|
14
|
|
|
|
|
79
|
return $self->{'redacted_arguments_list'}; |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=head2 get_redacted_line() |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
Return the redacted version of the original line from the stack trace. |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
my $redacted_line = $caller_information->get_redacted_line(); |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=cut |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
sub get_redacted_line |
113
|
|
|
|
|
|
|
{ |
114
|
6
|
|
|
6
|
1
|
4784
|
my ( $self ) = @_; |
115
|
|
|
|
|
|
|
|
116
|
6
|
|
|
|
|
81
|
my $line = $self->get_line(); |
117
|
6
|
|
|
|
|
79
|
my $arguments_string = $self->get_arguments_string(); |
118
|
|
|
|
|
|
|
|
119
|
6
|
100
|
|
|
|
51
|
if ( defined( $arguments_string ) ) |
120
|
|
|
|
|
|
|
{ |
121
|
5
|
|
50
|
|
|
23
|
my $redacted_arguments_list = $self->get_redacted_arguments_list() || []; |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
# Data::Dump::dump() is really nice except that it treats arrays with |
124
|
|
|
|
|
|
|
# only one member as a string, so we need to make an exception for |
125
|
|
|
|
|
|
|
# formatting in that case. |
126
|
5
|
|
|
|
|
28
|
my $redacted_arguments_string = Data::Dump::dump( @$redacted_arguments_list ); |
127
|
5
|
100
|
|
|
|
1561
|
$redacted_arguments_string = "($redacted_arguments_string)" |
128
|
|
|
|
|
|
|
if scalar( @$redacted_arguments_list ) == 1; |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
# Data::Dump::dump() may format the output on more than one line. |
131
|
|
|
|
|
|
|
# We make sure that the indentation of the original line is carried |
132
|
|
|
|
|
|
|
# here to the new lines. |
133
|
5
|
|
|
|
|
28
|
my ( $indentation ) = $line =~ /^(\s*)/; |
134
|
5
|
|
|
|
|
41
|
$redacted_arguments_string =~ s/(\r?\n)/$1$indentation/gs; |
135
|
|
|
|
|
|
|
|
136
|
5
|
|
|
|
|
142
|
$line =~ s/\(\Q$arguments_string\E\)/$redacted_arguments_string/x; |
137
|
|
|
|
|
|
|
} |
138
|
|
|
|
|
|
|
|
139
|
6
|
|
|
|
|
32
|
return $line |
140
|
|
|
|
|
|
|
} |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=head1 AUTHOR |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
Kate Kirby, C<< >>. |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
Guillaume Aubert, C<< >>. |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=head1 BUGS |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
Please report any bugs or feature requests to C, or through |
153
|
|
|
|
|
|
|
the web interface at L. |
154
|
|
|
|
|
|
|
I will be notified, and then you'll automatically be notified of progress on |
155
|
|
|
|
|
|
|
your bug as I make changes. |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
=head1 SUPPORT |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
perldoc Carp::Parse::CallerInformation::Redacted |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
You can also look for information at: |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
=over 4 |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
L |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
L |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
=item * CPAN Ratings |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
L |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
=item * Search CPAN |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
L |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
=back |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
Thanks to ThinkGeek (L) and its corporate overlords |
191
|
|
|
|
|
|
|
at Geeknet (L), for footing the bill while we eat pizza |
192
|
|
|
|
|
|
|
and write code for them! |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
Copyright 2012 Kate Kirby & Guillaume Aubert. |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License version 3 as published by the Free Software Foundation. |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/ |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
=cut |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
1; |