NAME
Carp::Parse::Redact - Parse a Carp stack trace into an array of caller information, while redacting sensitive function parameters out.
DESCRIPTION
Carp produces a stacktrace that includes caller arguments; this module parses each line of the stack trace to extract its arguments and redacts out the sensitive information contained in the function arguments for each caller.
VERSION
Version 1.1.5
DEFAULTS FOR REDACTING SENSITIVE DATA
Redacting using hash keys
By default, this module will redact values for which the argument name is:
password
passwd
cc_number
cc_exp
ccv
You can easily change this list when parsing a stack trace by passing the argument sensitive_argument_names when calling parse_stack_trace()
.
Redacting using regular expressions
By default, this module will redact subroutine arguments in the stack traces that match the following patterns:
Credit card numbers (VISA, MasterCard, American Express, Diners Club, Discover, JCB)
SYNOPSIS
# Retrieve a Carp stack trace with longmess(). This is tedious, but you will
# normally be using this module in a context where the stacktrace is already
# generated for you and you want to parse it, so you won't have to go through
# this step.
sub test3 { return Carp::longmess("Test"); }
sub test2 { return test3(); }
sub test1 { return test2(); }
my $stack_trace = test1();
# Parse the Carp stack trace.
# The call takes an optional list of arguments to redact, if you don't want
# to use the default.
use Carp::Parse::Redact;
my $redacted_parsed_stack_trace = Carp::Parse::Redact::parse_stack_trace(
$stack_trace,
sensitive_argument_names => #optional
[
'password',
'passwd',
'cc_number',
'cc_exp',
'ccv',
],
sensitive_regexp_patterns => #optional
[
qr/^\d{16}$/,
]
);
use Data::Dump qw( dump );
foreach my $caller_information ( @$parsed_stack_trace )
{
# Print the arguments for each caller.
say dump( $caller->get_redacted_arguments_list() );
}
FUNCTIONS
parse_stack_trace()
Parse a stack trace produced by Carp
into an arrayref of Carp::Parse::CallerInformation::Redacted
objects and redact out the sensitive information from each function caller arguments.
my $redacted_parsed_stack_trace = Carp::Parse::Redact::parse_stack_trace( $stack_trace );
my $redacted_parsed_stack_trace = Carp::Parse::Redact::parse_stack_trace(
$stack_trace,
sensitive_argument_names => #optional
[
password
passwd
cc_number
cc_exp
ccv
],
sensitive_regexp_patterns => #optional
[
qr/^\d{16}$/,
]
);
The first argument, a stack trace, is required. Optional parameters:
sensitive_argument_names
An arrayref of argument names to redact, when they are found in hashes of arguments in the stack trace. If not set, see the list of defaults used at the top of this documentation.
sensitive_regexp_patterns
An arrayref of regular expressions. If an argument in the list of subroutine calls in the stack trace matches any of the patterns, it will be redacted. If not set, see the list of defaults used at the top of this documentation.
AUTHOR
Kate Kirby, <kate at cpan.org>
.
Guillaume Aubert, <aubertg at cpan.org>
.
BUGS
Please report any bugs or feature requests to bug-carp-parse-redact at rt.cpan.org
, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Carp-Parse-Redact. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
SUPPORT
You can find documentation for this module with the perldoc command.
perldoc Carp::Parse::Redact
You can also look for information at:
RT: CPAN's request tracker
AnnoCPAN: Annotated CPAN documentation
CPAN Ratings
Search CPAN
ACKNOWLEDGEMENTS
Thanks to ThinkGeek (http://www.thinkgeek.com/) and its corporate overlords at Geeknet (http://www.geek.net/), for footing the bill while we eat pizza and write code for them!
COPYRIGHT & LICENSE
Copyright 2012 Kate Kirby & Guillaume Aubert.
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.
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.
You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/