chg: [internal] Simplified Warninglist::__checkValue

pull/6335/head
Jakub Onderka 2020-09-07 19:14:17 +02:00
parent b031ad3a07
commit a77ee50845
1 changed files with 8 additions and 12 deletions

View File

@ -496,30 +496,26 @@ class Warninglist extends AppModel
private function __checkValue($listValues, $value, $type, $listType) private function __checkValue($listValues, $value, $type, $listType)
{ {
if ($type === 'malware-sample' || strpos($type, '|') !== false) { if ($type === 'malware-sample' || strpos($type, '|') !== false) {
$value = explode('|', $value); $value = explode('|', $value, 2);
} else { } else {
$value = array($value); $value = array($value);
} }
$components = array(0, 1); foreach ($value as $v) {
foreach ($components as $component) {
if (!isset($value[$component])) {
continue;
}
if ($listType === 'cidr') { if ($listType === 'cidr') {
$result = $this->__evalCidrList($listValues, $value[$component]); $result = $this->__evalCidrList($listValues, $v);
} elseif ($listType === 'string') { } elseif ($listType === 'string') {
$result = $this->__evalString($listValues, $value[$component]); $result = $this->__evalString($listValues, $v);
} elseif ($listType === 'substring') { } elseif ($listType === 'substring') {
$result = $this->__evalSubString($listValues, $value[$component]); $result = $this->__evalSubString($listValues, $v);
} elseif ($listType === 'hostname') { } elseif ($listType === 'hostname') {
$result = $this->__evalHostname($listValues, $value[$component]); $result = $this->__evalHostname($listValues, $v);
} elseif ($listType === 'regex') { } elseif ($listType === 'regex') {
$result = $this->__evalRegex($listValues, $value[$component]); $result = $this->__evalRegex($listValues, $v);
} else { } else {
$result = false; $result = false;
} }
if ($result !== false) { if ($result !== false) {
return [$result, $value[$component]]; return [$result, $v];
} }
} }
return false; return false;