The Security Scan workflow performs comprehensive security vulnerability scanning on Docker packages in your repository. It supports both manual triggering via workflow_dispatch and automatic scheduled runs. The workflow can scan all Docker images in your GitHub Container Registry (GHCR) or a specific image, using multiple security scanning tools (Trivy and Grype) to identify vulnerabilities.
This workflow can be triggered in two ways:
-
Manual trigger: Via
workflow_dispatchwith configurable parameters- Allows scanning specific images or all images
- Customizable severity levels, scanners, and error handling
- Full control over scan parameters
-
Scheduled trigger: Automatically runs every Sunday at 03:00 UTC
- Uses default parameter values
- Scans all Docker images in the repository
- Ideal for regular security checks
- Runner:
ubuntu-latest - Purpose: Discovers and lists all Docker packages in GHCR for the repository
- Permissions:
packages: read - Uses:
Netcracker/qubership-workflow-hub/actions/ghcr-discover-repo-packages@v2.0.5 - Outputs:
packages: JSON array of discovered packageshas-packages: Boolean indicating if packages were found
-
List GHCR packages for this repository
- Uses the ghcr-discover-repo-packages action
- Discovers all Docker images available in GHCR
- Sets output packages as JSON array
-
Print packages
- Displays discovered packages in JSON format
- Useful for debugging and visibility
-
Continue only if repository has GHCR packages
- Validates that at least one package was found
- Proceeds if packages exist
-
No packages found, fail the job
- Fails the workflow if no GHCR packages are discovered
- Prevents invalid scan attempts
- Runner:
ubuntu-latest(via reusable workflow) - Purpose: Runs security scans on all discovered Docker packages in parallel
- Dependencies: Requires
debug-packagesjob - Condition: Only runs if no specific image is provided (
inputs.image == '' || inputs.image == null) - Strategy: Matrix strategy iterates through all discovered packages
- Uses:
netcracker/qubership-workflow-hub/.github/workflows/re-security-scan.yml@v2.0.5
- Runner:
ubuntu-latest(via reusable workflow) - Purpose: Runs security scan on a specific Docker image
- Dependencies: Requires
debug-packagesjob - Condition: Only runs if a specific image is provided (
inputs.image != '' && inputs.image != null) - Uses:
netcracker/qubership-workflow-hub/.github/workflows/re-security-scan.yml@v2.0.5
The workflow uses conditional logic to choose between two scanning modes:
- Matrix Mode: Automatically scans all discovered Docker images when no specific image is provided
- Single Image Mode: Scans a specific image when the
imageparameter is provided
target(choice, optional): Target type for the scan- Options:
docker,source - Default:
docker
- Options:
image(string, optional): Docker image to scan- Format:
ghcr.io/<owner>/<repository>:tag - Default: Empty (scans all repository images)
- Format:
tag(string, optional): Tag of the image to scan- Default:
latest
- Default:
only-high-critical(boolean, optional): Scope only HIGH and CRITICAL severity vulnerabilities- Default:
true
- Default:
trivy-scan(boolean, optional): Enable Trivy vulnerability scanner- Default:
true
- Default:
grype-scan(boolean, optional): Enable Grype vulnerability scanner- Default:
true
- Default:
continue-on-error(boolean, optional): Continue workflow execution even if scan detects vulnerabilities- Default:
true
- Default:
only-fixed(boolean, optional): Ignore unfixed vulnerabilities in scan results- Default:
true
- Default:
packages: read- For reading Docker packages from GHCR
GH_TOKEN: GitHub access token (usessecrets.GH_ACCESS_TOKEN)
- Runs automatically every Sunday at 03:00 UTC
- Trigger the workflow manually from GitHub Actions
- Leave all parameters at default values
- Leave
imageparameter empty - Workflow will:
- Discover all Docker images in GHCR
- Scan each image in parallel using matrix strategy
- Use Trivy and Grype scanners
- Report only HIGH and CRITICAL vulnerabilities
- Ignore unfixed vulnerabilities
- Trigger the workflow manually from GitHub Actions
- Provide the
imageparameter (e.g.,ghcr.io/netcracker/myrepo/myimage) - Optionally customize other parameters:
tag: Specify image tag (default:latest)trivy-scan: Enable/disable Trivygrype-scan: Enable/disable Grype
- Workflow will scan only the specified image with your configurations
- Trigger the workflow manually
- Set
only-high-criticaltofalseto include all severity levels - Set
only-fixedtofalseto include unfixed vulnerabilities - Workflow will report all detected vulnerabilities
- Trigger the workflow manually
- Set
continue-on-errortofalse - If vulnerabilities matching the criteria are found, workflow will fail
- Useful for blocking deployments with security issues
- Workflow automatically runs every Sunday at 03:00 UTC
- Scans all Docker images with default parameters
- No manual intervention required
- Results available in GitHub Actions history
- Multi-scanner support: Uses both Trivy and Grype for comprehensive coverage
- Automatic discovery: Finds all Docker images in repository GHCR
- Batch scanning: Scans multiple images in parallel using matrix strategy
- Specific image scanning: Optionally scan individual images
- Severity filtering: Filter by HIGH/CRITICAL or view all vulnerabilities
- Fixed vulnerabilities handling: Option to ignore or include unfixed vulnerabilities
- Flexible error handling: Choose to fail or continue on vulnerability detection
- Scheduled runs: Automatic weekly security scans
- Manual control: Manually trigger scans with custom parameters
- Detailed reporting: JSON output of discovered packages and scan results
Before using this workflow, ensure:
-
Docker images are published to GHCR
- Images must be available in GitHub Container Registry
- Must be in the same repository
-
GitHub Token with appropriate permissions
GH_ACCESS_TOKENsecret must be configured- Token needs
packages: readpermission
The workflow delegates actual vulnerability scanning to the re-security-scan.yml reusable workflow from the qubership-workflow-hub repository, which:
- Sets up and configures security scanning tools
- Pulls the specified Docker image from GHCR
- Runs Trivy vulnerability scanner (if enabled)
- Runs Grype vulnerability scanner (if enabled)
- Filters results by severity and fix status
- Reports findings
- No GHCR packages: If no Docker images are found in GHCR, the workflow fails during the
debug-packagesjob - Matrix vs Single: Only one scanning job runs (either matrix or single image mode)
- Default parameters: Matrix mode uses hardcoded defaults when triggered by schedule
- Token requirements: Ensure
GH_ACCESS_TOKENhas sufficient permissions - Parallel execution: Multiple images are scanned in parallel for efficiency
- Scheduled runs: Use default parameters during scheduled execution; customize by manually triggering
The workflow provides:
- Package discovery: List of all Docker images found in GHCR
- Vulnerability reports: Detailed findings from Trivy and Grype scanners
- Step summaries: GitHub Actions step summaries for each scan
- Matrix job logs: Individual logs for each scanned image
- Security
- Docker
- Automation
- Vulnerability Scanning
- security
- Docker
- scanning
- vulnerability
- automation
- trivy
- grype