1
0
mirror of https://github.com/nttgin/BGPalerter.git synced 2024-05-19 06:50:08 +00:00

improved skipPrefixMatch and renamed skipPrefixMatchOnDifferentGroups

This commit is contained in:
Massimo Candela
2023-10-16 04:14:55 +02:00
parent a2e06f0ec8
commit 34f5774db6
3 changed files with 9 additions and 5 deletions

View File

@@ -46,7 +46,7 @@ monitors:
channel: misconfiguration channel: misconfiguration
name: asn-monitor name: asn-monitor
params: params:
skipPrefixMatch: false skipPrefixMatchOnDifferentGroups: false
thresholdMinPeers: 3 thresholdMinPeers: 3
- file: monitorRPKI - file: monitorRPKI

View File

@@ -68,7 +68,7 @@ export default class Config {
channel: "misconfiguration", channel: "misconfiguration",
name: "asn-monitor", name: "asn-monitor",
params: { params: {
skipPrefixMatch: false, skipPrefixMatchOnDifferentGroups: false,
thresholdMinPeers: 3 thresholdMinPeers: 3
} }
}, },

View File

@@ -37,7 +37,7 @@ export default class MonitorAS extends Monitor {
constructor(name, channel, params, env, input){ constructor(name, channel, params, env, input){
super(name, channel, params, env, input); super(name, channel, params, env, input);
this.thresholdMinPeers = (params && params.thresholdMinPeers != null) ? params.thresholdMinPeers : 3; this.thresholdMinPeers = (params && params.thresholdMinPeers != null) ? params.thresholdMinPeers : 3;
this.skipPrefixMatch = !!params?.skipPrefixMatch; this.skipPrefixMatchOnDifferentGroups = !!params?.skipPrefixMatchOnDifferentGroups;
this.updateMonitoredResources(); this.updateMonitoredResources();
}; };
@@ -86,7 +86,11 @@ export default class MonitorAS extends Monitor {
const matchedPrefixRule = this.getMoreSpecificMatch(messagePrefix, true); const matchedPrefixRule = this.getMoreSpecificMatch(messagePrefix, true);
if (this.skipPrefixMatch || !matchedPrefixRule) { const groupsUnion = [...new Set([...matchedRule.group, ...matchedPrefixRule.group])];
const differentGroups = this.skipPrefixMatchOnDifferentGroups
&& (groupsUnion.length !== matchedRule.group.length || groupsUnion.length !== matchedPrefixRule.group);
if (differentGroups || !matchedPrefixRule) {
this.publishAlert(messageOrigin.getId().toString() + "-" + messagePrefix, this.publishAlert(messageOrigin.getId().toString() + "-" + messagePrefix,
messageOrigin.getId(), messageOrigin.getId(),
matchedRule, matchedRule,