Skip to content

Commit 9735600

Browse files
committed
Adding zap full scan github action
1 parent 5842e3f commit 9735600

File tree

5 files changed

+6195
-1
lines changed

5 files changed

+6195
-1
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ typings/
8080

8181
# Nuxt.js build / generate output
8282
.nuxt
83-
dist
8483

8584
# Gatsby files
8685
.cache/

action.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: 'OWASP ZAP Full Scan'
2+
description: 'Scans the web application with the OWASP ZAP Baseline Scan'
3+
branding:
4+
icon: 'zap'
5+
color: 'blue'
6+
inputs:
7+
token:
8+
description: 'GitHub Token to create issues in the repository'
9+
required: true
10+
target:
11+
description: 'Target URL'
12+
required: true
13+
rules_file_name:
14+
description: 'Relative path of the ZAP configuration file'
15+
required: false
16+
docker_name:
17+
description: 'The Docker file to be executed'
18+
required: true
19+
default: 'owasp/zap2docker-stable'
20+
cmd_options:
21+
description: 'Additional command line options'
22+
required: false
23+
issue_title:
24+
description: 'The title for the GitHub issue that is created'
25+
required: false
26+
default: 'ZAP Scan Baseline Report'
27+
runs:
28+
using: 'node12'
29+
main: 'dist/index.js'

index.js

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
const core = require('@actions/core');
2+
const exec = require('@actions/exec');
3+
const common = require('actions-common-scans');
4+
const _ = require('lodash');
5+
6+
// Default file names
7+
let jsonReportName = 'report_json.json';
8+
let mdReportName = 'report_md.md';
9+
let htmlReportName = 'report_html.html';
10+
11+
async function run() {
12+
13+
try {
14+
let workspace = process.env.GITHUB_WORKSPACE;
15+
let currentRunnerID = process.env.GITHUB_RUN_ID;
16+
let repoName = process.env.GITHUB_REPOSITORY;
17+
let token = core.getInput('token');
18+
let docker_name = core.getInput('docker_name');
19+
let target = core.getInput('target');
20+
let rulesFileLocation = core.getInput('rules_file_name');
21+
let cmdOptions = core.getInput('cmd_options');
22+
let issueTitle = core.getInput('issue_title');
23+
24+
console.log('starting the program');
25+
console.log('github run id :' + currentRunnerID);
26+
27+
let plugins = [];
28+
if (rulesFileLocation) {
29+
plugins = await common.helper.processLineByLine(`${workspace}/${rulesFileLocation}`);
30+
}
31+
32+
let command = (`docker run --user root -v ${workspace}:/zap/wrk/:rw --network="host" ` +
33+
`-t ${docker_name} zap-full-scan.py -t ${target} -J ${jsonReportName} -w ${mdReportName} -r ${htmlReportName} ${cmdOptions}`);
34+
35+
if (plugins.length !== 0) {
36+
command = command + ` -c ${rulesFileLocation}`
37+
}
38+
39+
try {
40+
await exec.exec(command);
41+
} catch (err) {
42+
core.setFailed('The ZAP Baseline scan has failed, starting to analyze the alerts. err: ' + err.toString());
43+
}
44+
await common.main.processReport(token, workspace, plugins, currentRunnerID, issueTitle, repoName);
45+
} catch (error) {
46+
core.setFailed(error.message);
47+
}
48+
}
49+
50+
run();

0 commit comments

Comments
 (0)