chg: [internal] Do not load exclusion list from Redis again and again

pull/7655/head
Jakub Onderka 2021-08-12 15:05:39 +02:00
parent 1f10a88504
commit 14b78904ba
1 changed files with 13 additions and 6 deletions

View File

@ -21,7 +21,7 @@ class Correlation extends AppModel
)
);
private $exclusions = [];
private $exclusions;
public function correlateValueRouter($value)
{
@ -349,19 +349,26 @@ class Correlation extends AppModel
return $this->__saveCorrelations($correlations);
}
/**
* @param array $a
* @return bool True if attribute value is excluded
*/
private function __preventExcludedCorrelations($a)
{
$value = $a['value1'];
if (!empty($a['value2'])) {
$value .= '|' . $a['value2'];
}
if (empty($this->exclusions)) {
if ($this->exclusions === null) {
try {
$redis = $this->setupRedisWithException();
$this->exclusions = $redis->sMembers('misp:correlation_exclusions');
} catch (Exception $e) {
return false;
}
} else if (empty($this->exclusions)) {
return false;
}
$value = $a['value1'];
if (!empty($a['value2'])) {
$value .= '|' . $a['value2'];
}
foreach ($this->exclusions as $exclusion) {
if (!empty($exclusion)) {