Skip to content

Commit

Permalink
fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
massimocandela committed Oct 16, 2023
1 parent 34f5774 commit 5a07f2a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/monitors/monitorAS.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,19 @@ export default class MonitorAS extends Monitor {

const matchedPrefixRule = this.getMoreSpecificMatch(messagePrefix, true);

const groupsUnion = [...new Set([...matchedRule.group, ...matchedPrefixRule.group])];
const differentGroups = this.skipPrefixMatchOnDifferentGroups
&& (groupsUnion.length !== matchedRule.group.length || groupsUnion.length !== matchedPrefixRule.group);

if (differentGroups || !matchedPrefixRule) {
if (matchedPrefixRule) {
const matchedRuleGroup = [matchedRule.group].flat() ?? ["default"];
const matchedPrefixRuleGroup = [matchedPrefixRule.group].flat() ?? ["default"];

if (this.skipPrefixMatchOnDifferentGroups && matchedRuleGroup.some(g => !matchedPrefixRuleGroup.includes(g))) {
this.publishAlert(messageOrigin.getId().toString() + "-" + messagePrefix,
messageOrigin.getId(),
matchedRule,
message,
{});
}

} else {
this.publishAlert(messageOrigin.getId().toString() + "-" + messagePrefix,
messageOrigin.getId(),
matchedRule,
Expand Down
1 change: 1 addition & 0 deletions tests/config.test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ monitors:
channel: misconfiguration
name: asn-monitor
params:
skipPrefixMatchOnDifferentGroups: false
thresholdMinPeers: 2

- file: monitorRPKI
Expand Down

0 comments on commit 5a07f2a

Please sign in to comment.