Skip to content

Commit

Permalink
improved skipPrefixMatch and renamed skipPrefixMatchOnDifferentGroups
Browse files Browse the repository at this point in the history
  • Loading branch information
massimocandela committed Oct 16, 2023
1 parent a2e06f0 commit 34f5774
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion config.yml.example
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ monitors:
channel: misconfiguration
name: asn-monitor
params:
skipPrefixMatch: false
skipPrefixMatchOnDifferentGroups: false
thresholdMinPeers: 3

- file: monitorRPKI
Expand Down
2 changes: 1 addition & 1 deletion src/config/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export default class Config {
channel: "misconfiguration",
name: "asn-monitor",
params: {
skipPrefixMatch: false,
skipPrefixMatchOnDifferentGroups: false,
thresholdMinPeers: 3
}
},
Expand Down
10 changes: 7 additions & 3 deletions src/monitors/monitorAS.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export default class MonitorAS extends Monitor {
constructor(name, channel, params, env, input){
super(name, channel, params, env, input);
this.thresholdMinPeers = (params && params.thresholdMinPeers != null) ? params.thresholdMinPeers : 3;
this.skipPrefixMatch = !!params?.skipPrefixMatch;
this.skipPrefixMatchOnDifferentGroups = !!params?.skipPrefixMatchOnDifferentGroups;
this.updateMonitoredResources();
};

Expand Down Expand Up @@ -69,7 +69,7 @@ export default class MonitorAS extends Monitor {
if (prefixesOut.length > 1) {
return `${matchedMessages[0].originAS} is announcing some prefixes which are not in the configured list of announced prefixes: ${prefixesOut}`
} else if (prefixesOut.length === 1) {
return `${matchedMessages[0].originAS} is announcing ${matchedMessages[0].prefix} but this prefix is not in the configured list of announced prefixes`;
return `${matchedMessages[0].originAS} is announcing ${matchedMessages[0].prefix} but this prefix is not in the configured list of announced prefixes`;
}

return false;
Expand All @@ -86,7 +86,11 @@ export default class MonitorAS extends Monitor {

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,
messageOrigin.getId(),
matchedRule,
Expand Down

0 comments on commit 34f5774

Please sign in to comment.