Skip to content

Commit d38a0fc

Browse files
authored
Merge pull request #1 from sshniro/full
Adding zap full scan github action
2 parents 5842e3f + 96a2da9 commit d38a0fc

File tree

6 files changed

+6287
-3
lines changed

6 files changed

+6287
-3
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/

README.md

Lines changed: 91 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,91 @@
1-
# action-full-scan
2-
A GitHub Action for running the OWASP ZAP Full scan
1+
# ZAP Action Full Scan
2+
3+
A GitHub Action for running the OWASP ZAP [Full Scan](https://www.zaproxy.org/docs/docker/full-scan/) to perform
4+
Dynamic Application Security Testing (DAST).
5+
6+
The ZAP full scan action runs the ZAP spider against the specified target (by default with no time limit) followed by an
7+
optional ajax spider scan and then a full active scan before reporting the results. The alerts will be maintained as a
8+
GitHub issue in the corresponding repository.
9+
10+
## Inputs
11+
12+
### `target`
13+
14+
**Required** The URL of the web application to be scanned. This can be either a publicly available web application or a locally
15+
accessible URL.
16+
17+
### `docker_name`
18+
19+
**Optional** The name of the docker file to be executed. By default the action runs the stable version of ZAP. But you can
20+
configure the parameter to use the weekly builds.
21+
22+
### `rules_file_name`
23+
24+
**Optional** You can also specify a relative path to the rules file to ignore any alerts from the ZAP scan. Make sure to create
25+
the rules file inside the relevant repository. The following shows a sample rules file configuration.
26+
Make sure to checkout the repository (actions/checkout@v2) to provide the ZAP rules to the scan action.
27+
28+
```tsv
29+
10011 IGNORE (Cookie Without Secure Flag)
30+
10015 IGNORE (Incomplete or No Cache-control and Pragma HTTP Header Set)
31+
```
32+
33+
### `cmd_options`
34+
35+
**Optional** Additional command lines options for the full scan script
36+
37+
### `issue_title`
38+
39+
**Optional** The title for the GitHub issue to be created.
40+
41+
### `token`
42+
43+
**Optional** ZAP action uses the default action token provided by GitHub to create and update the issue for the full scan.
44+
You do not have to create a dedicated token. Make sure to use the GitHub's default action token when running the action(`secrets.GIT_TOKEN`).
45+
46+
## Example usage
47+
48+
** Basic **
49+
```
50+
steps:
51+
- name: ZAP Scan
52+
uses: zaproxy/action-full-scan@v0.1.0
53+
with:
54+
target: 'https://www.zaproxy.org/'
55+
```
56+
57+
** Advanced **
58+
59+
```
60+
on: [push]
61+
62+
jobs:
63+
zap_scan:
64+
runs-on: ubuntu-latest
65+
name: Scan the webapplication
66+
steps:
67+
- name: Checkout
68+
uses: actions/checkout@v2
69+
with:
70+
ref: master
71+
- name: ZAP Scan
72+
uses: zaproxy/action-full-scan@v0.1.0
73+
with:
74+
token: ${{ secrets.GITHUB_TOKEN }}
75+
docker_name: 'owasp/zap2docker-stable'
76+
target: 'https://www.zaproxy.org/'
77+
rules_file_name: '.zap/rules.tsv'
78+
cmd_options: '-a'
79+
```
80+
81+
## Localised Alert Details
82+
83+
ZAP is internationalised and alert information is available in many languages.
84+
85+
You can change the language used by this action by changing the locale via the `cmd_options` e.g.: `-z "-config view.locale=fr_FR"`
86+
87+
This is currently only available with the `owasp/zap2docker-weekly` or `owasp/zap2docker-live` Docker images.
88+
89+
See [https://github.com/zaproxy/zaproxy/tree/develop/zap/src/main/dist/lang](https://github.com/zaproxy/zaproxy/tree/develop/zap/src/main/dist/lang) for the full set of locales currently supported.
90+
91+
You can help improve ZAP translations via [https://crowdin.com/project/owasp-zap](https://crowdin.com/project/owasp-zap).

action.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: 'OWASP ZAP Full Scan'
2+
description: 'Scans the web application with the OWASP ZAP Full 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: false
10+
default: ${{ github.token }}
11+
target:
12+
description: 'Target URL'
13+
required: true
14+
rules_file_name:
15+
description: 'Relative path of the ZAP configuration file'
16+
required: false
17+
docker_name:
18+
description: 'The Docker file to be executed'
19+
required: true
20+
default: 'owasp/zap2docker-stable'
21+
cmd_options:
22+
description: 'Additional command line options'
23+
required: false
24+
issue_title:
25+
description: 'The title for the GitHub issue to be created'
26+
required: false
27+
default: 'ZAP Full Scan Report'
28+
runs:
29+
using: 'node12'
30+
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('@zaproxy/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 full 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)