Skip to content

Commit e46d127

Browse files
authored
Add ability to enable --fail-on-vulnerabilities for check-compliance (#16)
Signed-off-by: tdruez <[email protected]>
1 parent 8d3c269 commit e46d127

File tree

3 files changed

+47
-7
lines changed

3 files changed

+47
-7
lines changed

.github/workflows/find-vulnerabilities.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,8 @@ jobs:
1717
- uses: ./
1818
with:
1919
pipelines: "scan_codebase,find_vulnerabilities"
20+
scancodeio-repo-branch: "main"
21+
check-compliance: true
22+
compliance-fail-on-vulnerabilities: true
2023
env:
2124
VULNERABLECODE_URL: https://public.vulnerablecode.io/

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,11 @@ steps:
7777
# Failure level for compliance check. Options: ERROR, WARNING, MISSING.
7878
# Default is 'ERROR'
7979
compliance-fail-level:
80+
81+
# Exit with a non-zero status if known vulnerabilities are detected in discovered
82+
# packages and dependencies.
83+
# Default is false
84+
compliance-fail-on-vulnerabilities:
8085

8186
# Python version that will be installed to run ScanCode.io
8287
# Default is '3.12'
@@ -128,6 +133,23 @@ However, you also have the option to run your own VulnerableCode instance.
128133
For details on setting up and configuring your own instance, please refer to the
129134
[VulnerableCode documentation](https://vulnerablecode.readthedocs.io/en/latest/index.html).
130135

136+
#### Fail on known vulnerabilities
137+
138+
When enabled, the workflow will fail if any known vulnerabilities are found in the
139+
project's discovered packages or dependencies.
140+
Activate this behavior by enabling `check-compliance` and setting
141+
`compliance-fail-on-vulnerabilities` to true.
142+
143+
```yaml
144+
- uses: aboutcode-org/scancode-action@beta
145+
with:
146+
pipelines: "scan_codebase,find_vulnerabilities"
147+
check-compliance: true
148+
compliance-fail-on-vulnerabilities: true
149+
env:
150+
VULNERABLECODE_URL: https://public.vulnerablecode.io/
151+
```
152+
131153
### Choose the output formats
132154

133155
```yaml

action.yml

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,18 @@ inputs:
2424
description: |
2525
Check for compliance issues in the project.
2626
Exits with a non-zero status if compliance issues are detected.
27+
required: false
28+
default: "false"
2729
compliance-fail-level:
2830
description: "Failure level for compliance check. Options: ERROR, WARNING, MISSING."
31+
required: false
2932
default: "ERROR"
33+
compliance-fail-on-vulnerabilities:
34+
description: |
35+
Exit with a non-zero status if known vulnerabilities are detected in discovered
36+
packages and dependencies.
3037
required: false
38+
default: "false"
3139
python-version:
3240
description: "Python version."
3341
default: "3.12"
@@ -127,16 +135,23 @@ runs:
127135
--project ${{ inputs.project-name }}
128136
--format ${{ inputs.output-formats }}
129137

130-
- name: Check compliance
131-
if: inputs.check-compliance == 'true'
132-
shell: bash
133-
run: scanpipe check-compliance
134-
--project ${{ inputs.project-name }}
135-
--fail-level ${{ inputs.compliance-fail-level }}
136-
137138
- name: Upload outputs
138139
uses: actions/upload-artifact@v4
139140
id: artifact-upload-step
140141
with:
141142
name: ${{ inputs.outputs-archive-name }}
142143
path: ${{ env.PROJECT_WORK_DIRECTORY }}/output/*
144+
145+
- name: Check compliance
146+
if: inputs.check-compliance == 'true'
147+
shell: bash
148+
run: |
149+
cmd="scanpipe check-compliance \
150+
--project ${{ inputs.project-name }} \
151+
--fail-level ${{ inputs.compliance-fail-level }}"
152+
153+
if [[ "${{ inputs.compliance-fail-on-vulnerabilities }}" == "true" ]]; then
154+
cmd="$cmd --fail-on-vulnerabilities"
155+
fi
156+
157+
eval "$cmd"

0 commit comments

Comments
 (0)