Skip to content

Commit

Permalink
fix: [workflow-modules:Organisation_if] Make sure to convert operator…
Browse files Browse the repository at this point in the history
… to support new version of the module

Shoud fix MISP#9423
  • Loading branch information
mokaddem committed Dec 18, 2023
1 parent 23bf20d commit c8f7f89
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions app/Model/WorkflowModules/logic/Module_organisation_if.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ public function exec(array $node, WorkflowRoamingData $roamingData, array &$erro

$org_type = $params['org_type']['value'];
$operator = $params['condition']['value'];
$operator = $this->convertOperators($operator);
$selectedOrgs = !empty($params['org_id']['value']) ? $params['org_id']['value'] : [];
$selectedOrgs = is_array($selectedOrgs) ? $selectedOrgs : [$selectedOrgs]; // Backward compatibility for non-multiple `org_id`
$path = 'Event.org_id';
Expand All @@ -75,4 +76,20 @@ public function exec(array $node, WorkflowRoamingData $roamingData, array &$erro
$eval = $this->evaluateCondition($selectedOrgs, $operator, $extracted_org);
return !empty($eval);
}

/**
* Make sure to convert version 0.1 of this module to the new operators
*
* @param string $operator
* @return string
*/
private function convertOperators($operator)
{
if ($operator == 'equals') {
$operator = 'in';
} else if ($operator == 'not_equals') {
$operator = 'not_in';
}
return $operator;
}
}

0 comments on commit c8f7f89

Please sign in to comment.