diff --git a/lib/NGCP/Panel/Controller/API/Interceptions.pm b/lib/NGCP/Panel/Controller/API/Interceptions.pm index dd15a17a02..ddb3bfe406 100644 --- a/lib/NGCP/Panel/Controller/API/Interceptions.pm +++ b/lib/NGCP/Panel/Controller/API/Interceptions.pm @@ -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: diff --git a/lib/NGCP/Panel/Controller/API/InterceptionsItem.pm b/lib/NGCP/Panel/Controller/API/InterceptionsItem.pm index 1f00f131b5..21f9d537e5 100644 --- a/lib/NGCP/Panel/Controller/API/InterceptionsItem.pm +++ b/lib/NGCP/Panel/Controller/API/InterceptionsItem.pm @@ -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: diff --git a/lib/NGCP/Panel/Role/API.pm b/lib/NGCP/Panel/Role/API.pm index d83dc5143a..3e99ec011e 100644 --- a/lib/NGCP/Panel/Role/API.pm +++ b/lib/NGCP/Panel/Role/API.pm @@ -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{