A GitHub Action to scan container images in Amazon ECR for security vulnerabilities. This action provides a way to retrieve ECR automatic scans with direct feedback in a PR, failing builds if serious security issues are detected.
- π‘οΈ Retrieves ECR image scans, checking for security vulnerabilities
- π Provides detailed vulnerability reports
- π« Configurable failure thresholds
- βοΈ Ability to ignore specific vulnerabilities
- π¬ Automatic PR comments with findings
- π¨ Rich console output with formatted tables
- uses: vonsteer/ecr-scanning-action@v1
with:
repository: myorg/myimage # ECR repository name
tag: latest # Image tag to scan
fail_threshold: high # Optional: Severity level that will cause failure (default: high)
ignore_list: CVE-2023-1234 CVE-2023-5678 # Optional: CVEs to ignore
region: us-east-2 # Optional: AWS region (default: us-east-2)
pr_comment: true # Optional: Post results as PR comment (default: true)
max_retries: 10 # Optional: Maximum number of retries for API calls (default: 10)
retry_delay: 5 # Optional: Delay between retries in seconds (default: 5)
Input | Description | Required | Default |
---|---|---|---|
repository |
ECR repository name | Yes | - |
tag |
Image tag to scan | Yes | - |
fail_threshold |
Severity level that will cause failure | No | critical |
ignore_list |
List of CVE IDs to ignore | No | - |
region |
AWS region | No | us-east-2 |
pr_comment |
Post results as PR comment | No | true |
max_retries |
Maximum number of retries for API calls | No | 10 |
retry_delay |
Delay between retries (in seconds) | No | 5 |
Available threshold levels (from highest to lowest):
critical
high
medium
low
informational
none
Output | Description |
---|---|
critical |
Number of critical vulnerabilities |
high |
Number of high vulnerabilities |
medium |
Number of medium vulnerabilities |
low |
Number of low vulnerabilities |
informational |
Number of informational findings |
undefined |
Number of undefined severity findings |
total |
Total number of findings |
detailed_findings |
JSON object with detailed scan results |
name: Security Scan
on:
pull_request:
branches: [ main ]
jobs:
scan:
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
pull-requests: write # Required for PR comments
steps:
- uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::123456789012:role/github-actions
aws-region: us-east-2
- uses: vonsteer/ecr-scanning-action@v1
with:
repository: myorg/myimage
tag: latest
fail_threshold: high
ignore_list: CVE-2023-1234 CVE-2023-5678
The action requires the following AWS IAM permissions:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"ecr:DescribeImageScanFindings",
"ecr:DescribeImages",
"ecr:BatchGetImage"
],
"Resource": "arn:aws:ecr:*:*:repository/*"
}
]
}
Name | Severity | Package | Version | Description |
---|---|---|---|---|
CVE-2023-1235 | CRITICAL | package1 | 1.0.0 | This finding should be ignored |
π Build Succeeded: No vulnerabilities were detected.
Severity | Count | |
---|---|---|
CRITICAL | 1 | |
π΄ | HIGH | 0 |
π‘ | MEDIUM | 0 |
π’ | LOW | 0 |
π΅ | INFORMATIONAL | 0 |
β | UNDEFINED | 0 |
Name | Severity | Package | Version | Description |
---|---|---|---|---|
CVE-2023-1234 | CRITICAL | vulnerable-package | 1.0.0 | Critical vulnerability |
Name | Severity | Package | Version | Description |
---|---|---|---|---|
CVE-2023-1235 | CRITICAL | package1 | 1.0.0 | This finding should be ignored |
You can also use the scanner locally:
# Install the package
uv pip install .
# Run the scanner
ecr-scan myorg/myimage latest --fail-threshold high --ignore-list CVE-2023-1234
This project includes a comprehensive testing strategy with unit tests and integration tests:
Unit tests use the botocore stubber to mock AWS API interactions:
# Run all tests
make test
A GitHub workflow (action-integration-test.yml
) tests the action with actual AWS resources:
- Pushes a test image to ECR
- Runs the scanning action against the image
- Tests both success and failure scenarios
- Tests the CVE ignore list functionality
This ensures the action works correctly in real-world scenarios.
A basic smoke test ensures the package can be imported and executed:
# Run the smoke test
python tests/smoke_test.py