Skip to content
This repository was archived by the owner on Oct 14, 2020. It is now read-only.

Commit 5067d9c

Browse files
committed
Change add-attribute hook to update-field hook
This allows chaning other fields, like the category, name, location of the findings, not just the attribute
1 parent ce7acdb commit 5067d9c

File tree

17 files changed

+4726
-12
lines changed

17 files changed

+4726
-12
lines changed

.github/workflows/ci.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,14 @@ jobs:
239239
repository: scbexperimental/test-read-write-hook
240240
path: ./hooks/test-read-write-hook/
241241
tag_with_ref: true
242+
- uses: docker/build-push-action@v1
243+
name: "Build & Push UpdateField Hook Image"
244+
with:
245+
username: ${{ secrets.DOCKER_USERNAME }}
246+
password: ${{ secrets.DOCKER_PASSWORD }}
247+
repository: scbexperimental/update-field
248+
path: ./hooks/update-field/
249+
tag_with_ref: true
242250
scannerImages:
243251
# Note we only build images for scanner that don't provider official public container images
244252
name: "Build / Scanner"

hooks/add-attributes/Dockerfile

Lines changed: 0 additions & 3 deletions
This file was deleted.

hooks/add-attributes/templates/NOTES.txt

Lines changed: 0 additions & 2 deletions
This file was deleted.
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
apiVersion: v2
2-
name: add-attributes-hook
3-
description: Lets you add new attributes to every finding
2+
name: update-field-hook
3+
description: Lets you add or override a field to every finding
44

55
type: application
66

hooks/update-field/Dockerfile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
FROM node:12-alpine as build
2+
RUN mkdir -p /home/app
3+
WORKDIR /home/app
4+
COPY package.json package-lock.json ./
5+
RUN npm ci --production
6+
7+
FROM scbexperimental/hook-sdk-nodejs:latest
8+
WORKDIR /home/app/hook-wrapper/hook/
9+
COPY --from=build --chown=app:app /home/app/node_modules/ ./node_modules/
10+
COPY --chown=app:app ./hook.js ./hook.js
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
const set = require("lodash.set");
2+
13
async function handle({
24
getFindings,
35
updateFindings,
@@ -7,7 +9,7 @@ async function handle({
79
const findings = await getFindings();
810

911
const newFindings = findings.map((finding) => {
10-
finding.attributes[attributeName] = attributeValue;
12+
set(finding, attributeName, attributeValue);
1113
return finding;
1214
});
1315

0 commit comments

Comments
 (0)