GitHub Actions Integration¶
This guide explains how to use GitHub Actions for secure Kubernetes container scanning with CINC Auditor (using the train-k8s-container plugin) and MITRE SAF-CLI.
Strategic Priority: We strongly recommend the Kubernetes API Approach using the train-k8s-container plugin for enterprise-grade container scanning. Our highest priority is enhancing this plugin to support distroless containers. See Approach Comparison and Security Compliance for more details.
Available Workflows¶
We provide three GitHub Actions workflow examples:
- Basic Setup and Scan - Sets up a minikube cluster and runs a basic scan against a container
- Dynamic RBAC Scanning - Demonstrates dynamic pod selection by labels with secure RBAC
- CI/CD Pipeline - Complete pipeline that builds, deploys, scans a container, and processes results with SAF-CLI
Setup Instructions¶
1. Repository Setup¶
- Create a new GitHub repository or use an existing one
- Copy the workflow files from the
docs/github-workflow-examples
directory to.github/workflows
in your repository - Commit and push the changes
2. Workflow Permissions¶
Ensure your GitHub Actions workflows have appropriate permissions:
- Go to your repository Settings > Actions > General
- Under "Workflow permissions", select "Read and write permissions"
- Check "Allow GitHub Actions to create and approve pull requests"
Running the Workflows¶
Basic Setup and Scan¶
This workflow sets up a minikube cluster and runs a basic scan against a busybox container:
- Navigate to the Actions tab in your repository
- Select the "Setup Minikube and Run CINC Auditor Scan" workflow
- Click Run workflow
- Configure the parameters:
- Minikube version: Version of minikube to use (default: v1.32.0)
- Kubernetes version: Version of Kubernetes to use (default: v1.28.3)
- CINC profile: Profile to run (default: dev-sec/linux-baseline)
- Click Run workflow to start the scan
The workflow will:
- Set up a minikube cluster
- Create a test pod
- Configure restricted RBAC
- Run CINC Auditor against the container
- Upload the scan results as artifacts
Dynamic RBAC Scanning¶
This workflow demonstrates more advanced scanning with dynamic pod targeting:
- Navigate to the Actions tab
- Select the "Dynamic RBAC Pod Scanning" workflow
- Click Run workflow
- Configure the parameters:
- Target container image: Container image to scan
- Scan label: Label to identify the target container (format: key=value)
- CINC profile: Profile to run
- Click Run workflow
The workflow will:
- Create multiple pods but only label one for scanning
- Set up label-based RBAC
- Run CINC Auditor against the labeled container only
- Verify that access is properly restricted
- Upload the results as artifacts
CI/CD Pipeline with SAF-CLI¶
This workflow demonstrates a complete CI/CD pipeline with security scanning and quality gates:
- Navigate to the Actions tab
- Select the "CI/CD Pipeline with CINC Auditor Scanning" workflow
- Click Run workflow
- Configure the parameters:
- Image tag: Tag for the container image
- Scan namespace: Kubernetes namespace for deployment and scanning
- Threshold: Minimum passing score (0-100) for security checks
- Click Run workflow
The workflow will:
- Create a simple test application
- Build a container image
- Deploy it to Kubernetes
- Set up secure scanning access
- Run custom security checks with CINC Auditor
- Generate reports with SAF-CLI
- Apply threshold checks for quality gates
- Upload all results as artifacts
MITRE SAF-CLI Integration¶
Overview¶
The workflow uses MITRE SAF-CLI for processing scan results and implementing quality gates. SAF-CLI provides:
- Formatted summaries (Markdown, JSON, etc.)
- Threshold-based quality gates
- Visualization capabilities
SAF-CLI Commands Used¶
Summary Generation¶
Threshold Checks¶
Advanced Thresholds¶
For more granular control, you can extend the threshold command:
GitHub Step Summary Integration¶
Customizing the Workflows¶
Using Your Own Profiles¶
To use your own CINC Auditor profiles:
- Create a profile in your repository (e.g.,
./profiles/my-custom-profile
) - When running the workflow, enter
./profiles/my-custom-profile
as the profile parameter
Or use a profile from a URL:
- Host your profile in a Git repository
- When running the workflow, enter the URL of your profile
Integrating with Pull Requests¶
You can modify the workflows to run on pull requests:
- Edit the workflow file
- Update the
on:
section to include pull requests:
- Add comment reporting using SAF-CLI output:
Enforcing Quality Gates¶
To enforce quality gates in your workflow:
- Edit the workflow file
- Modify the threshold check to exit on failure:
Security Considerations¶
GitHub Secrets¶
For production use, consider storing sensitive configuration in GitHub Secrets:
- Go to repository Settings > Secrets and variables > Actions
- Create secrets for:
KUBE_CONFIG
: Base64-encoded kubeconfig (for external clusters)CINC_LICENSE
: License acceptance for CINC Auditor (if needed)
RBAC Best Practices¶
The workflows demonstrate secure RBAC patterns:
- Use time-limited tokens (15 minutes)
- Clean up resources after scanning
- Only grant necessary permissions
- Use label selectors for dynamic targeting
Troubleshooting¶
Common Issues¶
- Minikube startup fails - Increase resource limits in the action
- Plugin installation fails - Check network connectivity or use pre-built images
- Scan access denied - Verify RBAC permissions and token validity
- SAF-CLI installation fails - Ensure Node.js is available in the runner
SAF-CLI Debugging¶
If you encounter issues with SAF-CLI:
References¶
- CINC Auditor Documentation
- MITRE SAF-CLI Documentation
- GitHub Actions Documentation
- Minikube GitHub Action
- Kubernetes RBAC Documentation