Skip to content

Commit

Permalink
improved performance of misconfig monitor
Browse files Browse the repository at this point in the history
  • Loading branch information
massimocandela committed Oct 19, 2023
1 parent e3f5746 commit 631aae1
Showing 1 changed file with 17 additions and 15 deletions.
32 changes: 17 additions & 15 deletions src/monitors/monitorAS.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,32 +80,34 @@ export default class MonitorAS extends Monitor {

const messageOrigin = message.originAS;
const messagePrefix = message.prefix;
const matchedRule = this.getMonitoredAsMatch(messageOrigin);
const matchedASRule = this.getMonitoredAsMatch(messageOrigin);

if (matchedRule) {
if (matchedASRule) {

const matchedPrefixRules = this.getMoreSpecificMatches(messagePrefix, true, false);

if (this.skipPrefixMatch) {
this.publishAlert(messageOrigin.getId().toString() + "-" + messagePrefix,
messageOrigin.getId(),
matchedRule,
message,
{});

for (let matchedPrefixRule of matchedPrefixRules) {
this.publishAlert(messageOrigin.getId().toString() + "-" + messagePrefix,
messageOrigin.getId(),
matchedPrefixRule,
message,
{});
const skipMatches = matchedPrefixRules.map(i => i.group).flat();
const goodMatches = matchedASRule.map(i => i.group).flat();

for (let g of goodMatches) {
if (!skipMatches.includes(g)) {
this.publishAlert(messageOrigin.getId().toString() + "-" + messagePrefix,
messageOrigin.getId(),
{
...matchedASRule,
group: [g]
},
message,
{});
}
}

} else if (!matchedPrefixRules.length) {

this.publishAlert(messageOrigin.getId().toString() + "-" + messagePrefix,
messageOrigin.getId(),
matchedRule,
matchedASRule,
message,
{});
}
Expand Down

0 comments on commit 631aae1

Please sign in to comment.