Skip to content

Commit b549b07

Browse files
authored
Merge pull request #163 from secureCodeBox/feature/teams-webhook
Implementing the MS Teams WebHook
2 parents c1e6806 + c0f1499 commit b549b07

27 files changed

+12918
-6
lines changed

.github/workflows/ci.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,16 @@ jobs:
318318
build_args: baseImageTag=ci-local
319319
tag_with_ref: true
320320
tag_with_sha: true
321+
- uses: docker/build-push-action@v1
322+
name: "Build & Push MS Teams Notification Hook Image"
323+
with:
324+
username: ${{ secrets.DOCKER_USERNAME }}
325+
password: ${{ secrets.DOCKER_PASSWORD }}
326+
repository: securecodebox/hook-teams-notification
327+
path: ./hooks/teams-webhook/
328+
build_args: baseImageTag=ci-local
329+
tag_with_ref: true
330+
tag_with_sha: true
321331
- uses: docker/build-push-action@v1
322332
name: "Build & Push GenericWebhook Hook Image"
323333
with:

hooks/finding-post-processing/hook.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1313
See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
16-
const { isMatch, merge } = require("lodash")
16+
const { isMatch, merge } = require("lodash");
1717
async function handle({
1818
getFindings,
1919
updateFindings,
20-
rules =JSON.parse(process.env["RULES"]),
20+
rules = JSON.parse(process.env["RULES"]),
2121
}) {
2222
const findings = await getFindings();
2323
const res = applyRules(rules, findings);
@@ -32,18 +32,20 @@ module.exports.handle = handle;
3232
*/
3333
function applyRules(rules, findings) {
3434
let hasChanged = false;
35-
const newFindings = findings.map(finding => {
35+
const newFindings = findings.map((finding) => {
3636
let newFinding = finding;
3737
for (const rule of rules) {
38-
const isRuleMatching = rule.matches.anyOf.some(condition => isMatch(finding, condition));
38+
const isRuleMatching = rule.matches.anyOf.some((condition) =>
39+
isMatch(finding, condition)
40+
);
3941
if (isRuleMatching) {
4042
hasChanged = true;
4143
newFinding = postProcessFinding(finding, rule);
4244
}
4345
}
4446
return newFinding;
4547
});
46-
return { hasChanged, findings: newFindings }
48+
return { hasChanged, findings: newFindings };
4749
}
4850

4951
function postProcessFinding(finding, rule) {

hooks/teams-webhook/.dockerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules/

hooks/teams-webhook/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules

hooks/teams-webhook/.helmignore

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Patterns to ignore when building packages.
2+
# This supports shell glob matching, relative path matching, and
3+
# negation (prefixed with !). Only one pattern per line.
4+
.DS_Store
5+
# Common VCS dirs
6+
.git/
7+
.gitignore
8+
.bzr/
9+
.bzrignore
10+
.hg/
11+
.hgignore
12+
.svn/
13+
# Common backup files
14+
*.swp
15+
*.bak
16+
*.tmp
17+
*~
18+
# Various IDEs
19+
.project
20+
.idea/
21+
*.tmproj
22+
.vscode/
23+
# Node.js files
24+
node_modules/*
25+
package.json
26+
package-lock.json
27+
src/*
28+
config/*
29+
Dockerfile
30+
.dockerignore

hooks/teams-webhook/Chart.lock

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
dependencies: []
2+
digest: sha256:643d5437104296e21d906ecb15b2c96ad278f20cfc4af53b12bb6069bd853726
3+
generated: "2020-05-26T16:56:03.119255+02:00"

hooks/teams-webhook/Chart.yaml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Copyright 2020 iteratec GmbH
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
apiVersion: v2
16+
name: teams-webhook
17+
description: Lets you send a findings result summary as webhook to MS Teams, after a scan is completed.
18+
19+
type: application
20+
21+
# version - gets automatically set to the secureCodeBox release version when the helm charts gets published
22+
version: latest
23+
kubeVersion: ">=v1.11.0-0"
24+
25+
dependencies: []

hooks/teams-webhook/Dockerfile

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Copyright 2020 iteratec GmbH
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
ARG baseImageTag
16+
FROM node:12-alpine as build
17+
RUN mkdir -p /home/app
18+
WORKDIR /home/app
19+
COPY package.json package-lock.json ./
20+
RUN npm ci --production
21+
22+
FROM securecodebox/hook-sdk-nodejs:${baseImageTag:-latest}
23+
WORKDIR /home/app/hook-wrapper/hook/
24+
COPY --from=build --chown=app:app /home/app/node_modules/ ./node_modules/
25+
COPY --chown=app:app ./hook.js ./hook.js
26+
COPY --chown=app:app ./msteams-template.js ./msteams-template.js

hooks/teams-webhook/README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ usecase: "Publishes Scan Summary to MS Teams."
1010

1111
## Deployment
1212

13-
Installing the Teams WebHook hook will add a ReadOnly Hook to your namespace.
13+
Installing the Teams WebHook hook will add a ReadOnly Hook to your namespace.
1414

1515
> 🔧 The implementation is currently work-in-progress and still undergoing major changes. It'll be released here once it has stabilized.
16+
17+
```bash
18+
helm upgrade --install twh ./hooks/teams-webhook/ --set notification.url="http://example.com/my/webhook/target"
19+
```
20+
> ✍ This documentation is currently work-in-progress.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
title: "MS Teams WebHook"
3+
category: "hook"
4+
type: "integration"
5+
state: "roadmap"
6+
usecase: "Publishes Scan Summary to MS Teams."
7+
---
8+
9+
<!-- end -->
10+
11+
## Deployment
12+
13+
Installing the Teams WebHook hook will add a ReadOnly Hook to your namespace.
14+
15+
> 🔧 The implementation is currently work-in-progress and still undergoing major changes. It'll be released here once it has stabilized.
16+
17+
18+
```bash
19+
helm upgrade --install twh ./hooks/teams-webhook/ --set notification.url="http://example.com/my/webhook/target"
20+
```
21+
> ✍ This documentation is currently work-in-progress.

0 commit comments

Comments
 (0)