iac-sast-scanning
Skill0 starsChanged 5 months agoMITView on GitHub
The binding, machine-enforced security gate for Ansible + GitLab CI changes: ansible-lint (production profile, SARIF), gitleaks + TruffleHog secret scanning, Checkov/KICS IaC misconfig scanning, with SARIF aggregated to the GitLab Security Dashboard and a deterministic severity gate. Reviewer agents advise; THIS fails the pipeline. Triggers on: SAST, static analysis, security scan, ansible-lint, checkov, kics, gitleaks, trufflehog, SARIF, security gate, supply chain, SBOM.
In this repository24 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- ansible-patternsSkill
- ansible-testingSkill
- change-documentationSkill
- ci-pipeline-debuggingSkill
- drift-detectionSkill
- gitlab-cicd-pipelineSkill
- hsa-infrastructureSkill
- iac-tooling-selectionSkill
- incident-responseSkill
- instinct-promotionSkill
- instinct-rollbackSkill
- knowledge-curationSkill
- multi-env-promotionSkill
- octopus-releaseSkill
- pci-cp-complianceSkill
- pci-dss-complianceSkill
- pci-pin-awarenessSkill
- perso-change-controlSkill
- perso-complianceSkill
- pre-commit-and-secret-scanningSkill
- rollback-and-runbooksSkill
- secrets-vaultSkill
- supply-chain-and-sbomSkill
The file
We split this skill into the rules it gives an agent
1 rule. About 0 are common, 1 is distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 17
Use when wiring or reasoning about the machine-enforced security gate for Ansible and GitLab CI changes — the layer that *fails the build* …
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
IaC SAST & Security Scanning Skill
When to Use
Use when wiring or reasoning about the machine-enforced security gate for Ansible and GitLab CI changes — the layer that fails the build rather than merely advising. An LLM reviewer is probabilistic; this gate is deterministic. Every MR passes through it, and any finding at or above the gate threshold blocks the merge regardless of what any agent concluded.
How It Works
Enforcement is layered so each control runs where it is cheapest and hardest to bypass:
- Pre-commit (advisory, fast <10s): a
.pre-commit-config.yamlsubset (yamllint, a fast ansible-lint profile, gitleaks) catches the obvious before code leaves the developer's machine. Advisory only — CI is authoritative. - PostToolUse hooks (in-session):
yamllint-hook,ansible-syntax-hook, and thepan-egress-filterDLP run automatically as the agent edits. Fast, fail-open on parse errors (CI is the hard gate). - CI gate (authoritative, binding): the pipeline stages below. Each emits SARIF uploaded as a GitLab Code Quality / Security report so findings surface inline on the MR and aggregate in the Security Dashboard.
CI stage order (mirrors ansible-testing, with security inserted)
yamllint → ansible-lint (production, SARIF) → ansible-playbook --syntax-check
→ gitleaks → trufflehog (verified) → checkov (or kics) → --check --diff (ARA)
→ molecule (idempotence)Deterministic severity gate (no model discretion)
- CRITICAL / HIGH from any scanner → pipeline fails, merge blocked.
- MEDIUM → reported, non-blocking, must be triaged.
- Suppressions require an inline justification comment + an expiry and are themselves
reviewed (no blanket disables). ansible-lint
# noqa, checkov# checkov:skip, gitleaksgitleaks:allow— each with a reason and a ticket reference.
Determinism / repeatability
Pin every scanner by digest or exact version so the ruleset is identical across
runs (same input → same verdict): ansible-lint ≥24.x (production profile), Checkov
pinned, gitleaks pinned (note the project moved to the gitleaks/gitleaks org), the
execution environment image by digest. Floating :latest is forbidden — it makes the
gate non-reproducible.
Single source of truth
The standards live in the rules/ files (path-injected) and the domain skills; this
skill wires the tools that enforce them. The reviewer agents (playbook-reviewer,
pci-compliance-reviewer, secrets-scanner) cite the same rules and feed the merge gate —
they catch the semantic/contextual issues the scanners cannot, while the scanners catch
what must never pass.
Examples
GitLab CI: ansible-lint with SARIF
ansible-lint:
stage: lint
image: registry.example/ee/ansible-lint@sha256:<pinned>
script:
- ansible-lint --profile production --sarif-file gl-sast-ansible.sarif || true
artifacts:
reports:
sast: gl-sast-ansible.sarif
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'Secret scanning (fail-closed)
gitleaks:
stage: security
image: zricethezav/gitleaks@sha256:<pinned> # org moved to gitleaks/gitleaks
script:
- gitleaks detect --redact --report-format sarif --report-path gl-secrets.sarif
artifacts:
reports:
secret_detection: gl-secrets.sarif
# No `|| true` — a secret leak must fail the pipeline.Checkov for Ansible misconfig
checkov:
stage: security
image: bridgecrew/checkov@sha256:<pinned>
script:
- checkov -d . --framework ansible --output sarif --output-file-path gl-iac.sarif
artifacts:
reports:
sast: gl-iac.sarifTrust boundary
- Scans run in the corporate/DSS zone CI only — never wired into the air-gapped HSA.
- Scanners are read-only over the repo; they never apply changes or reach prod.
- Secret/PAN findings are redacted in reports (
--redact) — never echo the value into logs. A confirmed PAN/key finding → route toincident-response.
Deep Reference
Full Tool Stack
| Tool | What it catches | Config file |
ansible-lint | Ansible anti-patterns, FQCN, idempotency | .ansible-lint |
yamllint | YAML syntax, formatting | .yamllint |
gitleaks | Secrets, high-entropy strings | .gitleaks.toml |
TruffleHog v3 | Historical secret leaks in git history | CLI flags |
Checkov | IaC misconfigurations (Terraform, Ansible, Dockerfile) | .checkov.yaml |
SARIF Output for GitLab Security Dashboard
# .gitlab-ci.yml
ansible-lint-sast:
stage: sast
tags: [linux, docker]
image: pipelinecomponents/ansible-lint:latest
script:
- ansible-lint -f sarif -o gl-sast-report.json || true
artifacts:
reports:
sast: gl-sast-report.jsonCheckov Ansible Checks to Enable
# .checkov.yaml
check:
- CKV2_ANSIBLE_1 # Ensure no_log is set for tasks with sensitive data
- CKV2_ANSIBLE_2 # Ensure validate_certs is not false
- CKV_ANSIBLE_1 # Ensure no plaintext passwordsBlocking vs. Advisory
The iac-sast-scanning CI gate is blocking — it must pass before a merge is allowed.
Agent reviewer VERDICTs are advisory. If the CI gate passes but an agent returns BLOCK,
treat the agent BLOCK as the authoritative signal (the agent may catch logic issues the
static scanner cannot).
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

