File Coverage

blib/lib/Sentry/Raven/Processor/RemoveStackVariables.pm
Criterion Covered Total %
statement 14 14 100.0
branch 1 2 50.0
condition n/a
subroutine 4 4 100.0
pod 1 1 100.0
total 20 21 95.2


line stmt bran cond sub pod time code
1             package Sentry::Raven::Processor::RemoveStackVariables;
2              
3 1     1   552 use 5.008;
  1         5  
4 1     1   6 use strict;
  1         2  
  1         20  
5 1     1   5 use warnings;
  1         2  
  1         195  
6              
7             =head1 NAME
8              
9             Sentry::Raven::Processor::RemoveStackVariables - Remove stack variables from stack traces in events
10              
11             =head1 SYNOPSIS
12              
13             use Sentry::Raven;
14             use Sentry::Raven::Processor::RemoveStackVariables;
15              
16             my $raven = Sentry::Raven->new(
17             processors => [ Sentry::Raven::Processor::RemoveStackVariables ],
18             );
19              
20             =head1 DESCRIPTION
21              
22             This processor removes variables from stack traces before they are posted to the sentry service. This prevents sensitive values from being exposed, such as passwords or credit card numbers.
23              
24             =head1 METHODS
25              
26             =head2 my $processed_event = Sentry::Raven::Processor::RemoveStackVariables->process( $event )
27              
28             Process an event.
29              
30             =cut
31              
32             sub process {
33 1     1 1 3 my ($class, $event) = @_;
34 1 50       5 if ($event->{'sentry.interfaces.Stacktrace'}) {
35 1         3 my $num_frames = scalar(@{$event->{'sentry.interfaces.Stacktrace'}->{frames}});
  1         38  
36 1         10 delete($event->{'sentry.interfaces.Stacktrace'}->{frames}->[$_]->{vars}) for 0..($num_frames-1);
37             }
38 1         4 return $event;
39             }
40              
41             1;