Skip to content
This repository has been archived by the owner on Jun 29, 2021. It is now read-only.

Commit

Permalink
Merge pull request #2 from wochinge/fail-on-vulnerabilities
Browse files Browse the repository at this point in the history
add option to fail if vulnerability was found
  • Loading branch information
wochinge committed Apr 28, 2020
2 parents e55a8e7 + ad34351 commit 6bf026b
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ If vulnerabilities are found by Trivy, it creates the following GitHub Issue.
|issue_title|False|Security Alert|Issue title|
|issue_label|False|trivy,vulnerability|Issue label (separated by commma)|
|issue_assignee|False|N/A|Issue assignee (separated by commma)|
|fail_on_vulnerabilities|False|false|Whether the action should fail if any vulnerabilities were found.|

### Outputs

Expand Down
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ inputs:
issue_assignee:
description: 'Issue assignee (separated by commma)'
required: false
fail_on_vulnerabilities:
description: Whether the action should fail if a vulnerability was found
default: 'false'
required: false

outputs:
issue_number:
Expand Down
3 changes: 3 additions & 0 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6593,6 +6593,9 @@ function run() {
const output = yield issue_1.createOrUpdateIssue(token, image, issueOption);
core.setOutput('html_url', output.htmlUrl);
core.setOutput('issue_number', output.issueNumber.toString());
if (core.getInput("fail_on_vulnerabilities") === 'true') {
core.setFailed(`Vulnerabilities found.\n${issueContent}`);
}
}
catch (error) {
core.error(error.stack);
Expand Down
4 changes: 4 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ async function run() {
const output: IssueResponse = await createOrUpdateIssue(token, image, issueOption);
core.setOutput('html_url', output.htmlUrl);
core.setOutput('issue_number', output.issueNumber.toString());

if (core.getInput("fail_on_vulnerabilities") === 'true') {
core.setFailed(`Vulnerabilities found.\n${issueContent}`)
}
} catch (error) {
core.error(error.stack);
core.setFailed(error.message);
Expand Down

0 comments on commit 6bf026b

Please sign in to comment.