Skip to content

About

Deterministic, rule-based CI/CD security gate: aggregates secret, dependency and SAST scanners into one policy-driven pass/fail gate with a deduplicated remediation report. Runs locally and as a GitHub Action.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

🛡️ CI/CD Security Vulnerability Gatekeeper

Tests Python Platform License

A security gate for your CI/CD pipeline. It scans every commit / pull request for hardcoded secrets, vulnerable dependencies, and insecure code, then decides whether to pass or fail the build based on a policy you control — and writes a clean report telling you exactly what to fix.

gatekeeper doesn't reinvent scanning. It wraps trusted open-source scanners (gitleaks, trivy, semgrep, …) and adds the part that's actually hard: merging their output, removing duplicates, scoring severity consistently, and turning it all into one pass/fail decision plus a fix list. All of that logic is deterministic and rule-based — same input, same result, every time.

gatekeeper scan --path . --policy gatekeeper.yml

Why it's useful

  • 🔑 Catches secrets — API keys, AWS credentials, private keys committed by mistake.
  • 📦 Flags vulnerable dependencies — known CVEs in your Python / Node packages.
  • 🐛 Finds insecure code — SQL injection, command injection, weak crypto (via SAST).
  • 🚦 One clear gate — a single policy file decides what fails the build.
  • 🧹 No noise — the same issue found by two scanners is shown once, credited to both.
  • 📋 Actionable fixes — every finding says what it is, where, why it matters, and how to fix it (e.g. "upgrade urllib3 1.25.8 → 1.26.5").
  • 🖥️ Runs anywhere — Windows, Linux, macOS; locally or in GitHub Actions.

How it works

 scanners (pluggable)                 core (deterministic engine)        outputs
 ┌─────────────┐
 │ gitleaks    │─┐                    ┌───────────┐  ┌──────────┐        ┌────────────────┐
 │ trufflehog  │ │                    │ normalize │→ │  score   │        │ Markdown report│
 │ trivy       │ ├──────────────────► │  + dedup  │  │ (rules)  │ ─────► │ results.json   │
 │ pip-audit   │ │  findings          │           │  │          │        │ PR comment     │
 │ npm audit   │ │                    └───────────┘  └──────────┘        │ GH annotations │
 │ semgrep     │─┘                          │             │              │ pass / fail    │
 └─────────────┘                            └──────►  policy gate  ──────►│ (exit code)    │
                                                     (gatekeeper.yml)     └────────────────┘

scan → score → deduplicate → gate. Each scanner is a small adapter that converts its native output into one shared Finding format; the core engine does everything after that.


Quick start

# 1. Clone
git clone https://github.com/Muhammad-Tayab/cicd-security-vulnerability-gatekeeper.git
cd cicd-security-vulnerability-gatekeeper

# 2. Install (only dependency is PyYAML)
pip install .

# 3. Run it on any project
gatekeeper scan --path . --policy gatekeeper.yml

With no scanners installed it runs cleanly and reports zero findings — install the scanners below to get real results.


Install the scanners

gatekeeper wraps scanners rather than bundling them. Each is optional — a missing one is skipped, not an error — so you can start with just one.

Category Tool Finds
Secrets gitleaks, trufflehog Hardcoded credentials / keys
Dependencies trivy, pip-audit, npm Vulnerable dependencies (CVEs)
SAST semgrep Insecure code patterns
# Python-based scanners (any OS)
pip install semgrep pip-audit

# gitleaks + trivy
scoop install gitleaks trivy        # Windows (or: choco install gitleaks trivy)
brew install gitleaks trivy         # macOS
# Linux: download the *_linux_x64 binaries from each project's releases page

npm audit ships with Node.js and runs automatically when a package.json is present. (semgrep has limited native Windows support — use WSL or a Linux CI job for SAST there.)


Usage

Local CLI:

gatekeeper scan --path . --policy gatekeeper.yml \
  --report report.md \      # write the Markdown remediation report
  --json results.json       # machine-readable results

# add --no-fail to report without failing the build

The command exits non-zero when the gate fails, so it works in any pipeline.

GitHub Actions — drop in .github/workflows/security-gate.yml:

name: Security Gate
on: [pull_request]
permissions:
  contents: read
  pull-requests: write
jobs:
  gatekeeper:
    runs-on: ubuntu-latest          # also works on windows-latest / macos-latest
    steps:
      - uses: actions/checkout@v4
        with: { fetch-depth: 0 }
      - uses: Muhammad-Tayab/cicd-security-vulnerability-gatekeeper@v1
        with:
          path: "."
          policy: "gatekeeper.yml"
          fail-on-findings: "true"

The action installs the scanners for you (with a Windows / Linux / macOS branch), posts findings inline in the PR diff, adds a summary comment, uploads the report, and fails the job if the gate trips.


Configuration

One YAML file (gatekeeper.yml) decides what fails the build:

fail_on:
  secrets:
    any: true             # any secret fails the build
  dependencies:
    min_cvss: 7.0         # fail on CVSS >= 7.0
  sast:
    min_severity: high    # fail on high-severity code issues

warn_on:                  # shown but non-blocking
  dependencies: { min_severity: medium }
  sast:         { min_severity: medium }

baseline:                 # accept known issues so old debt doesn't block you
  - fingerprint: "9f6d82c1e6514cbf"
    reason: "Accepted risk — tracked in JIRA-1234"

Under the hood

The interesting engineering is in the core, and it's all deterministic:

  • Deduplication — findings collapse on a stable fingerprint. The same secret flagged by two tools (gitleaks calls it aws-access-token, trufflehog calls it AWS) becomes one finding crediting both — no double counting. The same CVE from two dependency scanners merges too.
  • Severity scoring — one transparent ruleset: dependencies use CVSS bands; secrets are scored by type (a live AWS key outranks a random high-entropy string); SAST uses the rule's severity, elevated for high-impact CWEs. Every finding records why it got its score.
  • Remediation — fixes come from a rule table keyed by finding type, and dependency upgrade targets are computed from the advisory's fixed-version data.
  • Pluggable — adding a scanner is one small adapter class; the rest of the pipeline is untouched.

Tests

pip install -e ".[dev]"
pytest -q          # 22 passing

Tests feed recorded scanner output through the real dedup, scoring, and policy code — so the core is fully covered without any scanner installed.


Note

gatekeeper wraps scanners and reasons about their output. It does not modify your source or auto-commit fixes — it tells you what to change and lets you decide.

License

MIT — see LICENSE.

About

Deterministic, rule-based CI/CD security gate: aggregates secret, dependency and SAST scanners into one policy-driven pass/fail gate with a deduplicated remediation report. Runs locally and as a GitHub Action.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages