From 89493ffca64b96559ab85e5ad1c108a04d27a050 Mon Sep 17 00:00:00 2001 From: Yannik Fuhrmeister Date: Tue, 15 Jun 2021 14:40:34 +0200 Subject: [PATCH 01/11] [Refactor] Create New AbstractWebHookNotifier The implementation for a ms-teams notifier is nearly identical to the implementation of the slack notifier so I decided to create a new base class to handle Webhook Notifiers Signed-off-by: Yannik Fuhrmeister --- .../Notifiers/AbstractWebHookNotifier.ts | 32 +++++++++++++++++++ hooks/notification/Notifiers/SlackNotifier.ts | 17 ++-------- 2 files changed, 34 insertions(+), 15 deletions(-) create mode 100644 hooks/notification/Notifiers/AbstractWebHookNotifier.ts diff --git a/hooks/notification/Notifiers/AbstractWebHookNotifier.ts b/hooks/notification/Notifiers/AbstractWebHookNotifier.ts new file mode 100644 index 0000000000..cd46691b6d --- /dev/null +++ b/hooks/notification/Notifiers/AbstractWebHookNotifier.ts @@ -0,0 +1,32 @@ +// SPDX-FileCopyrightText: 2020 iteratec GmbH +// +// SPDX-License-Identifier: Apache-2.0 + +import { NotifierType } from "../NotifierType" +import { AbstractNotifier } from "./AbstractNotifier" +import { Finding } from "../model/Finding" +import axios from 'axios'; +import { NotificationChannel } from "../model/NotificationChannel"; +import { Scan } from "../model/Scan"; + +export abstract class AbstractWebHookNotifier extends AbstractNotifier { + + protected abstract type: NotifierType; + + constructor(channel: NotificationChannel, scan: Scan, findings: Finding[], args: Object) { + super(channel, scan, findings, args); + } + + public async sendMessage(): Promise { + await this.sendPostRequest(this.renderMessage()); + } + + protected async sendPostRequest(message: string) { + try { + await axios.post(this.channel.endPoint, message) + } catch (e) { + console.log(`There was an Error sending the Message for the "${this.type}": "${this.channel.name}"`); + console.log(e); + } + } +} diff --git a/hooks/notification/Notifiers/SlackNotifier.ts b/hooks/notification/Notifiers/SlackNotifier.ts index 7980894481..a964b2d0cb 100644 --- a/hooks/notification/Notifiers/SlackNotifier.ts +++ b/hooks/notification/Notifiers/SlackNotifier.ts @@ -3,30 +3,17 @@ // SPDX-License-Identifier: Apache-2.0 import { NotifierType } from "../NotifierType" -import { AbstractNotifier } from "./AbstractNotifier" +import { AbstractWebHookNotifier } from "./AbstractWebHookNotifier" import { Finding } from "../model/Finding" import axios from 'axios'; import { NotificationChannel } from "../model/NotificationChannel"; import { Scan } from "../model/Scan"; -export class SlackNotifier extends AbstractNotifier { +export class SlackNotifier extends AbstractWebHookNotifier { protected type: NotifierType = NotifierType.SLACK constructor(channel: NotificationChannel, scan: Scan, findings: Finding[], args: Object) { super(channel, scan, findings, args); } - - public async sendMessage(): Promise { - await this.sendPostRequest(this.renderMessage()); - } - - protected async sendPostRequest(message: string) { - try { - await axios.post(this.channel.endPoint, message) - } catch (e) { - console.log(`There was an Error sending the Message for the Slack Notifier "${this.channel.name}"`); - console.log(e); - } - } } From a6d3d65d20d7bfbc90c0944b7067d082687f4deb Mon Sep 17 00:00:00 2001 From: Yannik Fuhrmeister Date: Mon, 21 Jun 2021 09:23:11 +0200 Subject: [PATCH 02/11] Add MSTeamsNotifier I had to update a test for NotifierFactory because it expected the creation of a Notifier type of MS_TEAMS to fail. Signed-off-by: Yannik Fuhrmeister --- hooks/notification/NotifierFactory.test.ts | 7 +- hooks/notification/NotifierFactory.ts | 3 + .../Notifiers/MSTeamsNotifier.test.ts | 105 ++++++++++++++++++ .../notification/Notifiers/MSTeamsNotifier.ts | 19 ++++ .../.msteams-messageCard.njk.swp | Bin 0 -> 12288 bytes .../msteams-messageCard.njk | 64 +++++++++++ 6 files changed, 194 insertions(+), 4 deletions(-) create mode 100644 hooks/notification/Notifiers/MSTeamsNotifier.test.ts create mode 100644 hooks/notification/Notifiers/MSTeamsNotifier.ts create mode 100644 hooks/notification/notification-templates/.msteams-messageCard.njk.swp create mode 100644 hooks/notification/notification-templates/msteams-messageCard.njk diff --git a/hooks/notification/NotifierFactory.test.ts b/hooks/notification/NotifierFactory.test.ts index 7d793ba51b..24db902caf 100644 --- a/hooks/notification/NotifierFactory.test.ts +++ b/hooks/notification/NotifierFactory.test.ts @@ -7,6 +7,7 @@ import { NotificationChannel } from "./model/NotificationChannel"; import { Scan } from "./model/Scan"; import { NotifierFactory } from "./NotifierFactory" import { SlackNotifier } from "./Notifiers/SlackNotifier"; +import { MSTeamsNotifier } from "./Notifiers/MSTeamsNotifier"; import { NotifierType } from "./NotifierType"; const finding: Finding = { @@ -85,9 +86,7 @@ test("Should Create MS Teams Notifier", async () => { const findings: Finding[] = [] findings.push(finding) - const t = () => { - NotifierFactory.create(chan, scan, findings, []); - } + const s = NotifierFactory.create(chan, scan, findings, []); - expect(t).toThrow("This Type is not Implemented :("); + expect(s instanceof MSTeamsNotifier).toBe(true); }) diff --git a/hooks/notification/NotifierFactory.ts b/hooks/notification/NotifierFactory.ts index 8bf7de6ac3..63380703ff 100644 --- a/hooks/notification/NotifierFactory.ts +++ b/hooks/notification/NotifierFactory.ts @@ -7,6 +7,7 @@ import { NotifierType } from "./NotifierType"; import { SlackNotifier } from "./Notifiers/SlackNotifier"; import { SlackAppNotifier } from "./Notifiers/SlackAppNotifier"; import { EMailNotifier } from "./Notifiers/EMailNotifier"; +import { MSTeamsNotifier } from "./Notifiers/MSTeamsNotifier"; import { NotificationChannel } from "./model/NotificationChannel"; import { Scan } from "./model/Scan"; import { Finding } from "./model/Finding"; @@ -25,6 +26,8 @@ export class NotifierFactory { return new EMailNotifier(channel, scan, findings, args); case NotifierType.SLACK_APP: return new SlackAppNotifier(channel, scan, findings, args); + case NotifierType.MS_TEAMS: + return new MSTeamsNotifier(channel, scan, findings, args); default: throw new Error("This Type is not Implemented :("); } diff --git a/hooks/notification/Notifiers/MSTeamsNotifier.test.ts b/hooks/notification/Notifiers/MSTeamsNotifier.test.ts new file mode 100644 index 0000000000..bdba89a4ec --- /dev/null +++ b/hooks/notification/Notifiers/MSTeamsNotifier.test.ts @@ -0,0 +1,105 @@ +// SPDX-FileCopyrightText: 2020 iteratec GmbH +// +// SPDX-License-Identifier: Apache-2.0 + +import { MSTeamsNotifier } from "./MSTeamsNotifier"; +import axios from 'axios' +import { NotificationChannel } from "../model/NotificationChannel"; +import { NotifierType } from "../NotifierType"; +import { Scan } from "../model/Scan"; + +jest.mock('axios'); + +beforeEach(() => { + jest.clearAllMocks(); +}) + +const channel: NotificationChannel = { + name: "Channel Name", + type: NotifierType.MS_TEAMS, + template: "msteams-messageCard", + rules: [], + endPoint: "https://iteratec.webhook.office.com/webhookb2/f2a7b22a-6558-4db5-8d4b-860f8d4c6848@e96afb08-eeaf-49be-90d6-526571a42d8a/IncomingWebhook/cd8d3c70bb504eb8b44385a8e0ebe6f5/812e82db-e6d9-4651-b0c8-3becfca82658" +}; + +test("Should Send Message With Findings And Severities", async () => { + + const scan: Scan = { + metadata: { + uid: "09988cdf-1fc7-4f85-95ee-1b1d65dbc7cc", + name: "demo-scan-1601086432", + namespace: "my-scans", + creationTimestamp: new Date("2021-01-01T14:29:25Z"), + labels: { + company: "iteratec", + "attack-surface": "external", + }, + }, + spec: { + scanType: "Nmap", + parameters: ["-Pn", "localhost"], + }, + status: { + findingDownloadLink: + "https://my-secureCodeBox-instance.com/scan-b9as-sdweref--sadf-asdfsdf-dasdgf-asdffdsfa7/findings.json", + findings: { + categories: { + "A Client Error response code was returned by the server": 1, + "Information Disclosure - Sensitive Information in URL": 1, + "Strict-Transport-Security Header Not Set": 1, + }, + count: 3, + severities: { + high: 10, + medium: 5, + low: 2, + informational: 1, + }, + }, + finishedAt: new Date("2020-05-25T02:38:13Z"), + rawResultDownloadLink: + "https://my-secureCodeBox-instance.com/scan-blkfsdg-sdgfsfgd-sfg-sdfg-dfsg-gfs98-e8af2172caa7/zap-results.json?Expires=1601691232", + rawResultFile: "zap-results.json", + rawResultType: "zap-json", + state: "Done", + }, + }; + + const teamsNotifier = new MSTeamsNotifier(channel, scan, [], []); + teamsNotifier.sendMessage(); + expect(axios.post).toBeCalled(); +}); + +test("Should Send Minimal Template For Empty Findings", async () => { + const scan: Scan = { + metadata: { + uid: "09988cdf-1fc7-4f85-95ee-1b1d65dbc7cc", + name: "demo-scan-1601086432", + namespace: "my-scans", + creationTimestamp: new Date("2021-01-01T14:29:25Z"), + labels: { + company: "iteratec", + "attack-surface": "external", + }, + }, + spec: { + scanType: "Nmap", + parameters: ["-Pn", "localhost"], + }, + status: { + findingDownloadLink: + "https://my-secureCodeBox-instance.com/scan-b9as-sdweref--sadf-asdfsdf-dasdgf-asdffdsfa7/findings.json", + findings: {}, + finishedAt: new Date("2020-05-25T02:38:13Z"), + rawResultDownloadLink: + "https://my-secureCodeBox-instance.com/scan-blkfsdg-sdgfsfgd-sfg-sdfg-dfsg-gfs98-e8af2172caa7/zap-results.json?Expires=1601691232", + rawResultFile: "zap-results.json", + rawResultType: "zap-json", + state: "Done", + }, + }; + + const n = new MSTeamsNotifier(channel, scan, [], []); + n.sendMessage(); + expect(axios.post).toBeCalled(); +}) diff --git a/hooks/notification/Notifiers/MSTeamsNotifier.ts b/hooks/notification/Notifiers/MSTeamsNotifier.ts new file mode 100644 index 0000000000..5e50920595 --- /dev/null +++ b/hooks/notification/Notifiers/MSTeamsNotifier.ts @@ -0,0 +1,19 @@ +// SPDX-FileCopyrightText: 2020 iteratec GmbH +// +// SPDX-License-Identifier: Apache-2.0 + +import { NotifierType } from "../NotifierType" +import { AbstractWebHookNotifier } from "./AbstractWebHookNotifier" +import { Finding } from "../model/Finding" +import axios from 'axios'; +import { NotificationChannel } from "../model/NotificationChannel"; +import { Scan } from "../model/Scan"; + +export class MSTeamsNotifier extends AbstractWebHookNotifier { + + protected type: NotifierType = NotifierType.MS_TEAMS + + constructor(channel: NotificationChannel, scan: Scan, findings: Finding[], args: Object) { + super(channel, scan, findings, args); + } +} diff --git a/hooks/notification/notification-templates/.msteams-messageCard.njk.swp b/hooks/notification/notification-templates/.msteams-messageCard.njk.swp new file mode 100644 index 0000000000000000000000000000000000000000..e1c0414801e1de6d9479f5165745edfa5d617932 GIT binary patch literal 12288 zcmeI2&x<2P6vt~kx$3AWc&>>n1B2<_ABbbKf=*;{z}a2Qtb!*i)s=Kjy1Ux0>SVIx zD1s+1q8`MP2;SU3VZcAYgMwE*c<>+|1P=E3u@W%tr4aK;rV%&@z;N-kfzc)=?1cxR11`pC^QE{Y4^Dc}@v3OEIv0!{&^ zfK$LJaJCdM*$R0ZA>UJneWiY`-0`g6x`$K1Dc}@v3OEIv0!{&^fK$LJ;1qBQI0c*n zr%(YF60(0UA@81p^Z5V2`ThUvLxlVYZiA1(d*BTqzz*01YvAh#2{{6vgO9+QU<~@; z8L$F=S|#LLa0I>p?*jv_fG5B?@XG^O3w!`>0S2}K1*_n<`w960dMs z9s?`j=lclx4txnd10R9{yb7KL6#R~OzXzXyGWJurcg|&}fK$LJ;1qBQI0gPg1?d0L zCL-6UbPVYFMep)Dsa)us*E|vl>jX41CJTI@g)B32A~>oXwI>zIC+!5?4s`8^x2IKF z+n}__mFawQ$KYf!Waiwk&RBeAa*;-C~RR-&K558JZ}d+T_CU=vd$<2x|3^ zx?c>+1A0trJ5=f2%LN<>DKqrofNIWCFA)Y;#4wNBF`U+2iMn9Jl8hc668q7n>5Oq~ zRzR<*biR@0Nh%Nf$$PZK)ykhvA1=_1jrG5Hld?p>f%T1z`MI=?EIDC+?}bF|b9?Xx=T{e;EyJ8b)_du$VpMy9E1vN>w92WsDDnjxD=j_aSL zqvJtnGqYLb1~S+})|orDouDk6*cGbw@BHUwIBlHG)v2Ofyt*fBNxdD{#I!vaIuqQp zM`Rbfi>;t#eD;poPMX)*kL7~036n7!#A0n8=aP*&A#F5{-g$loDx5X>tWKwOF1Hoy z#7YBojYv&3tA2w-8_={Ux2oIBurUObWm#Mo$orEt^b*N)rPa`Q<##~yRY90Bj7JG9 ML(OXGx>lb23G8e^HUIzs literal 0 HcmV?d00001 diff --git a/hooks/notification/notification-templates/msteams-messageCard.njk b/hooks/notification/notification-templates/msteams-messageCard.njk new file mode 100644 index 0000000000..65cfa9b583 --- /dev/null +++ b/hooks/notification/notification-templates/msteams-messageCard.njk @@ -0,0 +1,64 @@ +type: message +attachments: + - contentType: application/vnd.microsoft.card.adaptive + contentUrl: null + content: + type: AdaptiveCard + body: + - type: TextBlock + size: Medium + weight: Bolder + text: "New {{ scan.spec.scanType }} security scan results are available!" + wrap: true + - type: ColumnSet + columns: + - type: Column + items: + - type: Image + style: Person + url: "https://securecodebox.io/favicon.png" + size: Small + width: auto + - type: Column + items: + - type: TextBlock + weight: Bolder + text: "Scan **'{{ scan.metadata.name }}'**" + wrap: true + - type: TextBlock + spacing: None + text: Created at {{ scan.metadata.creationTimestamp }} + isSubtle: true + wrap: true + width: stretch + - type: TextBlock + text: Findings Category Overview + wrap: true + weight: Bolder + size: Medium + - type: FactSet + facts: + {% for category, counter in scan.status.findings.categories -%} + - title: "{{ category }}:" + value: "{{ counter }}" + {% endfor %} + - type: TextBlock + text: Findings Severity Overview + wrap: true + weight: Bolder + size: Medium + - type: FactSet + facts: + {% for severity, counter in scan.status.findings.severities -%} + - title: "{{ severity }}:" + value: "{{ counter }}" + {% endfor %} + actions: + - type: Action.OpenUrl + title: Open Dashboard + url: "${viewUrl}" + - type: Action.OpenUrl + title: Show Results in Dashboard + url: "${viewUrl}" + "$schema": http://adaptivecards.io/schemas/adaptive-card.json + version: '1.3' From 1ad5e9c7967cdc16c3535bbed8606ea21f31cd10 Mon Sep 17 00:00:00 2001 From: Yannik Fuhrmeister Date: Mon, 21 Jun 2021 12:19:59 +0200 Subject: [PATCH 03/11] Add Option To Render Nunjucks Templates I wanted to render a nested template for a url containing a placeholder for an id Unfortunately I was not able to render this with the default setup so I decided to pass another object to the render function containing the Nunjucks function to render Strings Signed-off-by: Yannik Fuhrmeister --- hooks/notification/Notifiers/AbstractNotifier.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/hooks/notification/Notifiers/AbstractNotifier.ts b/hooks/notification/Notifiers/AbstractNotifier.ts index f3138d414b..45f0d58e4d 100644 --- a/hooks/notification/Notifiers/AbstractNotifier.ts +++ b/hooks/notification/Notifiers/AbstractNotifier.ts @@ -50,6 +50,7 @@ export abstract class AbstractNotifier implements Notifier { findings: this.findings, scan: this.scan, args: this.args, + renderString: nunjucks.renderString, } ); try { From e28938b1e0f12c02199b776876fa06790ba25d93 Mon Sep 17 00:00:00 2001 From: Yannik Fuhrmeister Date: Mon, 21 Jun 2021 12:33:10 +0200 Subject: [PATCH 04/11] Update Template To Show DashboardURL Signed-off-by: Yannik Fuhrmeister --- .../notification-templates/msteams-messageCard.njk | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/hooks/notification/notification-templates/msteams-messageCard.njk b/hooks/notification/notification-templates/msteams-messageCard.njk index 65cfa9b583..506fc9014a 100644 --- a/hooks/notification/notification-templates/msteams-messageCard.njk +++ b/hooks/notification/notification-templates/msteams-messageCard.njk @@ -53,12 +53,14 @@ attachments: - title: "{{ severity }}:" value: "{{ counter }}" {% endfor %} + {% if args["VULNMANAG_ENABLED"] == true -%} actions: - type: Action.OpenUrl title: Open Dashboard - url: "${viewUrl}" + url: "{{ renderString(args["dashboardUrl"].toString(), { uid: scan.metadata.uid }) }}" - type: Action.OpenUrl title: Show Results in Dashboard - url: "${viewUrl}" + url: "{{ renderString(args["dashboardFindingsUrl"], { uid: scan.metadata.uid }) }}" + {% endif %} "$schema": http://adaptivecards.io/schemas/adaptive-card.json version: '1.3' From 8bd1c735f4b31575046b238ca40ead7c0315c3d7 Mon Sep 17 00:00:00 2001 From: Yannik Fuhrmeister Date: Mon, 28 Jun 2021 08:03:42 +0200 Subject: [PATCH 05/11] Change URL For SCB Favicon Signed-off-by: Yannik Fuhrmeister --- .../.msteams-messageCard.njk.swp | Bin 12288 -> 0 bytes .../msteams-messageCard.njk | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) delete mode 100644 hooks/notification/notification-templates/.msteams-messageCard.njk.swp diff --git a/hooks/notification/notification-templates/.msteams-messageCard.njk.swp b/hooks/notification/notification-templates/.msteams-messageCard.njk.swp deleted file mode 100644 index e1c0414801e1de6d9479f5165745edfa5d617932..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 12288 zcmeI2&x<2P6vt~kx$3AWc&>>n1B2<_ABbbKf=*;{z}a2Qtb!*i)s=Kjy1Ux0>SVIx zD1s+1q8`MP2;SU3VZcAYgMwE*c<>+|1P=E3u@W%tr4aK;rV%&@z;N-kfzc)=?1cxR11`pC^QE{Y4^Dc}@v3OEIv0!{&^ zfK$LJaJCdM*$R0ZA>UJneWiY`-0`g6x`$K1Dc}@v3OEIv0!{&^fK$LJ;1qBQI0c*n zr%(YF60(0UA@81p^Z5V2`ThUvLxlVYZiA1(d*BTqzz*01YvAh#2{{6vgO9+QU<~@; z8L$F=S|#LLa0I>p?*jv_fG5B?@XG^O3w!`>0S2}K1*_n<`w960dMs z9s?`j=lclx4txnd10R9{yb7KL6#R~OzXzXyGWJurcg|&}fK$LJ;1qBQI0gPg1?d0L zCL-6UbPVYFMep)Dsa)us*E|vl>jX41CJTI@g)B32A~>oXwI>zIC+!5?4s`8^x2IKF z+n}__mFawQ$KYf!Waiwk&RBeAa*;-C~RR-&K558JZ}d+T_CU=vd$<2x|3^ zx?c>+1A0trJ5=f2%LN<>DKqrofNIWCFA)Y;#4wNBF`U+2iMn9Jl8hc668q7n>5Oq~ zRzR<*biR@0Nh%Nf$$PZK)ykhvA1=_1jrG5Hld?p>f%T1z`MI=?EIDC+?}bF|b9?Xx=T{e;EyJ8b)_du$VpMy9E1vN>w92WsDDnjxD=j_aSL zqvJtnGqYLb1~S+})|orDouDk6*cGbw@BHUwIBlHG)v2Ofyt*fBNxdD{#I!vaIuqQp zM`Rbfi>;t#eD;poPMX)*kL7~036n7!#A0n8=aP*&A#F5{-g$loDx5X>tWKwOF1Hoy z#7YBojYv&3tA2w-8_={Ux2oIBurUObWm#Mo$orEt^b*N)rPa`Q<##~yRY90Bj7JG9 ML(OXGx>lb23G8e^HUIzs diff --git a/hooks/notification/notification-templates/msteams-messageCard.njk b/hooks/notification/notification-templates/msteams-messageCard.njk index 506fc9014a..8bee75049f 100644 --- a/hooks/notification/notification-templates/msteams-messageCard.njk +++ b/hooks/notification/notification-templates/msteams-messageCard.njk @@ -16,7 +16,7 @@ attachments: items: - type: Image style: Person - url: "https://securecodebox.io/favicon.png" + url: "https://www.securecodebox.io/favicon.png" size: Small width: auto - type: Column From 3b3ee49fae13052548cf3e050f8bf2aa7fe6940c Mon Sep 17 00:00:00 2001 From: Yannik Fuhrmeister Date: Mon, 28 Jun 2021 08:05:49 +0200 Subject: [PATCH 06/11] Ignore Temporary VIM Files Signed-off-by: Yannik Fuhrmeister --- .gitignore | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/.gitignore b/.gitignore index 77d11c509f..985aa89d53 100644 --- a/.gitignore +++ b/.gitignore @@ -21,3 +21,29 @@ *.iml *.ipr out/ + +Created by https://www.toptal.com/developers/gitignore/api/vim +# Edit at https://www.toptal.com/developers/gitignore?templates=vim + +### Vim ### +# Swap +[._]*.s[a-v][a-z] +!*.svg # comment out if you don't need vector files +[._]*.sw[a-p] +[._]s[a-rt-v][a-z] +[._]ss[a-gi-z] +[._]sw[a-p] + +# Session +Session.vim +Sessionx.vim + +# Temporary +.netrwhist +*~ +# Auto-generated tag files +tags +# Persistent undo +[._]*.un~ + +# End of https://www.toptal.com/developers/gitignore/api/vim From c54f5cb388b0d8b8cf0702807aac29d89a1be8b1 Mon Sep 17 00:00:00 2001 From: Yannik Fuhrmeister Date: Mon, 28 Jun 2021 08:29:44 +0200 Subject: [PATCH 07/11] Add Documentation For MS Teams Notifier Signed-off-by: Yannik Fuhrmeister --- hooks/notification/.helm-docs.gotmpl | 34 +++++++++++++++++++++++++++- hooks/notification/README.md | 32 ++++++++++++++++++++++++++ 2 files changed, 65 insertions(+), 1 deletion(-) diff --git a/hooks/notification/.helm-docs.gotmpl b/hooks/notification/.helm-docs.gotmpl index e17f5d7ba0..10a36ef6a0 100644 --- a/hooks/notification/.helm-docs.gotmpl +++ b/hooks/notification/.helm-docs.gotmpl @@ -46,6 +46,7 @@ Please take a look at the documentation for each type (e.g. for slack see [Confi - [Slack](#configuration-of-a-slack-notification) - [Slack App](#configuration-of-a-slack-app-notification) - [Email](#configuration-of-an-email-notification) +- [MS Teams](#configuration-of-a-ms-teams-notification) ### Configuration of a Notification @@ -227,6 +228,37 @@ env: value: secureCodeBox ``` +### Configuration Of A MS Teams Notification + +To configure a MS Teams notification you need to set the type to `ms-teams`. +In `endPoint` you need to specify the MS Teams webhook. +To use the template provided by the secureCodeBox set template to `msteams-messageCard`. + +The default template allows you to specify an additional set of information. +If you you use the persistence-elastic or use some kind of dashboard, you can set the variable `VULNMANAG_ENABLED` to true, `dashboardUrl` to the URL of your dashboard. +This will add a button in the notification that opens your dashboard. +You can also add a button that opens your findings directly in your dashboard. +To do this you need to specify `dashboardFingingsUrl`. +You will have to replace the id of the scan in this url with `{{ `{{ uid }}` }}` so that nunjucks can parse these urls. + +A basic configuration could look like this: + +```yaml +notificationChannels: + - name: ms-teams + type: ms-teams + template: msteams-messageCard + rules: [] + endPoint: "https://somewhere.xyz/sadf12" +env: + - name: VULNMANAG_ENABLED + value: true + - name: dashboardUrl + value: "somedashboard.url" + - name: dashboardFindingsUrl + value: "somedashboard.url/findings/{{ `{{ uid }}` }}" +``` + ### Custom Message Templates CAUTION: Nunjucks templates allow code to be injected! Use templates from trusted sources only! @@ -244,4 +276,4 @@ To fill your template with data we provide the following objects. {{- end }} {{- define "extra.scannerLinksSection" -}} -{{- end }} \ No newline at end of file +{{- end }} diff --git a/hooks/notification/README.md b/hooks/notification/README.md index af712a84bf..3354899936 100644 --- a/hooks/notification/README.md +++ b/hooks/notification/README.md @@ -65,6 +65,7 @@ Please take a look at the documentation for each type (e.g. for slack see [Confi - [Slack](#configuration-of-a-slack-notification) - [Slack App](#configuration-of-a-slack-app-notification) - [Email](#configuration-of-an-email-notification) +- [MS Teams](#configuration-of-a-ms-teams-notification) ### Configuration of a Notification @@ -246,6 +247,37 @@ env: value: secureCodeBox ``` +### Configuration Of A MS Teams Notification + +To configure a MS Teams notification you need to set the type to `ms-teams`. +In `endPoint` you need to specify the MS Teams webhook. +To use the template provided by the secureCodeBox set template to `msteams-messageCard`. + +The default template allows you to specify an additional set of information. +If you you use the persistence-elastic or use some kind of dashboard, you can set the variable `VULNMANAG_ENABLED` to true, `dashboardUrl` to the URL of your dashboard. +This will add a button in the notification that opens your dashboard. +You can also add a button that opens your findings directly in your dashboard. +To do this you need to specify `dashboardFingingsUrl`. +You will have to replace the id of the scan in this url with `{{ uid }}` so that nunjucks can parse these urls. + +A basic configuration could look like this: + +```yaml +notificationChannels: + - name: ms-teams + type: ms-teams + template: msteams-messageCard + rules: [] + endPoint: "https://somewhere.xyz/sadf12" +env: + - name: VULNMANAG_ENABLED + value: true + - name: dashboardUrl + value: "somedashboard.url" + - name: dashboardFindingsUrl + value: "somedashboard.url/findings/{{ uid }}" +``` + ### Custom Message Templates CAUTION: Nunjucks templates allow code to be injected! Use templates from trusted sources only! From 6a2d9f28c01098afcea5367071b97c2f346d836a Mon Sep 17 00:00:00 2001 From: Yannik Fuhrmeister Date: Mon, 28 Jun 2021 08:51:48 +0200 Subject: [PATCH 08/11] Format Example As YAML Signed-off-by: Yannik Fuhrmeister --- hooks/notification/.helm-docs.gotmpl | 2 +- hooks/notification/README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/hooks/notification/.helm-docs.gotmpl b/hooks/notification/.helm-docs.gotmpl index 10a36ef6a0..0e3fe5be5c 100644 --- a/hooks/notification/.helm-docs.gotmpl +++ b/hooks/notification/.helm-docs.gotmpl @@ -205,7 +205,7 @@ This configuration needs to be specified under `env` in the values yaml. The identifier for this config has to be `SMTP_CONFIG`. A basic configuration could look like this: -``` +```yaml notificationChannels: - name: email type: email diff --git a/hooks/notification/README.md b/hooks/notification/README.md index 3354899936..ecd7d39e9b 100644 --- a/hooks/notification/README.md +++ b/hooks/notification/README.md @@ -224,7 +224,7 @@ This configuration needs to be specified under `env` in the values yaml. The identifier for this config has to be `SMTP_CONFIG`. A basic configuration could look like this: -``` +```yaml notificationChannels: - name: email type: email From b2bf02a28d3b4a70a81738cb766dbf6c27bb6d64 Mon Sep 17 00:00:00 2001 From: Yannik Fuhrmeister Date: Tue, 6 Jul 2021 09:21:26 +0200 Subject: [PATCH 09/11] Change ENV Vars To Uppercase Signed-off-by: Yannik Fuhrmeister --- hooks/notification/.helm-docs.gotmpl | 6 +++--- hooks/notification/README.md | 6 +++--- .../notification-templates/msteams-messageCard.njk | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/hooks/notification/.helm-docs.gotmpl b/hooks/notification/.helm-docs.gotmpl index 0e3fe5be5c..98985404bb 100644 --- a/hooks/notification/.helm-docs.gotmpl +++ b/hooks/notification/.helm-docs.gotmpl @@ -235,7 +235,7 @@ In `endPoint` you need to specify the MS Teams webhook. To use the template provided by the secureCodeBox set template to `msteams-messageCard`. The default template allows you to specify an additional set of information. -If you you use the persistence-elastic or use some kind of dashboard, you can set the variable `VULNMANAG_ENABLED` to true, `dashboardUrl` to the URL of your dashboard. +If you you use the persistence-elastic or use some kind of dashboard, you can set the variable `VULNMANAG_ENABLED` to true, `VULNMANAG_DASHBOARD_URL` to the URL of your dashboard. This will add a button in the notification that opens your dashboard. You can also add a button that opens your findings directly in your dashboard. To do this you need to specify `dashboardFingingsUrl`. @@ -253,9 +253,9 @@ notificationChannels: env: - name: VULNMANAG_ENABLED value: true - - name: dashboardUrl + - name: VULNMANAG_DASHBOARD_URL value: "somedashboard.url" - - name: dashboardFindingsUrl + - name: VULNMANAG_DASHBOARD_FINDINGS_URL value: "somedashboard.url/findings/{{ `{{ uid }}` }}" ``` diff --git a/hooks/notification/README.md b/hooks/notification/README.md index ecd7d39e9b..789ead5ba8 100644 --- a/hooks/notification/README.md +++ b/hooks/notification/README.md @@ -254,7 +254,7 @@ In `endPoint` you need to specify the MS Teams webhook. To use the template provided by the secureCodeBox set template to `msteams-messageCard`. The default template allows you to specify an additional set of information. -If you you use the persistence-elastic or use some kind of dashboard, you can set the variable `VULNMANAG_ENABLED` to true, `dashboardUrl` to the URL of your dashboard. +If you you use the persistence-elastic or use some kind of dashboard, you can set the variable `VULNMANAG_ENABLED` to true, `VULNMANAG_DASHBOARD_URL` to the URL of your dashboard. This will add a button in the notification that opens your dashboard. You can also add a button that opens your findings directly in your dashboard. To do this you need to specify `dashboardFingingsUrl`. @@ -272,9 +272,9 @@ notificationChannels: env: - name: VULNMANAG_ENABLED value: true - - name: dashboardUrl + - name: VULNMANAG_DASHBOARD_URL value: "somedashboard.url" - - name: dashboardFindingsUrl + - name: VULNMANAG_DASHBOARD_FINDINGS_URL value: "somedashboard.url/findings/{{ uid }}" ``` diff --git a/hooks/notification/notification-templates/msteams-messageCard.njk b/hooks/notification/notification-templates/msteams-messageCard.njk index 8bee75049f..539b1ca345 100644 --- a/hooks/notification/notification-templates/msteams-messageCard.njk +++ b/hooks/notification/notification-templates/msteams-messageCard.njk @@ -57,10 +57,10 @@ attachments: actions: - type: Action.OpenUrl title: Open Dashboard - url: "{{ renderString(args["dashboardUrl"].toString(), { uid: scan.metadata.uid }) }}" + url: "{{ renderString(args["VULNMANAG_DASHBOARD_URL"].toString(), { uid: scan.metadata.uid }) }}" - type: Action.OpenUrl title: Show Results in Dashboard - url: "{{ renderString(args["dashboardFindingsUrl"], { uid: scan.metadata.uid }) }}" + url: "{{ renderString(args["VULNMANAG_DASHBOARD_FINDINGS_URL"], { uid: scan.metadata.uid }) }}" {% endif %} "$schema": http://adaptivecards.io/schemas/adaptive-card.json version: '1.3' From cca9d0bedaa9721014637da237a28b50fd9a6456 Mon Sep 17 00:00:00 2001 From: Yannik Fuhrmeister Date: Tue, 6 Jul 2021 09:26:32 +0200 Subject: [PATCH 10/11] Change Wording For Hook Docs Signed-off-by: Yannik Fuhrmeister --- hooks/notification/.helm-docs.gotmpl | 4 ++-- hooks/notification/README.md | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/hooks/notification/.helm-docs.gotmpl b/hooks/notification/.helm-docs.gotmpl index 98985404bb..6723c08bdb 100644 --- a/hooks/notification/.helm-docs.gotmpl +++ b/hooks/notification/.helm-docs.gotmpl @@ -235,8 +235,8 @@ In `endPoint` you need to specify the MS Teams webhook. To use the template provided by the secureCodeBox set template to `msteams-messageCard`. The default template allows you to specify an additional set of information. -If you you use the persistence-elastic or use some kind of dashboard, you can set the variable `VULNMANAG_ENABLED` to true, `VULNMANAG_DASHBOARD_URL` to the URL of your dashboard. -This will add a button in the notification that opens your dashboard. +If you use an external web based vulnerability management system with some kind of dashboard, you can set the variable `VULNMANAG_ENABLED` to true and point the `VULNMANAG_DASHBOARD_URL` to the URL of your vulnerability management. +This will add a button in the notification that links directly to your dashboard. You can also add a button that opens your findings directly in your dashboard. To do this you need to specify `dashboardFingingsUrl`. You will have to replace the id of the scan in this url with `{{ `{{ uid }}` }}` so that nunjucks can parse these urls. diff --git a/hooks/notification/README.md b/hooks/notification/README.md index 789ead5ba8..99d57f7b83 100644 --- a/hooks/notification/README.md +++ b/hooks/notification/README.md @@ -254,8 +254,8 @@ In `endPoint` you need to specify the MS Teams webhook. To use the template provided by the secureCodeBox set template to `msteams-messageCard`. The default template allows you to specify an additional set of information. -If you you use the persistence-elastic or use some kind of dashboard, you can set the variable `VULNMANAG_ENABLED` to true, `VULNMANAG_DASHBOARD_URL` to the URL of your dashboard. -This will add a button in the notification that opens your dashboard. +If you use an external web based vulnerability management system with some kind of dashboard, you can set the variable `VULNMANAG_ENABLED` to true and point the `VULNMANAG_DASHBOARD_URL` to the URL of your vulnerability management. +This will add a button in the notification that links directly to your dashboard. You can also add a button that opens your findings directly in your dashboard. To do this you need to specify `dashboardFingingsUrl`. You will have to replace the id of the scan in this url with `{{ uid }}` so that nunjucks can parse these urls. From e33e69b805d2a5baeb05e52954c7ca193f610876 Mon Sep 17 00:00:00 2001 From: fuhrmeistery Date: Tue, 6 Jul 2021 07:53:16 +0000 Subject: [PATCH 11/11] Updating Helm Docs Signed-off-by: GitHub Actions --- hooks/notification/docs/README.ArtifactHub.md | 34 ++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/hooks/notification/docs/README.ArtifactHub.md b/hooks/notification/docs/README.ArtifactHub.md index 2202a63645..795c1aed92 100644 --- a/hooks/notification/docs/README.ArtifactHub.md +++ b/hooks/notification/docs/README.ArtifactHub.md @@ -73,6 +73,7 @@ Please take a look at the documentation for each type (e.g. for slack see [Confi - [Slack](#configuration-of-a-slack-notification) - [Slack App](#configuration-of-a-slack-app-notification) - [Email](#configuration-of-an-email-notification) +- [MS Teams](#configuration-of-a-ms-teams-notification) ### Configuration of a Notification @@ -231,7 +232,7 @@ This configuration needs to be specified under `env` in the values yaml. The identifier for this config has to be `SMTP_CONFIG`. A basic configuration could look like this: -``` +```yaml notificationChannels: - name: email type: email @@ -254,6 +255,37 @@ env: value: secureCodeBox ``` +### Configuration Of A MS Teams Notification + +To configure a MS Teams notification you need to set the type to `ms-teams`. +In `endPoint` you need to specify the MS Teams webhook. +To use the template provided by the secureCodeBox set template to `msteams-messageCard`. + +The default template allows you to specify an additional set of information. +If you use an external web based vulnerability management system with some kind of dashboard, you can set the variable `VULNMANAG_ENABLED` to true and point the `VULNMANAG_DASHBOARD_URL` to the URL of your vulnerability management. +This will add a button in the notification that links directly to your dashboard. +You can also add a button that opens your findings directly in your dashboard. +To do this you need to specify `dashboardFingingsUrl`. +You will have to replace the id of the scan in this url with `{{ uid }}` so that nunjucks can parse these urls. + +A basic configuration could look like this: + +```yaml +notificationChannels: + - name: ms-teams + type: ms-teams + template: msteams-messageCard + rules: [] + endPoint: "https://somewhere.xyz/sadf12" +env: + - name: VULNMANAG_ENABLED + value: true + - name: VULNMANAG_DASHBOARD_URL + value: "somedashboard.url" + - name: VULNMANAG_DASHBOARD_FINDINGS_URL + value: "somedashboard.url/findings/{{ uid }}" +``` + ### Custom Message Templates CAUTION: Nunjucks templates allow code to be injected! Use templates from trusted sources only!