From 64401339895023b24ecf356370bad7e708339d80 Mon Sep 17 00:00:00 2001 From: Jakub Onderka Date: Wed, 21 Jul 2021 08:42:05 +0200 Subject: [PATCH] chg: [internal] Convert variable to const --- app/Lib/Tools/ComplexTypeTool.php | 6 +++--- app/Model/Attribute.php | 4 ++-- app/Model/Correlation.php | 6 +++--- app/Model/Feed.php | 4 ++-- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/app/Lib/Tools/ComplexTypeTool.php b/app/Lib/Tools/ComplexTypeTool.php index 253d5aee3..1282f6954 100644 --- a/app/Lib/Tools/ComplexTypeTool.php +++ b/app/Lib/Tools/ComplexTypeTool.php @@ -3,7 +3,7 @@ require_once __DIR__ . '/TmpFileTool.php'; class ComplexTypeTool { - private static $__refangRegexTable = array( + private const REFANG_REGEX__TABLE = array( array( 'from' => '/^(hxxp|hxtp|htxp|meow|h\[tt\]p)/i', 'to' => 'http', @@ -35,7 +35,7 @@ class ComplexTypeTool public static function refangValue($value, $type) { - foreach (self::$__refangRegexTable as $regex) { + foreach (self::REFANG_REGEX__TABLE as $regex) { if (in_array($type, $regex['types'], true)) { $value = preg_replace($regex['from'], $regex['to'], $value); } @@ -352,7 +352,7 @@ class ComplexTypeTool private function __refangInput($input) { $input['refanged'] = $input['raw']; - foreach (self::$__refangRegexTable as $regex) { + foreach (self::REFANG_REGEX__TABLE as $regex) { $input['refanged'] = preg_replace($regex['from'], $regex['to'], $input['refanged']); } $input['refanged'] = rtrim($input['refanged'], "."); diff --git a/app/Model/Attribute.php b/app/Model/Attribute.php index 6d1155f0f..33a0fbec6 100644 --- a/app/Model/Attribute.php +++ b/app/Model/Attribute.php @@ -108,7 +108,7 @@ class Attribute extends AppModel 'anonymised' ); - public $primaryOnlyCorrelatingTypes = array( + public const PRIMARY_ONLY_CORRELATING_TYPES = array( 'ip-src|port', 'ip-dst|port', 'hostname|port', @@ -1689,7 +1689,7 @@ class Attribute extends AppModel foreach ($resultArray as $key => $result) { if (in_array($result['default_type'], $composeTypes, true)) { $pieces = explode('|', $result['value']); - if (in_array($result['default_type'], $this->primaryOnlyCorrelatingTypes, true)) { + if (in_array($result['default_type'], self::PRIMARY_ONLY_CORRELATING_TYPES, true)) { $or = ['Attribute.value1' => $pieces[0], 'Attribute.value2' => $pieces[0]]; } else { $or = ['Attribute.value1' => $pieces, 'Attribute.value2' => $pieces]; diff --git a/app/Model/Correlation.php b/app/Model/Correlation.php index aa356856d..8f8f8ac89 100644 --- a/app/Model/Correlation.php +++ b/app/Model/Correlation.php @@ -113,7 +113,7 @@ class Correlation extends AppModel 'Attribute.value1' => $value, 'AND' => [ 'Attribute.value2' => $value, - 'NOT' => ['Attribute.type' => $this->Attribute->primaryOnlyCorrelatingTypes] + 'NOT' => ['Attribute.type' => Attribute::PRIMARY_ONLY_CORRELATING_TYPES] ] ], 'NOT' => [ @@ -290,7 +290,7 @@ class Correlation extends AppModel // generate additional correlating attribute list based on the advanced correlations $extraConditions = $this->__buildAdvancedCorrelationConditions($a); $correlatingValues = array($a['value1']); - if (!empty($a['value2']) && !in_array($a['type'], $this->Attribute->primaryOnlyCorrelatingTypes, true)) { + if (!empty($a['value2']) && !in_array($a['type'], Attribute::PRIMARY_ONLY_CORRELATING_TYPES, true)) { $correlatingValues[] = $a['value2']; } @@ -301,7 +301,7 @@ class Correlation extends AppModel 'Attribute.value1' => $cV, 'AND' => [ 'Attribute.value2' => $cV, - 'NOT' => ['Attribute.type' => $this->Attribute->primaryOnlyCorrelatingTypes] + 'NOT' => ['Attribute.type' => Attribute::PRIMARY_ONLY_CORRELATING_TYPES] ] ], 'NOT' => [ diff --git a/app/Model/Feed.php b/app/Model/Feed.php index 9e19de169..8f2d1c7b8 100644 --- a/app/Model/Feed.php +++ b/app/Model/Feed.php @@ -392,7 +392,7 @@ class Feed extends AppModel list($value1, $value2) = explode('|', $attribute['value']); $parts = [$value1]; - if (!in_array($attribute['type'], $this->Attribute->primaryOnlyCorrelatingTypes, true)) { + if (!in_array($attribute['type'], Attribute::PRIMARY_ONLY_CORRELATING_TYPES, true)) { $parts[] = $value2; } } else { @@ -1316,7 +1316,7 @@ class Feed extends AppModel if (!in_array($attribute['type'], $this->Attribute->nonCorrelatingTypes)) { if (in_array($attribute['type'], $this->Attribute->getCompositeTypes())) { $value = explode('|', $attribute['value']); - if (in_array($attribute['type'], $this->Attribute->primaryOnlyCorrelatingTypes)) { + if (in_array($attribute['type'], Attribute::PRIMARY_ONLY_CORRELATING_TYPES, true)) { unset($value[1]); } } else {