mirror of https://github.com/MISP/MISP
chg: [internal] Convert variable to const
parent
bf9ee25239
commit
6440133989
|
@ -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'], ".");
|
||||
|
|
|
@ -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];
|
||||
|
|
|
@ -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' => [
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue