Agent/MCP/HeaderUtils.pm

filter: Statementstmt 100% 30 / 30 Branchbran 90.0% 9 / 10 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 6 / 6 Podpod 100% 2 / 2 totaltotal 90.5% 48 / 53 CC 10 SCAR 16.6
CC
10
Cov
93%
is_sensitive_header
8.2
redacted_headers
3.0
BEGIN
1.0
CRAP 5.2
« Agent/Message/Assistant.pm ↑ Summary Agent/Permission.pm »
1 package Claude::Agent::MCP::HeaderUtils;
2  
3 8 ▶use 5.020;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 8 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 8 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 8 ▶use Exporter qw(import);
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 8 our @EXPORT_OK = qw(is_sensitive_header redacted_headers);
10  
11 8 my @AUTO_SENSITIVE = qw(
12 authorization
13 x-api-key
14 x-auth-token
15 x-access-token
16 bearer
17 api-key
18 apikey
19 secret
20 token
21 password
22 credential
23 );
24  
25 15 ▶sub is_sensitive_header {
Subroutine is_sensitive_header: called CC=8 SCAR=21.1
Pod documented
26 15 my ($header_name, $custom_sensitive) = @_;
27 15 ▶ return 0 unless defined $header_name;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $header_name 1 14 15
28  
29 14 my $lc_name = lc($header_name);
30  
31 14 for my $pattern (@AUTO_SENSITIVE) {
32 81 ▶ return 1 if index($lc_name, $pattern) >= 0;
Branch: 1 branch
BranchTrueFalseTotal
if index($lc_name, $pattern) != -1 9 72 81
33 }
34  
35 5 ▶ if ($custom_sensitive && ref($custom_sensitive) eq 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if ($custom_sensitive and ref $custom_sensitive eq "ARRAY") 5 0 5
Condition33%1/3
$custom_sensitive and ref $custom_sensitive eq "ARRAY"
!ll&&!rl&&r
005
MC/DC0%0/2
$custom_sensitive and ref $custom_sensitive eq "ARRAY"
$custom_sensitive ref $custom_sensitive eq "ARRAY"
Truth table33%1/3
A and B
A= $custom_sensitiveB= ref $custom_sensitive eq "ARRAY"
ABresult
0X0
100
111
36 5 for my $sensitive (@$custom_sensitive) {
37 4 ▶ return 1 if lc($sensitive) eq $lc_name;
Branch: 1 branch
BranchTrueFalseTotal
if lc $sensitive eq $lc_name 2 2 4
38 }
39 }
40  
41 3 return 0;
42 }
43  
44 2 ▶sub redacted_headers {
Subroutine redacted_headers: called CC=3 SCAR=11.0
Pod documented
45 2 my ($headers, $custom_sensitive) = @_;
46 2 my %redacted;
47  
48 2 for my $key (keys %$headers) {
49 5 ▶ if (is_sensitive_header($key, $custom_sensitive)) {
Branch: 1 branch
BranchTrueFalseTotal
if (is_sensitive_header($key, $custom_sensitive)) { } 4 1 5
50 4 $redacted{$key} = '[REDACTED]';
51 } else {
52 1 $redacted{$key} = $headers->{$key};
53 }
54 }
55  
56 2 return \%redacted;
57 }
58  
59  
60 8 1;
61  
62 __END__
« Agent/Message/Assistant.pm ↑ Summary Agent/Permission.pm »