Skip to content

Commit

Permalink
Merge pull request #12 from certego/fix_certego_field
Browse files Browse the repository at this point in the history
Fix overwriting certego field
  • Loading branch information
ManofWax committed Jul 25, 2023
2 parents e64e40e + f62db4b commit b400697
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
## 1.6.x
### 1.6.3
#### Bugfix
* Fix overwriting of certego field
### 1.6.2
#### Bugfix
* Added filter in routing_filter
Expand All @@ -22,7 +25,7 @@
* Added routing history and loop protection in rule parsing

## 1.4.x
### 1.4.1
### 1.4.1+
#### Bugfix
* Updated *setup.py* to include new dependency *macaddress*
### 1.4.0
Expand Down
8 changes: 6 additions & 2 deletions routingfilter/routing.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,12 @@ def match(self, event: dict, type_: str = "streams", tag_field_name: str = "tags
:return: A list of dicts containing the matched rules and the outputs in the following format: {"rules": [...], "output": {...}}; an empty list if no rule matched
:rtype: List[dict]
"""
if not event.get("certego", {}).get("routing_history", {}):
event["certego"] = {"routing_history": {}}
# Creating routing_history if not present
if "certego" not in event:
event["certego"] = {}
if "routing_history" not in event["certego"]:
event["certego"]["routing_history"] = {}
# check for rules
if not self.rules:
self.logger.error("'rules_list' must be set before evaluating a match!")
raise ValueError("'rules_list' must be set before evaluating a match!")
Expand Down
6 changes: 3 additions & 3 deletions routingfilter/routing_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -373,9 +373,9 @@ def test_rule_in_routing_history(self):
"streams": {
}
}
self.assertFalse(self.routing.rule_in_routing_history(event, rule))
self.assertFalse(self.routing.rule_in_routing_history("streams", event, rule))
event = {"certego": {"routing_history": {"Workshop": "2023-06-06T18:00:00.000Z"}}}
self.assertFalse(self.routing.rule_in_routing_history(event, rule))
self.assertFalse(self.routing.rule_in_routing_history("streams", event, rule))
rule = {
"filters": [
{
Expand All @@ -394,6 +394,6 @@ def test_rule_in_routing_history(self):
}
}
}
self.assertTrue(self.routing.rule_in_routing_history(event, rule))
self.assertTrue(self.routing.rule_in_routing_history("streams", event, rule))


0 comments on commit b400697

Please sign in to comment.