Hamburger Cross Icon
SAST Guardrails - Lunar Policy for Security And Compliance

SAST Guardrails

Policy Stable Security And Compliance

Enforces Static Application Security Testing standards. Ensures SAST scanners run and validates finding thresholds for code security.

Add sast to your lunar-config.yml:
uses: github://earthly/lunar-lib/policies/sast@v1.0.0

Included Guardrails

This policy includes 3 guardrails that enforce standards for your security and compliance.

Guardrail

executed

Verifies that SAST scanning was executed on the component. Fails if no scanner has written to .sast.

sast security scanning compliance code
View Guardrail
Guardrail

max-severity

Ensures no findings at or above the configured severity threshold. Configure min_severity to set the threshold (critical, high, medium, low).

sast critical high findings security code
View Guardrail
Guardrail

max-total

Ensures total code findings are under a configurable threshold.

sast threshold findings code
View Guardrail

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
1
Integrations Gather Data
Collectors extract metadata from code, CI pipelines, tool outputs, and scans
2
{ } Centralized as JSON
All data merged into each component's unified metadata document
3
Guardrails Enforce Standards This Policy
Real-time feedback in PRs and AI workflows

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 GitHub

SAST Guardrails

Enforces Static Application Security Testing (SAST) scanning standards for code security.

Overview

This policy validates that SAST scanning is configured and enforces finding thresholds for code security. It works with any SAST scanner that writes to the normalized .sast path in the Component JSON (Semgrep, CodeQL, Snyk Code, SonarQube, etc.).

Policies

This plugin provides the following policies (use include to select a subset):

Policy Description Failure Meaning
executed Verifies SAST scanning ran No scanner has written to .sast
max-severity No findings at or above severity threshold Findings found at configured severity or higher
max-total Total findings under threshold Total count exceeds configured limit

Required Data

This policy reads from the following Component JSON paths:

Path Type Provided By
.sast object Any SAST collector (Semgrep, CodeQL, etc.)
.sast.findings.critical number SAST collector
.sast.findings.high number SAST collector
.sast.findings.medium number SAST collector
.sast.findings.low number SAST collector
.sast.findings.total number SAST collector
.sast.summary.has_critical boolean SAST collector (preferred)
.sast.summary.has_high boolean SAST collector (preferred)
.sast.summary.has_medium boolean SAST collector (preferred)
.sast.summary.has_low boolean SAST collector (preferred)

Note: If collectors don't yet write finding 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/sast@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

{
  "sast": {
    "source": { "tool": "semgrep", "integration": "github_app" },
    "findings": { "critical": 0, "high": 0, "medium": 3, "total": 8 },
    "summary": { "has_critical": false, "has_high": false }
  }
}

Failing Example

{
  "sast": {
    "source": { "tool": "semgrep", "integration": "github_app" },
    "findings": { "critical": 1, "high": 3, "medium": 12, "total": 20 },
    "summary": { "has_critical": true, "has_high": true }
  }
}

Failure messages:

  • executed: "No SAST scanning data found. Ensure a scanner (Semgrep, CodeQL, etc.) is configured."
  • max-severity: "Critical SAST findings detected (1 found)"
  • max-total: "Total code findings (20) exceeds threshold (10)"

Remediation

When this policy fails, you can resolve it by:

  1. executed failure: Configure a SAST scanner (Semgrep, CodeQL, SonarQube) in your CI pipeline or as a GitHub App integration.
  2. max-severity failure: Review and remediate flagged code issues by applying the recommended fixes or marking as false positives in your scanner's configuration.
  3. max-total failure: Reduce total finding count by addressing code issues.

Open Source

This policy is open source and available on GitHub. Contribute improvements, report issues, or fork it for your own use.

View Repository

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.

Works with any process
check Infrastructure conventions
check Post-mortem action items
check Security & compliance policies
check Testing & quality requirements
Automate Now
Turn any process doc into guardrails
Book a Demo