Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
19d7d59
First base implementation.
J12934 Oct 19, 2020
63a518a
Intruduced a mustache template for the messageCard.
rfelber Oct 23, 2020
5ed4490
Adding hook configuration options.
rfelber Nov 18, 2020
3881d7b
Removed Mustache and replaced it with plain js templates.
rfelber Dec 20, 2020
7a9dbd4
Fixed test names.
rfelber Dec 20, 2020
4233414
Removed unused dependecies.
rfelber Dec 20, 2020
6cc84c0
Fixed ESlint issue.
rfelber Dec 21, 2020
fc115a0
Merge branch 'main' into feature/teams-webhook
rfelber Dec 21, 2020
368991d
Added licenceheader and fixed brocken urls.
rfelber Dec 22, 2020
0266c53
Fixed formatter issues.
rfelber Dec 22, 2020
ec9d07b
Fixed codeclimate issues.
rfelber Dec 22, 2020
777eb2f
Fixed codeclimate issues.
rfelber Dec 22, 2020
ea9a955
Updated dev dependencies.
rfelber Dec 22, 2020
c1969aa
Added new testcase for missing webhookUrls.
rfelber Dec 22, 2020
0dd0c19
Added a new rules based filter to define when the webhook should fire…
rfelber Dec 22, 2020
129e153
Merge branch 'main' into feature/teams-webhook
rfelber Dec 22, 2020
a8f41ff
Moved the ms teams template rendering into a seperate module.
rfelber Dec 22, 2020
7ff3935
Added missing helm2 chart.
rfelber Dec 22, 2020
e36426f
Added docker build to CI pipeline.
rfelber Dec 23, 2020
553ae97
Fixed review findings.
rfelber Dec 30, 2020
0fedba5
Fixed finishedDateTime issue (undefined if the hook is not the last o…
rfelber Jan 1, 2021
7c08989
Fixed old readme description.
rfelber Jan 1, 2021
42edfdd
Added missing parsing function for scan UID in dashboard URLs and fix…
rfelber Jan 2, 2021
5686acc
Updating Helm Docs
Jan 2, 2021
5eee799
Updated logo image reference.
rfelber Jan 5, 2021
bd50438
Updated logo image reference.
rfelber Jan 5, 2021
478f97c
Update snapshots to include new favicon image
J12934 Jan 12, 2021
59c4473
Retrigger FOSSA
J12934 Jan 12, 2021
fe84996
Merge branch 'main' into feature/teams-webhook
rfelber Jan 12, 2021
ed4d6f6
Merge branch 'main' into feature/teams-webhook
rfelber Jan 13, 2021
a904798
Merge branch 'main' into feature/teams-webhook
J12934 Jan 28, 2021
c0f1499
Merge branch 'main' into feature/teams-webhook
J12934 Jan 28, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,16 @@ jobs:
build_args: baseImageTag=ci-local
tag_with_ref: true
tag_with_sha: true
- uses: docker/build-push-action@v1
name: "Build & Push MS Teams Notification Hook Image"
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
repository: securecodebox/hook-teams-notification
path: ./hooks/teams-webhook/
build_args: baseImageTag=ci-local
tag_with_ref: true
tag_with_sha: true
- uses: docker/build-push-action@v1
name: "Build & Push GenericWebhook Hook Image"
with:
Expand Down
12 changes: 7 additions & 5 deletions hooks/finding-post-processing/hook.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
const { isMatch, merge } = require("lodash")
const { isMatch, merge } = require("lodash");
async function handle({
getFindings,
updateFindings,
rules =JSON.parse(process.env["RULES"]),
rules = JSON.parse(process.env["RULES"]),
}) {
const findings = await getFindings();
const res = applyRules(rules, findings);
Expand All @@ -32,18 +32,20 @@ module.exports.handle = handle;
*/
function applyRules(rules, findings) {
let hasChanged = false;
const newFindings = findings.map(finding => {
const newFindings = findings.map((finding) => {
let newFinding = finding;
for (const rule of rules) {
const isRuleMatching = rule.matches.anyOf.some(condition => isMatch(finding, condition));
const isRuleMatching = rule.matches.anyOf.some((condition) =>
isMatch(finding, condition)
);
if (isRuleMatching) {
hasChanged = true;
newFinding = postProcessFinding(finding, rule);
}
}
return newFinding;
});
return { hasChanged, findings: newFindings }
return { hasChanged, findings: newFindings };
}

function postProcessFinding(finding, rule) {
Expand Down
1 change: 1 addition & 0 deletions hooks/teams-webhook/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules/
1 change: 1 addition & 0 deletions hooks/teams-webhook/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
30 changes: 30 additions & 0 deletions hooks/teams-webhook/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
# Node.js files
node_modules/*
package.json
package-lock.json
src/*
config/*
Dockerfile
.dockerignore
3 changes: 3 additions & 0 deletions hooks/teams-webhook/Chart.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
dependencies: []
digest: sha256:643d5437104296e21d906ecb15b2c96ad278f20cfc4af53b12bb6069bd853726
generated: "2020-05-26T16:56:03.119255+02:00"
25 changes: 25 additions & 0 deletions hooks/teams-webhook/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Copyright 2020 iteratec GmbH
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

apiVersion: v2
name: teams-webhook
description: Lets you send a findings result summary as webhook to MS Teams, after a scan is completed.

type: application

# version - gets automatically set to the secureCodeBox release version when the helm charts gets published
version: latest
kubeVersion: ">=v1.11.0-0"

dependencies: []
26 changes: 26 additions & 0 deletions hooks/teams-webhook/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Copyright 2020 iteratec GmbH
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

ARG baseImageTag
FROM node:12-alpine as build
RUN mkdir -p /home/app
WORKDIR /home/app
COPY package.json package-lock.json ./
RUN npm ci --production

FROM securecodebox/hook-sdk-nodejs:${baseImageTag:-latest}
WORKDIR /home/app/hook-wrapper/hook/
COPY --from=build --chown=app:app /home/app/node_modules/ ./node_modules/
COPY --chown=app:app ./hook.js ./hook.js
COPY --chown=app:app ./msteams-template.js ./msteams-template.js
7 changes: 6 additions & 1 deletion hooks/teams-webhook/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ usecase: "Publishes Scan Summary to MS Teams."

## Deployment

Installing the Teams WebHook hook will add a ReadOnly Hook to your namespace.
Installing the Teams WebHook hook will add a ReadOnly Hook to your namespace.

> 🔧 The implementation is currently work-in-progress and still undergoing major changes. It'll be released here once it has stabilized.

```bash
helm upgrade --install twh ./hooks/teams-webhook/ --set notification.url="http://example.com/my/webhook/target"
```
> ✍ This documentation is currently work-in-progress.
21 changes: 21 additions & 0 deletions hooks/teams-webhook/README.md.gotmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
title: "MS Teams WebHook"
category: "hook"
type: "integration"
state: "roadmap"
usecase: "Publishes Scan Summary to MS Teams."
---

<!-- end -->

## Deployment

Installing the Teams WebHook hook will add a ReadOnly Hook to your namespace.

> 🔧 The implementation is currently work-in-progress and still undergoing major changes. It'll be released here once it has stabilized.


```bash
helm upgrade --install twh ./hooks/teams-webhook/ --set notification.url="http://example.com/my/webhook/target"
```
> ✍ This documentation is currently work-in-progress.
1 change: 1 addition & 0 deletions hooks/teams-webhook/__mocks__/axios.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports.post = jest.fn();
Loading