Skip to content

Commit

Permalink
Merge branch 'dev' into dist
Browse files Browse the repository at this point in the history
  • Loading branch information
massimocandela committed Oct 16, 2023
2 parents 18d61a9 + 5a07f2a commit 22a7db6
Show file tree
Hide file tree
Showing 4 changed files with 18 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
18 changes: 15 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,19 @@ export default class MonitorAS extends Monitor {

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

if (this.skipPrefixMatch || !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 22a7db6

Please sign in to comment.