mirror of https://github.com/MISP/MISP
Merge branch '2.4' into develop
commit
8dc58f3a04
|
@ -180,3 +180,7 @@ CakeLog::config('error', array(
|
|||
CakePlugin::loadAll(array(
|
||||
'CakeResque' => array('bootstrap' => true)
|
||||
));
|
||||
|
||||
|
||||
// Enable the additional exception logging for certain failures (timeouts, out of memory, etc)
|
||||
Configure::write('Exception.renderer', 'AppExceptionRenderer');
|
|
@ -0,0 +1,77 @@
|
|||
<?php
|
||||
|
||||
App::uses('ExceptionRenderer', 'Error');
|
||||
|
||||
class AppExceptionRenderer extends ExceptionRenderer {
|
||||
|
||||
public function __construct($exception) {
|
||||
$this->controller = $this->_getController($exception);
|
||||
|
||||
if (method_exists($this->controller, 'appError')) {
|
||||
$this->controller->appError($exception);
|
||||
return;
|
||||
}
|
||||
$method = $template = Inflector::variable(str_replace('Exception', '', get_class($exception)));
|
||||
$code = $exception->getCode();
|
||||
|
||||
$methodExists = method_exists($this, $method);
|
||||
if ($exception instanceof CakeException && !$methodExists) {
|
||||
$this->_customErrorLogging($exception);
|
||||
$method = '_cakeError';
|
||||
if (empty($template) || $template === 'internalError') {
|
||||
$template = 'error500';
|
||||
}
|
||||
} elseif ($exception instanceof PDOException) {
|
||||
$method = 'pdoError';
|
||||
$template = 'pdo_error';
|
||||
$code = 500;
|
||||
} elseif (!$methodExists) {
|
||||
$method = 'error500';
|
||||
if ($code >= 400 && $code < 500) {
|
||||
$method = 'error400';
|
||||
}
|
||||
}
|
||||
|
||||
$isNotDebug = !Configure::read('debug');
|
||||
if ($isNotDebug && $method === '_cakeError') {
|
||||
$method = 'error400';
|
||||
}
|
||||
if ($isNotDebug && $code == 500) {
|
||||
$method = 'error500';
|
||||
}
|
||||
$this->template = $template;
|
||||
$this->method = $method;
|
||||
$this->error = $exception;
|
||||
}
|
||||
|
||||
protected function _customErrorLogging($exception): bool
|
||||
{
|
||||
$message = $exception->getMessage();
|
||||
$errorDetection = [
|
||||
'Maximum execution time of' => 'timeout',
|
||||
'Allowed memory size of' => 'out of memory'
|
||||
];
|
||||
$user = $this->controller->Auth->user();
|
||||
$ua = env('HTTP_USER_AGENT');
|
||||
$source = $this->controller->IndexFilter->isRest() ? 'API' : 'web UI';
|
||||
if (strpos($ua, 'MISP ') !== false) {
|
||||
$source = 'MISP sync';
|
||||
}
|
||||
foreach ($errorDetection as $search => $errorName) {
|
||||
if (strpos($message, $search) !== false) {
|
||||
$logMessage = sprintf(
|
||||
'%s %s error triggered by User %s (%s) via the %s on %s.',
|
||||
date('Y-m-d H:i:s'),
|
||||
$errorName,
|
||||
$user['id'],
|
||||
$user['email'],
|
||||
$source,
|
||||
$this->controller->request->here()
|
||||
);
|
||||
file_put_contents(LOGS . 'fatal_error.log', $logMessage . PHP_EOL, FILE_APPEND);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -1824,7 +1824,7 @@
|
|||
"Feed": {
|
||||
"name": "Infoblox-Threat-Intelligence",
|
||||
"provider": "infoblox.com",
|
||||
"url": "https:\/\/github.com\/infobloxopen\/threat-intelligence\/tree\/main\/indicators\/misp",
|
||||
"url": "https:\/\/raw.githubusercontent.com\/infobloxopen\/threat-intelligence\/main\/indicators\/misp",
|
||||
"rules": "{\"tags\":{\"OR\":[],\"NOT\":[]},\"orgs\":{\"OR\":[],\"NOT\":[]}}",
|
||||
"enabled": true,
|
||||
"distribution": "0",
|
||||
|
|
Loading…
Reference in New Issue