Log occ commands for the audit trail
Commands run through the terminal were only logged at debug level, and admin_audit skipped them because the console request carried no command in argv. Pass the command as argv so admin_audit records the full command the way it does for occ on the command line, and log the command name with the user as a warning, like the SQL mode does for queries. The regular log gets only the name, because arguments can hold secrets (config:system:set --value=...).
This commit is contained in:
@@ -114,7 +114,15 @@ class OccController extends Controller
|
||||
public function cmd($command)
|
||||
{
|
||||
if ($err = $this->requireAdmin()) return $err;
|
||||
$this->logger->debug($command);
|
||||
// The regular log gets only the command name: arguments can hold
|
||||
// secrets (config:system:set --value=...). The full command goes to
|
||||
// admin_audit through the ConsoleEvent, like occ on the CLI.
|
||||
$this->logger->warning('[extended_occweb] occ command by {user}: {command}', [
|
||||
'app' => 'extended_occweb',
|
||||
'user' => $this->userId,
|
||||
'command' => strtok(trim((string) $command), " \t\n") ?: '(empty)',
|
||||
]);
|
||||
$this->fakeRequest->server['argv'] = ['occ', $command];
|
||||
$input = new StringInput($command);
|
||||
$response = $this->run($input);
|
||||
$this->logger->debug($response);
|
||||
|
||||
Reference in New Issue
Block a user