Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change default behavior so action fails on medium (and higher) severities #86

Merged
merged 5 commits into from Mar 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/demo.yml
Expand Up @@ -11,6 +11,7 @@ jobs:
with:
image: "alpine:latest"
debug: true
fail-build: false

test-directory:
runs-on: ubuntu-latest
Expand All @@ -21,3 +22,4 @@ jobs:
path: "tests/python"
debug: true
severity-cutoff: "negligible"
fail-build: false
2 changes: 2 additions & 0 deletions .github/workflows/sarifdemo.yml
Expand Up @@ -16,6 +16,7 @@ jobs:
image: "debian:8"
debug: true
acs-report-enable: true
fail-build: false
#severity-cutoff: "Medium"

- name: Inspect Generated SARIF
Expand All @@ -41,6 +42,7 @@ jobs:
path: "tests/python"
debug: true
acs-report-enable: true
fail-build: false
#severity-cutoff: "Medium"

- name: Inspect Generated SARIF
Expand Down
12 changes: 7 additions & 5 deletions README.md
Expand Up @@ -36,7 +36,7 @@ Supported packages and libraries:

## Container scanning

The simplest workflow for scanning a `localbuild/testimage` container, that does not fail the build:
The simplest workflow for scanning a `localbuild/testimage` container:

```yaml
- name: Scan image
Expand All @@ -59,25 +59,27 @@ To scan a directory, add the following step:
The `path` key allows any valid path for the current project. The root of the path (`"."` in this example) is the repository root.

## Failing a build on vulnerability severity
To have the build step fail in cases where there are vulnerabilities with a specific severity level, then set the `fail-build` to `true`. By default, the severity level is `medium`, but this can be adjusted using the `severity-cutoff` field.
By default, if any vulnerability at `medium` or higher is seen, the build fails. To have the build step fail in cases where there are vulnerabilities with a severity level different than the default, set the `severity-cutoff` field to one of `low`, `high`, or `critical`:

With a different severity level:

```yaml
- name: Scan image
uses: anchore/scan-action@v2
with:
image: "localbuild/testimage:latest"
fail-build: true
severity-cutoff: critical
```

With a different severity level:
Optionally, change the `fail-build` field to `false` to avoid failing the build regardless of severity:

```yaml
- name: Scan image
uses: anchore/scan-action@v2
with:
image: "localbuild/testimage:latest"
fail-build: true
severity-cutoff: critical
fail-build: false
```


Expand Down
4 changes: 2 additions & 2 deletions action.yml
Expand Up @@ -15,9 +15,9 @@ inputs:
required: false
default: 'false'
fail-build:
description: 'Set to any value to cause build to fail upon failed anchore policy evaluation'
description: 'Set to false to avoid failing based on severity-cutoff. Default is to fail when severity-cutoff is reached (or surpassed)'
required: false
default: 'false'
default: 'true'
grype-version:
description: 'Optionally, specify the Grype version (e.g. 0.1.0) to use instead of the default version'
required: false
Expand Down
3 changes: 2 additions & 1 deletion tests/functional/test_images.py
Expand Up @@ -14,7 +14,8 @@ class TestSmoke:
# basic validation
def test_zero_exit_status(self, image_output):
lines = image_output.split()
assert lines[-1] == '0'
fail_context = '\n'.join(image_output.split('\n')[-20:])
assert lines[-1] == '0', fail_context

def test_found_vulnerabilities(self, image_output):
assert "Failed minimum severity level. Found vulnerabilities with level medium or higher" in image_output
3 changes: 3 additions & 0 deletions workflows/tests.yml
Expand Up @@ -14,6 +14,7 @@ jobs:
with:
image: "python:3.8"
debug: true
fail-build: false

no-sources:
runs-on: ubuntu-latest
Expand All @@ -25,6 +26,7 @@ jobs:
- uses: ./
with:
debug: true
fail-build: false

invalid-input:
runs-on: ubuntu-latest
Expand All @@ -38,6 +40,7 @@ jobs:
image: "python:3.8"
path: "/some/path"
debug: true
fail-build: false

# XXX Port these to get verified with tests
# image-fail-build:
Expand Down