From 5a07f2a0132dd8687707e209f875a4ea1f275f3f Mon Sep 17 00:00:00 2001 From: Massimo Candela Date: Mon, 16 Oct 2023 13:27:39 +0200 Subject: [PATCH] fixed tests --- src/monitors/monitorAS.js | 18 +++++++++++++----- tests/config.test.yml | 1 + 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/monitors/monitorAS.js b/src/monitors/monitorAS.js index 40dd7253..255832a0 100644 --- a/src/monitors/monitorAS.js +++ b/src/monitors/monitorAS.js @@ -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, diff --git a/tests/config.test.yml b/tests/config.test.yml index 48c74de5..1cd9f6a1 100644 --- a/tests/config.test.yml +++ b/tests/config.test.yml @@ -35,6 +35,7 @@ monitors: channel: misconfiguration name: asn-monitor params: + skipPrefixMatchOnDifferentGroups: false thresholdMinPeers: 2 - file: monitorRPKI