fix: [logs] Remove support for elastic logging for auditlog, as it was broken and didnt work

pull/8749/head
Jakub Onderka 2022-11-12 20:42:27 +01:00
parent e458023b8f
commit b508674f2c
4 changed files with 15 additions and 30 deletions

View File

@ -165,13 +165,7 @@ class AccessLog extends AppModel
}
$this->publishKafkaNotification('audit', $data, 'log');
if (Configure::read('Plugin.ElasticSearch_logging_enable')) {
// send off our logs to distributed /dev/null
$logIndex = Configure::read("Plugin.ElasticSearch_log_index");
$elasticSearchClient = $this->getElasticSearchTool();
$elasticSearchClient->pushDocument($logIndex, "log", $data);
}
// In future add support for sending logs to elastic
}
/**

View File

@ -41,8 +41,6 @@ class AppModel extends Model
private $__profiler = array();
public $elasticSearchClient;
/** @var AttachmentTool|null */
private $attachmentTool;
@ -2974,17 +2972,6 @@ class AppModel extends Model
return self::$loadedPubSubTool;
}
protected function getElasticSearchTool()
{
if (!$this->elasticSearchClient) {
App::uses('ElasticSearchClient', 'Tools');
$client = new ElasticSearchClient();
$client->initTool();
$this->elasticSearchClient = $client;
}
return $this->elasticSearchClient;
}
/**
* @return BackgroundJobsTool
*/

View File

@ -46,9 +46,6 @@ class AuditLog extends AppModel
/** @var bool */
private $pubToZmq;
/** @var bool */
private $elasticLogging;
/** @var bool */
private $logClientIp;
@ -85,7 +82,6 @@ class AuditLog extends AppModel
$this->compressionEnabled = Configure::read('MISP.log_new_audit_compress') &&
(function_exists('brotli_compress') || function_exists('zstd_compress'));
$this->pubToZmq = $this->pubToZmq('audit');
$this->elasticLogging = Configure::read('Plugin.ElasticSearch_logging_enable');
$this->logClientIp = Configure::read('MISP.log_client_ip');
}
@ -262,12 +258,7 @@ class AuditLog extends AppModel
$this->publishKafkaNotification('audit', $data, 'log');
if ($this->elasticLogging) {
// send off our logs to distributed /dev/null
$logIndex = Configure::read("Plugin.ElasticSearch_log_index");
$elasticSearchClient = $this->getElasticSearchTool();
$elasticSearchClient->pushDocument($logIndex, "log", $data);
}
// In future add support for sending logs to elastic
// write to syslogd as well if enabled
if ($this->syslog === null) {

View File

@ -108,6 +108,8 @@ class Log extends AppModel
public $actsAs = ['LightPaginator'];
private $elasticSearchClient;
/**
* Null when not defined, false when not enabled
* @var Syslog|null|false
@ -1134,4 +1136,15 @@ class Log extends AppModel
break;
}
}
private function getElasticSearchTool()
{
if (!$this->elasticSearchClient) {
App::uses('ElasticSearchClient', 'Tools');
$client = new ElasticSearchClient();
$client->initTool();
$this->elasticSearchClient = $client;
}
return $this->elasticSearchClient;
}
}