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

Commit ad34351

Browse files
committed
add option to fail if vulnerability was found
1 parent e55a8e7 commit ad34351

File tree

4 files changed

+12
-0
lines changed

4 files changed

+12
-0
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ If vulnerabilities are found by Trivy, it creates the following GitHub Issue.
2424
|issue_title|False|Security Alert|Issue title|
2525
|issue_label|False|trivy,vulnerability|Issue label (separated by commma)|
2626
|issue_assignee|False|N/A|Issue assignee (separated by commma)|
27+
|fail_on_vulnerabilities|False|false|Whether the action should fail if any vulnerabilities were found.|
2728

2829
### Outputs
2930

action.yml

+4
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ inputs:
3939
issue_assignee:
4040
description: 'Issue assignee (separated by commma)'
4141
required: false
42+
fail_on_vulnerabilities:
43+
description: Whether the action should fail if a vulnerability was found
44+
default: 'false'
45+
required: false
4246

4347
outputs:
4448
issue_number:

dist/index.js

+3
Original file line numberDiff line numberDiff line change
@@ -6593,6 +6593,9 @@ function run() {
65936593
const output = yield issue_1.createOrUpdateIssue(token, image, issueOption);
65946594
core.setOutput('html_url', output.htmlUrl);
65956595
core.setOutput('issue_number', output.issueNumber.toString());
6596+
if (core.getInput("fail_on_vulnerabilities") === 'true') {
6597+
core.setFailed(`Vulnerabilities found.\n${issueContent}`);
6598+
}
65966599
}
65976600
catch (error) {
65986601
core.error(error.stack);

src/index.ts

+4
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@ async function run() {
7272
const output: IssueResponse = await createOrUpdateIssue(token, image, issueOption);
7373
core.setOutput('html_url', output.htmlUrl);
7474
core.setOutput('issue_number', output.issueNumber.toString());
75+
76+
if (core.getInput("fail_on_vulnerabilities") === 'true') {
77+
core.setFailed(`Vulnerabilities found.\n${issueContent}`)
78+
}
7579
} catch (error) {
7680
core.error(error.stack);
7781
core.setFailed(error.message);

0 commit comments

Comments
 (0)