Skip to content

Commit de17435

Browse files
authored
Merge pull request #73 from camelmasa/artifact-name
Add artifact name as input
2 parents 42ff17e + 69970e2 commit de17435

File tree

5 files changed

+25
-2
lines changed

5 files changed

+25
-2
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
77
### Fixed
88
- Update Crowdin link.
99

10+
### Added
11+
- An input (`artifact_name`) used to name the artifact that contains the ZAP reports. [#73](https://github.com/zaproxy/action-full-scan/pull/73)
12+
1013
## [0.6.0] - 2023-08-02
1114
### Changed
1215
- The default Docker image was changed to `ghcr.io/zaproxy/zaproxy:stable`.

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@ You do not have to create a dedicated token. Make sure to use the GitHub's defau
5858
**Optional** By default ZAP Docker container will fail with an [exit code](https://github.com/zaproxy/zaproxy/blob/efb404d38280dc9ecf8f88c9b0c658385861bdcf/docker/zap-full-scan.py#L31),
5959
if it identifies any alerts. Set this option to `true` if you want to fail the status of the GitHub Scan if ZAP identifies any alerts during the scan.
6060

61+
### `artifact_name`
62+
63+
**Optional** By default the full scan action will attach the report to the build with the name `zap_scan`. Set this to a different string to name it something else. Consult [GitHub's documentation](https://github.com/actions/toolkit/blob/main/packages/artifact/docs/additional-information.md#non-supported-characters) for which artifact names are allowed.
64+
6165
## Example usage
6266

6367
** Basic **

action.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ inputs:
3333
description: 'Whether Github issues should be created or not'
3434
required: false
3535
default: true
36+
artifact_name:
37+
description: 'The name of the artifact that contains the ZAP reports'
38+
required: false
39+
default: 'zap_scan'
3640
runs:
3741
using: 'node16'
3842
main: 'dist/index.js'

dist/index.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38341,6 +38341,7 @@ async function run() {
3834138341
let issueTitle = core.getInput('issue_title');
3834238342
let failAction = core.getInput('fail_action');
3834338343
let allowIssueWriting = core.getInput('allow_issue_writing');
38344+
let artifactName = core.getInput('artifact_name');
3834438345
let createIssue = true;
3834538346

3834638347
if (!(String(failAction).toLowerCase() === 'true' || String(failAction).toLowerCase() === 'false')) {
@@ -38350,6 +38351,11 @@ async function run() {
3835038351
createIssue = false;
3835138352
}
3835238353

38354+
if (!artifactName) {
38355+
console.log('[WARNING]: \'artifact_name\' action input should not be empty. Setting it back to the default name.');
38356+
artifactName = 'zap_scan';
38357+
}
38358+
3835338359
console.log('starting the program');
3835438360
console.log('github run id :' + currentRunnerID);
3835538361

@@ -38386,7 +38392,7 @@ async function run() {
3838638392
console.log('Scanning process completed, starting to analyze the results!')
3838738393
}
3838838394
}
38389-
await common.main.processReport(token, workspace, plugins, currentRunnerID, issueTitle, repoName, createIssue);
38395+
await common.main.processReport(token, workspace, plugins, currentRunnerID, issueTitle, repoName, createIssue, artifactName);
3839038396
} catch (error) {
3839138397
core.setFailed(error.message);
3839238398
}

index.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ async function run() {
2222
let issueTitle = core.getInput('issue_title');
2323
let failAction = core.getInput('fail_action');
2424
let allowIssueWriting = core.getInput('allow_issue_writing');
25+
let artifactName = core.getInput('artifact_name');
2526
let createIssue = true;
2627

2728
if (!(String(failAction).toLowerCase() === 'true' || String(failAction).toLowerCase() === 'false')) {
@@ -31,6 +32,11 @@ async function run() {
3132
createIssue = false;
3233
}
3334

35+
if (!artifactName) {
36+
console.log('[WARNING]: \'artifact_name\' action input should not be empty. Setting it back to the default name.');
37+
artifactName = 'zap_scan';
38+
}
39+
3440
console.log('starting the program');
3541
console.log('github run id :' + currentRunnerID);
3642

@@ -67,7 +73,7 @@ async function run() {
6773
console.log('Scanning process completed, starting to analyze the results!')
6874
}
6975
}
70-
await common.main.processReport(token, workspace, plugins, currentRunnerID, issueTitle, repoName, createIssue);
76+
await common.main.processReport(token, workspace, plugins, currentRunnerID, issueTitle, repoName, createIssue, artifactName);
7177
} catch (error) {
7278
core.setFailed(error.message);
7379
}

0 commit comments

Comments
 (0)