mirror of https://github.com/MISP/MISP
chg: [analyst-data:push] Added support of sync-filtering rules
parent
9d18007b2e
commit
e5d000143a
|
@ -524,6 +524,9 @@ class AnalystData extends AppModel
|
|||
if (!$this->Event->checkDistributionForPush($analystData, $server, $type)) {
|
||||
unset($dataForPush[$type][$i]);
|
||||
}
|
||||
if (!$this->isPushableForServerSyncRules($analystData[$type], $server)) {
|
||||
unset($dataForPush[$type][$i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
return $dataForPush;
|
||||
|
@ -548,6 +551,22 @@ class AnalystData extends AppModel
|
|||
return $sgIDs;
|
||||
}
|
||||
|
||||
private function isPushableForServerSyncRules(array $analystData, array $server): bool
|
||||
{
|
||||
$push_rules = json_decode($server['Server']['push_rules'], true);
|
||||
if (!empty($push_rules['orgs']['OR'])) {
|
||||
if (!in_array($analystData['Orgc']['id'], $push_rules['orgs']['OR'])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (!empty($push_rules['orgs']['NOT'])) {
|
||||
if (in_array($analystData['Orgc']['id'], $push_rules['orgs']['NOT'])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get an array of analyst data that the remote is willing to get and returns analyst data that should be pushed.
|
||||
|
|
Loading…
Reference in New Issue