fix: [logs] reverted the removal of api logs from the /logs/ logging system unless confirmed

- breaks logging with existing configurations
pull/8796/head
iglocska 2022-11-28 13:27:40 +01:00
parent b64f2fd8a3
commit dbc18f2ca7
No known key found for this signature in database
GPG Key ID: BEA224F1FEF113AC
5 changed files with 36 additions and 2 deletions

View File

@ -58,7 +58,9 @@ class AccessLogsController extends AppController
}
return $this->RestResponse->viewData($list, 'json');
}
if (empty(Configure::read('MISP.log_skip_access_logs_in_application_logs'))) {
$this->Flash->warning(__('Access logs are logged in both application logs and access logs. Make sure you reconfigure your log monitoring tools and update MISP.log_skip_access_logs_in_application_logs.'));
}
$this->paginate['conditions'] = $conditions;
$list = $this->paginate();

View File

@ -682,6 +682,28 @@ class AppController extends Controller
$accessLog = ClassRegistry::init('AccessLog');
$accessLog->logRequest($user, $this->_remoteIp(), $this->request, $includeRequestBody);
}
if (
(empty(Configure::read('MISP.log_skip_access_logs_in_application_logs'))) &&
Configure::read('MISP.log_paranoid') || $userMonitoringEnabled
) {
$change = 'HTTP method: ' . $_SERVER['REQUEST_METHOD'] . PHP_EOL . 'Target: ' . $this->request->here;
if (
(
$this->request->is('post') ||
$this->request->is('put')
) &&
(
!empty(Configure::read('MISP.log_paranoid_include_post_body')) ||
$userMonitoringEnabled
)
) {
$payload = $this->request->input();
$change .= PHP_EOL . 'Request body: ' . $payload;
}
$this->loadModel('Log');
$this->Log->createLogEntry($user, 'request', 'User', $user['id'], 'Paranoid log entry', $change);
}
}
/**

View File

@ -2399,7 +2399,7 @@ class AppModel extends Model
'action' => 'update_db_worker',
'user_id' => 0,
'title' => __('Issues executing run_updates'),
'change' => __('Database updates are locked. Worker not spawned')
'change' => __('Database updates are locked. Make sure that you have an update worker running. If you do, it might be related to an update\'s execution repeatedly failing or still being in progress.')
));
if (!empty($job)) { // if multiple prio worker is enabled, want to mark them as done
$job['Job']['progress'] = 100;

View File

@ -61,6 +61,7 @@ class Log extends AppModel
'registration',
'registration_error',
'remove_dead_workers',
'request',
'request_delegation',
'reset_auth_key',
'send_mail',

View File

@ -5568,6 +5568,15 @@ class Server extends AppModel
'type' => 'boolean',
'null' => true
),
'log_skip_access_logs_in_application_logs' => [
'level' => 0,
'description' => __('Skip adding the access log entries to the /logs/ application logs. This is **HIGHLY** recommended as your instance will be logging these entries twice otherwise, however, for compatibility reasons for auditing we maintain this behaviour until confirmed otherwise.'),
'value' => false,
'errorMessage' => __('Access logs are logged twice. This is generally not recommended, make sure you update your tooling.'),
'test' => 'testBoolTrue',
'type' => 'boolean',
'null' => true
],
'log_paranoid' => array(
'level' => 0,
'description' => __('If this functionality is enabled all page requests will be logged. Keep in mind this is extremely verbose and will become a burden to your database.'),