Skip to content

Commit

Permalink
v1.1.0 (#52)
Browse files Browse the repository at this point in the history
* test sbomgen v1.2.0-beta

* test Dockerfile with vulns

* Add Dockerfile vulnerabilities (#51)

* Add test image for rendering Dockerfile checks

* ignore .DS_Store (macOS)

* Added starter tests

* check if components and vulns are present

* Added Dockerfile vuln parser

* dockerfile finding markdown conversion

* refactor for cleanliness

* Remove mock secrets so I can push changes

* Updated test data

* testing for regression

* Integrated Dockerfile checks system-wide

* saving work

* added CSV and MD integration tests

---------

Co-authored-by: Michael Long <[email protected]>

* Add workflow to demo Dockerfile vulns

* Display Dockerfile scan results

* Output Dockerfile findings as CSV only (debugging)

* Change action url to this branch

* Fix CLI typo

* display sbomgen download url

* debugging

* debugging

* debugging

* debugging

* roll back debug logs

* roll back check() macro

* check() becomes require_true()

* fix typos in dockerfile inputs

* fix typo when posting dockerfile csv

* debugging set_github_actions_output()

* add header to Dockerfile MD report

* Update Dockerfile header

* update workflow metadata

* Add Dockerfile reports as download artifacts

* Rename Dockerfile report header

* Display Dockerfile findings in job terminal

* Set Dockerfile dst csv

* Debugging dockerfile reports in GHA terminal

* Debug Dockerfile output variables

* Test no vulns

* Remove 'cat <report>' commands

---------

Co-authored-by: Michael Long <[email protected]>
  • Loading branch information
bluesentinelsec and Michael Long authored Jun 4, 2024
1 parent 3820085 commit a18de02
Show file tree
Hide file tree
Showing 53 changed files with 177,682 additions and 35,826 deletions.
23 changes: 20 additions & 3 deletions .github/workflows/build_scan_container.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,20 +47,23 @@ jobs:
role-to-assume: ${{ secrets.AWS_IAM_ROLE }}

- name: Scan built image with Inspector
uses: aws-actions/vulnerability-scan-github-action-for-amazon-inspector@v1.0.0
uses: aws-actions/vulnerability-scan-github-action-for-amazon-inspector@test_sbomgen_1.2.0-beta
id: inspector
with:
artifact_type: 'container'
artifact_path: 'app:latest'
display_vulnerability_findings: "enabled"
output_sbom_path: 'sbom.json'
output_inspector_scan_path: 'inspector_scan.json'
output_inspector_scan_path_csv: 'inspector_scan.csv'
output_inspector_scan_path_csv: 'inspector_pkg_scan.csv'
output_inspector_dockerfile_scan_path_csv: 'inspector_dockerfile_scan.csv'
output_inspector_dockerfile_scan_path_markdown: 'inspector_dockerfile_scan.md'
critical_threshold: 1
high_threshold: 1
medium_threshold: 1
low_threshold: 1
other_threshold: 1
sbomgen_version: "1.2.0-beta"

- name: Demonstrate SBOM Output (JSON)
run: cat ${{ steps.inspector.outputs.artifact_sbom }}
Expand All @@ -71,14 +74,28 @@ jobs:
- name: Demonstrate Inspector Scan Output (CSV)
run: cat ${{ steps.inspector.outputs.inspector_scan_results_csv }}

- name: Display Dockerfile vulns (CSV)
run: cat inspector_dockerfile_scan.csv

- name: Display Dockerfile vulns (MD)
run: cat inspector_dockerfile_scan.md

- name: Debug Dockerfile output variables
run: |
echo ${{ steps.inspector.outputs.inspector_dockerile_scan_results_csv }}
echo ${{ steps.inspector.outputs.inspector_dockerile_scan_results_markdown }}
- name: Demonstrate Upload Scan Results
uses: actions/upload-artifact@v4
with:
name: Inspector Scan SBOM Results
path: |
${{ steps.inspector.outputs.artifact_sbom }}
${{ steps.inspector.outputs.inspector_scan_results }}
${{ steps.inspector.outputs.inspector_scan_results_csv }}
${{ steps.inspector.outputs.artifact_sbom }}
${{ steps.inspector.outputs.inspector_scan_results_markdown }}
${{ steps.inspector.outputs.inspector_dockerile_scan_results_csv }}
${{ steps.inspector.outputs.inspector_dockerile_scan_results_markdown }}
- name: On vulnerability threshold exceeded

Expand Down
1 change: 1 addition & 0 deletions .github/workflows/example_display_findings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ jobs:
medium_threshold: 1
low_threshold: 1
other_threshold: 1
sbomgen_version: "1.2.0-beta"

# Additional input arguments are available.
# See 'action.yml' for additional input/output options.
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/test_archive.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ jobs:
artifact_type: 'archive'
artifact_path: 'entrypoint/tests/test_data/artifacts/archives/testData.zip'
display_vulnerability_findings: "enabled"
sbomgen_version: "1.2.0-beta"

- name: Display scan results
run: cat ${{ steps.inspector.outputs.inspector_scan_results }}
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/test_binary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ jobs:
artifact_type: 'binary'
artifact_path: 'entrypoint/tests/test_data/artifacts/binaries/inspector-sbomgen'
display_vulnerability_findings: "enabled"
sbomgen_version: "1.2.0-beta"

- name: Display scan results
run: cat ${{ steps.inspector.outputs.inspector_scan_results }}
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/test_containers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ jobs:
artifact_type: 'container'
artifact_path: 'ubuntu:14.04'
display_vulnerability_findings: "enabled"
sbomgen_version: "1.2.0-beta"

- name: Display scan results
run: cat ${{ steps.inspector.outputs.inspector_scan_results }}
Expand Down
77 changes: 77 additions & 0 deletions .github/workflows/test_dockerfile_vulns.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
name: Test Dockerfile Vulnerabilities

# This workflow tests that the action can successfully
# scan a GitHub repository. This workflow runs automatically
# every 6 hours, and on pushes.

on:
schedule:
- cron: '0 */6 * * *' # runs every 6 hours
push:
branches: #
- '*'

jobs:
daily_job:
runs-on: ubuntu-latest
environment:
name: plugin-development

steps:
- name: Checkout this repository
uses: actions/checkout@v4

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-region: ${{ secrets.AWS_REGION }}
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
role-to-assume: ${{ secrets.AWS_IAM_ROLE }}

- name: Scan Dockerfiles
id: inspector
uses: aws-actions/vulnerability-scan-github-action-for-amazon-inspector@test_sbomgen_1.2.0-beta
with:
artifact_type: 'repository'
artifact_path: './'
display_vulnerability_findings: "enabled"
sbomgen_version: "1.2.0-beta"

- name: Display scan results (JSON)
run: cat ${{ steps.inspector.outputs.inspector_scan_results }}

- name: Display package vulns (CSV)
run: cat ${{ steps.inspector.outputs.inspector_scan_results_csv }}

- name: Display package vulns (MD)
run: cat ${{ steps.inspector.outputs.inspector_scan_results_markdown }}

- name: Display Dockerfile vulns (CSV)
run: cat ${{ steps.inspector.outputs.inspector_dockerfile_scan_results_csv }}

- name: Display Dockerfile vulns (MD)
run: cat ${{ steps.inspector.outputs.inspector_dockerfile_scan_results_markdown }}

- name: Validate scan content
run: python3 validator/validate_inspector_scan.py --file ${{ steps.inspector.outputs.inspector_scan_results }}

- name: Demonstrate Upload Scan Results
uses: actions/upload-artifact@v4
with:
name: Inspector Scan SBOM Results
path: |
${{ steps.inspector.outputs.artifact_sbom }}
${{ steps.inspector.outputs.inspector_scan_results }}
${{ steps.inspector.outputs.inspector_scan_results_csv }}
${{ steps.inspector.outputs.inspector_scan_results_markdown }}
${{ steps.inspector.outputs.inspector_dockerile_scan_results_csv }}
${{ steps.inspector.outputs.inspector_dockerile_scan_results_markdown }}
# only run if the previous step failed
- name: Notify maintainers of validation failure
if: ${{ failure() }}
run: echo "this feature is not implemented"
# TODO: add steps to send notification to a Lambda to cut a ticket on job failure

1 change: 1 addition & 0 deletions .github/workflows/test_installation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ jobs:
artifact_type: 'container'
artifact_path: 'alpine:latest'
display_vulnerability_findings: "enabled"
sbomgen_version: "1.2.0-beta"

# only run if the previous step failed
- name: Notify maintainers of installation failure
Expand Down
54 changes: 54 additions & 0 deletions .github/workflows/test_no_vulns.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Test No Vulns

# confirm that reports are not displayed when no vulns are found

on:
push:
branches: #
- '*'

jobs:
daily_job:
runs-on: ubuntu-latest
environment:
name: plugin-development

steps:

- name: Checkout
uses: actions/checkout@v4

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-region: ${{ secrets.AWS_REGION }}
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
role-to-assume: ${{ secrets.AWS_IAM_ROLE }}

- name: Test binary scan
id: inspector
uses: aws-actions/vulnerability-scan-github-action-for-amazon-inspector@test_sbomgen_1.2.0-beta
with:
artifact_type: 'binary'
artifact_path: 'entrypoint/tests/test_data/artifacts/binaries/test_go_binary'
display_vulnerability_findings: "enabled"
output_sbom_path: 'sbom.json'
output_inspector_scan_path: 'inspector_scan.json'
output_inspector_scan_path_csv: 'inspector_pkg_scan.csv'
output_inspector_dockerfile_scan_path_csv: 'inspector_dockerfile_scan.csv'
output_inspector_dockerfile_scan_path_markdown: 'inspector_dockerfile_scan.md'
sbomgen_version: "1.2.0-beta"

- name: Demonstrate Upload Scan Results
uses: actions/upload-artifact@v4
with:
name: Inspector Scan SBOM Results
path: |
${{ steps.inspector.outputs.artifact_sbom }}
${{ steps.inspector.outputs.inspector_scan_results }}
${{ steps.inspector.outputs.inspector_scan_results_csv }}
${{ steps.inspector.outputs.inspector_scan_results_markdown }}
${{ steps.inspector.outputs.inspector_dockerile_scan_results_csv }}
${{ steps.inspector.outputs.inspector_dockerile_scan_results_markdown }}
1 change: 1 addition & 0 deletions .github/workflows/test_repository.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ jobs:
artifact_type: 'repository'
artifact_path: './'
display_vulnerability_findings: "enabled"
sbomgen_version: "1.2.0-beta"

- name: Display scan results
run: cat ${{ steps.inspector.outputs.inspector_scan_results }}
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/test_vuln_thresholds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ jobs:
medium_threshold: 1
low_threshold: 1
other_threshold: 1
sbomgen_version: "1.2.0-beta"

- name: Fail if vulnerability threshold is exceeded
run: if [[ ${{ steps.inspector.outputs.vulnerability_threshold_exceeded }} != "1" ]]; then echo "test failed"; else echo "test passed"; fi
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ plan.txt
__pycache__
scripts/entrypoint/test_data
.coverage
.DS_Store
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ This action can scan the following artifact types for vulnerabilities:

For more information, please refer to Amazon Inspector's supported [artifacts](https://docs.aws.amazon.com/inspector/latest/user/sbom-generator.html) and [container operating systems](https://docs.aws.amazon.com/inspector/latest/user/supported.html#supported-os-ecr).

To learn more about Amazon Inspector, as well as Inspector's free trial and pricing model, please see the links below:

1. https://aws.amazon.com/inspector/
2. https://aws.amazon.com/inspector/pricing/?nc=sn&loc=3


## Prerequisites

1. **Required:** You must have an active AWS account to use this action. Guidance on creating an AWS account is
Expand Down
19 changes: 19 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,16 @@ inputs:
required: False
default: 'inspector_scan_${{ github.run_id }}.md'

output_inspector_dockerfile_scan_path_csv:
description: "The destination file path for Inspector's Dockerfile vulnerability scan (CSV format)."
required: False
default: 'inspector_dockerfile_scan_${{ github.run_id }}.csv'

output_inspector_dockerfile_scan_path_markdown:
description: "The destination file path for Inspector's Dockerfile vulnerability scan (markdown format)."
required: False
default: 'inspector_dockerfile_scan_${{ github.run_id }}.md'

sbomgen_version:
description: "The inspector-sbomgen version you wish to use for SBOM generation. See here for more info: https://docs.aws.amazon.com/inspector/latest/user/sbom-generator.html"
required: False
Expand Down Expand Up @@ -109,6 +119,13 @@ outputs:
inspector_scan_results_markdown:
description: "The file path to the Inspector vulnerability scan findings in markdown format."

inspector_dockerile_scan_results_csv:
description: "The file path to the Inspector Dockerfile vulnerability scan findings in CSV format."

inspector_dockerile_scan_results_markdown:
description: "The file path to the Inspector Dockerfile vulnerability scan findings in markdown format."


vulnerability_threshold_exceeded:
description: "This variable is set to 1 if any vulnerability threshold was exceeded, otherwise it is 0. This variable can be used to trigger custom logic, such as failing the job if vulnerabilities were detected."

Expand All @@ -123,6 +140,8 @@ runs:
- --out-scan=${{ inputs.output_inspector_scan_path }}
- --out-scan-csv=${{ inputs.output_inspector_scan_path_csv }}
- --out-scan-markdown=${{ inputs.output_inspector_scan_path_markdown }}
- --out-dockerfile-scan-csv=${{ inputs.output_inspector_dockerfile_scan_path_csv }}
- --out-dockerfile-scan-md=${{ inputs.output_inspector_dockerfile_scan_path_markdown }}
- --sbomgen-version=${{ inputs.sbomgen_version }}
- --thresholds
- --critical=${{ inputs.critical_threshold }}
Expand Down
4 changes: 4 additions & 0 deletions entrypoint/entrypoint/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ def init(sys_argv=None) -> argparse.Namespace:
help="The destination file path for Inspector's vulnerability scan in CSV format.")
parser.add_argument("--out-scan-markdown", type=str, default="inspector-scan.md",
help="The destination file path for Inspector's vulnerability scan results in markdown format.")
parser.add_argument("--out-dockerfile-scan-csv", type=str, default="inspector-dockerfile-scan.csv",
help="The destination file path for Inspector's Dockerfile vulnerability scan in CSV format.")
parser.add_argument("--out-dockerfile-scan-md", type=str, default="inspector-dockerfile-scan.md",
help="The destination file path for Inspector's Dockerfile vulnerability scan in markdown format.")
parser.add_argument("--verbose", action="store_true", help="Enables verbose console logging.")
parser.add_argument("--sbomgen-version", type=str, default="latest",
help="The inspector-sbomgen version you wish to use for SBOM generation.")
Expand Down
Loading

0 comments on commit a18de02

Please sign in to comment.