TT#30376 filter interception numbers from log

Change-Id: I280e7fd7266c47d9e3afdd0a96874a7f620e5316
changes/24/18724/7
Gerhard Jungwirth 7 years ago
parent 232a84729b
commit 00633d1618

@ -229,6 +229,18 @@ sub POST :Allow {
return;
}
sub filter_log_response {
my ($self, $c, $response_body, $params_data) = @_;
if (exists $params_data->{number}) {
$params_data->{number} = '***';
}
$response_body //= "";
$response_body =~ s!([+0-9]{2,})([0-9]{2})!***$2!g; # hide strings which look like a number
return ($response_body, $params_data);
}
1;
# vim: set tabstop=4 expandtab:

@ -173,6 +173,15 @@ sub DELETE :Allow {
return;
}
sub filter_log_response {
my ($self, $c, $response_body, $params_data) = @_;
$response_body //= "";
$response_body =~ s!([+0-9]{2,})([0-9]{2})!***$2!g; # hide strings which look like a number
return ($response_body, $params_data);
}
1;
# vim: set tabstop=4 expandtab:

@ -787,10 +787,16 @@ sub log_response {
$self->error($c, HTTP_INTERNAL_SERVER_ERROR, "Internal Server Error");
$c->clear_errors;
}
my ($response_body, $params_data) = $self->filter_log_response(
$c,
$c->response->body,
$c->request->parameters,
);
NGCP::Panel::Utils::Message::info(
c => $c,
type => 'api_response',
log => $c->response->body,
log => $response_body,
data => $params_data,
);
}
@ -1140,6 +1146,13 @@ sub complete_transaction{
}
return;
}
# $response_body can only be modified as a string due to its nature of being the raw response body
sub filter_log_response {
my ($self, $c, $response_body, $params_data) = @_;
return ($response_body, $params_data);
}
#------ accessors ---
sub resource_name{

Loading…
Cancel
Save