diff --git a/config.yml.example b/config.yml.example index fa2a788..f7654c6 100644 --- a/config.yml.example +++ b/config.yml.example @@ -56,7 +56,7 @@ monitors: checkDisappearing: false - file: monitorROAS - channel: rpki + channel: roa name: rpki-diff params: enableDiffAlerts: true @@ -83,6 +83,7 @@ reports: - path - misconfiguration - rpki + - roa params: persistAlertData: false alertDataDirectory: alertdata/ @@ -95,6 +96,7 @@ reports: # - path # - misconfiguration # - rpki +# - roa # params: # showPaths: 5 # Amount of AS_PATHs to report in the alert # senderEmail: bgpalerter@xxxx @@ -127,6 +129,7 @@ reports: # - path # - misconfiguration # - rpki +# - roa # params: # showPaths: 0 # Amount of AS_PATHs to report in the alert # colors: @@ -135,6 +138,7 @@ reports: # visibility: '#fad648' # path: '#42cbf5' # rpki: '#d892f0' +# roa: '#d892f0' # hooks: # default: _YOUR_SLACK_WEBHOOK_URL_ # noc: _YOUR_SLACK_WEBHOOK_URL_ @@ -147,6 +151,7 @@ reports: # - path # - misconfiguration # - rpki +# - roa # params: # host: localhost # port: 9092 @@ -162,6 +167,7 @@ reports: # - asn-monitor # - misconfiguration # - rpki +# - roa # params: # host: 127.0.0.1 # port: 514 @@ -181,6 +187,7 @@ reports: # - path # - misconfiguration # - rpki +# - roa # params: # severity: # hijack: critical @@ -204,6 +211,7 @@ reports: # - path # - misconfiguration # - rpki +# - roa # params: # hooks: # default: _YOUR_WEBEX_WEBHOOK_URL_ @@ -217,6 +225,7 @@ reports: # - path # - misconfiguration # - rpki +# - roa # params: # templates: # See here how to write a template https://github.com/nttgin/BGPalerter/blob/main/docs/context.md # default: '{"text": "${summary}"}' @@ -235,6 +244,7 @@ reports: # - path # - misconfiguration # - rpki +# - roa # params: # showPaths: 0 # Amount of AS_PATHs to report in the alert # botUrl: https://api.telegram.org/bot<_BOT_ID_>/sendMessage @@ -250,6 +260,7 @@ reports: # - path # - misconfiguration # - rpki +# - roa # params: # maxAlertsAmount: 25 diff --git a/src/reports/email_templates/emailTemplates.js b/src/reports/email_templates/emailTemplates.js index 9b68f49..7a50c35 100644 --- a/src/reports/email_templates/emailTemplates.js +++ b/src/reports/email_templates/emailTemplates.js @@ -121,7 +121,7 @@ When event started: ${earliest} UTC\n\ Last event: ${latest} UTC\n\ See: ${rpkiLink}'; -const templateRoas = '${summary}\n\ +const templateRoa = '${summary}\n\ \n\ \n\ DETAILS:\n\ @@ -168,7 +168,7 @@ export default class emailTemplates { }, { channel: 'roa', - content: templateRoas + content: templateRoa } ]; diff --git a/src/reports/email_templates/roas.txt b/src/reports/email_templates/roa.txt similarity index 100% rename from src/reports/email_templates/roas.txt rename to src/reports/email_templates/roa.txt diff --git a/src/reports/report.js b/src/reports/report.js index 1f21f4b..6400be2 100644 --- a/src/reports/report.js +++ b/src/reports/report.js @@ -75,8 +75,10 @@ export default class Report { }; getRpkiLink = (prefix, asn) => { + asn = asn && asn.getValue() || []; + asn = (Array.isArray(asn)) ? [] : [asn]; return brembo.build("https://rpki.massimocandela.com/", { - path: ["#", prefix, asn], + path: ["#", prefix].concat(asn), params: { "sources": RpkiValidator.providers.join(",") } @@ -91,6 +93,10 @@ export default class Report { latest: moment(content.latest).utc().format("YYYY-MM-DD HH:mm:ss"), channel, type: content.origin, + bgplay: "", + rpkiLink: "", + slackUrl: "", + markDownUrl: "" }; let matched = null; @@ -170,10 +176,12 @@ export default class Report { context.asn = (matched.asn || "").toString(); context.prefix = matched.prefix || content.data[0].matchedMessage.prefix; context.description = matched.description || ""; + context.neworigin = content.data[0].matchedMessage.originAS; + context.newprefix = content.data[0].matchedMessage.prefix; context.bgplay = this.getBGPlayLink(matched.prefix, content.earliest, content.latest); - context.rpkiLink = this.getRpkiLink(context.prefix, context.asn); - context.slackUrl = `[<${context.rpkiLink}|See>]`; - context.markDownUrl = `[[see](${context.rpkiLink})]`; + context.rpkiLink = this.getRpkiLink(context.newprefix, context.neworigin); + context.slackUrl = ` [<${context.rpkiLink}|see>]`; + context.markDownUrl = ` [[see](${context.rpkiLink})]`; break; case "roa": diff --git a/tests/1_config.js b/tests/1_config.js index beabd49..000f86a 100644 --- a/tests/1_config.js +++ b/tests/1_config.js @@ -164,8 +164,8 @@ describe("Core functions", function() { expect(config.monitors[6]).to .containSubset({ - "channel": "rpki", - "name": "rpki-monitor" + "channel": "roa", + "name": "roa-diff" }); expect(config.monitors[config.monitors.length - 1]).to @@ -186,7 +186,11 @@ describe("Core functions", function() { "channels": [ "hijack", "newprefix", - "visibility" + "visibility", + "rpki", + "roa", + "misconfiguration", + "path" ], "params": {} }); diff --git a/tests/config.test.yml b/tests/config.test.yml index 06ac72d..48c74de 100644 --- a/tests/config.test.yml +++ b/tests/config.test.yml @@ -45,8 +45,8 @@ monitors: checkUncovered: true - file: monitorROAS - channel: rpki - name: rpki-monitor + channel: roa + name: roa-diff reports: - file: reportFile @@ -57,6 +57,7 @@ reports: - path - misconfiguration - rpki + - roa params: persistAlertData: false alertDataDirectory: alertdata/ @@ -69,6 +70,7 @@ reports: - path - misconfiguration - rpki + - roa params: maxAlertsAmount: 100