Container Scan Guardrails
Enforces container image vulnerability scanning standards. Ensures container scanners run and validates vulnerability thresholds for container security.
container-scan to your lunar-config.yml:uses: github://earthly/lunar-lib/policies/container-scan@v1.0.0
Included Guardrails
This policy includes 3 guardrails that enforce standards for your security and compliance.
executed
Verifies that container scanning was executed on the component. Fails if no scanner has written to .container_scan.
max-severity
Ensures no findings at or above the configured severity threshold. Configure min_severity to set the threshold (critical, high, medium, low).
max-total
Ensures total container vulnerabilities are under a configurable threshold.
How Guardrails Fit into Lunar
Lunar guardrails define your engineering standards as code. They evaluate data collected by integrations and produce pass/fail checks with actionable feedback.
Policies support gradual enforcement—from silent scoring to blocking PRs or deployments—letting you roll out standards at your own pace without disrupting existing workflows.
Learn How Lunar Works →Required Integrations
This policy evaluates data gathered by one or more of the following integration(s).
Make sure to enable them in your lunar-config.yml.
Configuration
Configure this policy in your lunar-config.yml.
Inputs
| Input | Required | Default | Description |
|---|---|---|---|
min_severity
|
Optional |
high
|
Minimum severity to fail on (critical, high, medium, low) |
max_total_threshold
|
Required | — | Maximum total findings allowed (must be configured) |
Documentation
View on GitHubContainer Scan Guardrails
Enforces container image vulnerability scanning standards for container security.
Overview
This policy validates that container scanning is configured and enforces vulnerability thresholds for container images. It works with any container scanner that writes to the normalized .container_scan path in the Component JSON (Trivy, Grype, Snyk Container, etc.).
Policies
This plugin provides the following policies (use include to select a subset):
| Policy | Description | Failure Meaning |
|---|---|---|
executed |
Verifies container scanning ran | No scanner has written to .container_scan |
max-severity |
No findings at or above severity threshold | Findings found at configured severity or higher |
max-total |
Total vulnerabilities under threshold | Total count exceeds configured limit |
Required Data
This policy reads from the following Component JSON paths:
| Path | Type | Provided By |
|---|---|---|
.container_scan |
object | Any container scanner collector (Trivy, Grype, etc.) |
.container_scan.vulnerabilities.critical |
number | Container scanner collector |
.container_scan.vulnerabilities.high |
number | Container scanner collector |
.container_scan.vulnerabilities.medium |
number | Container scanner collector |
.container_scan.vulnerabilities.low |
number | Container scanner collector |
.container_scan.vulnerabilities.total |
number | Container scanner collector |
.container_scan.summary.has_critical |
boolean | Container scanner collector (preferred) |
.container_scan.summary.has_high |
boolean | Container scanner collector (preferred) |
.container_scan.summary.has_medium |
boolean | Container scanner collector (preferred) |
.container_scan.summary.has_low |
boolean | Container scanner collector (preferred) |
Note: If collectors don't yet write vulnerability counts, the max-severity and max-total checks will fail. Use include: [executed] to only verify the scanner ran until collectors are enhanced.
Installation
Add to your lunar-config.yml:
policies:
- uses: github://earthly/lunar-lib/policies/container-scan@main
on: ["domain:your-domain"]
enforcement: report-pr
# include: [executed, max-severity] # Only run specific checks
with:
min_severity: "high" # Fail on critical and high findings
max_total_threshold: "10" # Fail if more than 10 total findings
Examples
Passing Example
{
"container_scan": {
"source": { "tool": "trivy", "integration": "cicd" },
"vulnerabilities": { "critical": 0, "high": 0, "medium": 5, "total": 12 },
"summary": { "has_critical": false, "has_high": false }
}
}
Failing Example
{
"container_scan": {
"source": { "tool": "trivy", "integration": "cicd" },
"vulnerabilities": { "critical": 3, "high": 8, "medium": 15, "total": 40 },
"summary": { "has_critical": true, "has_high": true }
}
}
Failure messages:
executed: "No container scan data found. Ensure a scanner (Trivy, Grype, etc.) is configured."max-severity: "Critical container vulnerabilities detected (3 found)"max-total: "Total container vulnerability findings (40) exceeds threshold (10)"
Remediation
When this policy fails, you can resolve it by:
executedfailure: Configure a container scanner (Trivy, Grype, Snyk Container) in your CI pipeline.max-severityfailure: Review and remediate flagged vulnerabilities by updating base images or using vulnerability suppression for accepted risks.max-totalfailure: Reduce total vulnerability count by updating base images and dependencies.
Open Source
This policy is open source and available on GitHub. Contribute improvements, report issues, or fork it for your own use.
Common Use Cases
Explore how individual guardrails work with specific integrations.
Ready to Automate Your Standards?
See how Lunar can turn your engineering wiki, compliance docs, or postmortem action items into automated guardrails with our 100+ built-in guardrails.