Skip to content

Commit

Permalink
added max request size logging #51
Browse files Browse the repository at this point in the history
  • Loading branch information
denisdulici committed Aug 2, 2022
1 parent 3de8261 commit 72f30fa
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
4 changes: 4 additions & 0 deletions src/Config/firewall.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
// 'ip' => '\App\Models\YourIpModel',
],

'log' => [
'max_request_size' => 2048,
],

'cron' => [
'enabled' => env('FIREWALL_CRON_ENABLED', true),
'expression' => env('FIREWALL_CRON_EXPRESSION', '* * * * *'),
Expand Down
9 changes: 6 additions & 3 deletions src/Traits/Helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,18 @@ public function log($middleware = null, $user_id = null, $level = 'medium')
$middleware = $middleware ?? $this->middleware;
$user_id = $user_id ?? $this->user_id;

$log = config('firewall.models.log', Log::class);
return $log::create([
$model = config('firewall.models.log', Log::class);

$input = urldecode(http_build_query($this->request->input()));

return $model::create([
'ip' => $this->ip(),
'level' => $level,
'middleware' => $middleware,
'user_id' => $user_id,
'url' => $this->request->fullUrl(),
'referrer' => $this->request->server('HTTP_REFERER') ?: 'NULL',
'request' => urldecode(http_build_query($this->request->input())),
'request' => substr($input, 0, config('firewall.log.max_request_size')),
]);
}

Expand Down

0 comments on commit 72f30fa

Please sign in to comment.