| 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
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 33 | } | ||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | 5 | ▶ | if ($custom_sensitive && ref($custom_sensitive) eq 'ARRAY') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$custom_sensitive and ref $custom_sensitive eq "ARRAY"
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"
| |||||||||||||||||||||||||||||
| 36 | 5 | for my $sensitive (@$custom_sensitive) { | |||||||||||||||||||||||||||
| 37 | 4 | ▶ | return 1 if lc($sensitive) eq $lc_name; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 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__ | ||||||||||||||||||||||||||||