Skip to content

docs: expand Security Gates with CI/CD examples - #99

Closed
farhanashrafdev wants to merge 13 commits into
OWASP:masterfrom
farhanashrafdev:master
Closed

farhanashrafdev wants to merge 13 commits into
OWASP:masterfrom
farhanashrafdev:master

Conversation

@farhanashrafdev

Copy link
Copy Markdown
Contributor

Expand Security Gates documentation

Filled in the Security Gates stub (current-version/2-Process/2-3-Build/2-3-5-Security-Gates.md) with practical content.

What's added

  • Explanation of what security gates are and why they matter
  • Threshold configuration examples (what to block vs warn)
  • Full CI/CD pipeline examples for both GitHub Actions and GitLab CI
  • Coverage of all gate types: secrets, SAST, SCA, container, IaC
  • Best practices: gradual rollout, handling false positives, emergency bypasses
  • Sample gate output showing what failures look like
  • Tools section (open-source and commercial) following the existing format

Why

The original file was just a TBD stub. Security gates are a core DevSecOps concept and the guideline needed concrete examples teams can actually use.

Checklist

  • Follows existing document structure
  • Uses - for lists (MD004)
  • Tools listed alphabetically with footnote
  • No trailing whitespace
  • Tested locally with markdownlint

@Ali-Yazdani

Copy link
Copy Markdown
Collaborator

Hi @farhanashrafdev, please fix the conflict.

@farhanashrafdev

Copy link
Copy Markdown
Contributor Author

Hello @Ali-Yazdani sure let me go through and fix it, thanks

…-pr-99-conflicts

# Conflicts:
#	current-version/2-Process/2-3-Build/2-3-5-Security-Gates.md
Copilot AI balanced review requested due to automatic review settings October 3, 2026 23:31
farhanashrafdev and others added 2 commits October 4, 2026 04:33
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…D040)

Add blank lines around headings, lists and fences, and tag bare code fences with a language so the pre-commit CI passes.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

The examples contain credential exposure, unenforced security policies, and pipeline execution failures.

Review effort: Balanced
Findings: 4 High severity · 13 Medium severity

Open (17)
What changed in this PR

Expands the DevSecOps Security Gates guidance with practical policies and CI/CD examples.

Changes:

  • Adds threshold policies and GitHub Actions/GitLab CI examples.
  • Documents rollout, exceptions, emergency bypasses, and gate results.
  • Expands tooling and reference resources.
File Description
current-version/​2-Process/​2-3-Build/​2-3-5-Security-Gates.md Adds security-gate policies, pipeline examples, and operational guidance.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread current-version/2-Process/2-3-Build/2-3-5-Security-Gates.md
Comment thread current-version/2-Process/2-3-Build/2-3-5-Security-Gates.md Outdated
Comment thread current-version/2-Process/2-3-Build/2-3-5-Security-Gates.md Outdated
Comment thread current-version/2-Process/2-3-Build/2-3-5-Security-Gates.md Outdated
Comment thread current-version/2-Process/2-3-Build/2-3-5-Security-Gates.md Outdated
Comment thread current-version/2-Process/2-3-Build/2-3-5-Security-Gates.md Outdated
Comment thread current-version/2-Process/2-3-Build/2-3-5-Security-Gates.md Outdated
Comment thread current-version/2-Process/2-3-Build/2-3-5-Security-Gates.md Outdated
Comment thread current-version/2-Process/2-3-Build/2-3-5-Security-Gates.md Outdated
Comment thread current-version/2-Process/2-3-Build/2-3-5-Security-Gates.md Outdated
@farhanashrafdev

Copy link
Copy Markdown
Contributor Author

@Ali-Yazdani fixed, please review :)

Address Copilot review findings in the GitHub Actions and GitLab CI examples:
- remove TruffleHog base/head overrides; add contents/actions read permissions
- run Semgrep explicitly, write semgrep.json and fail closed when missing
- enforce zero-high policy for SCA and container gates (no silent >5 loophole)
- install locked deps before pip-licenses; note CodeQL is enforced via code-scanning rulesets
- fix Checkov output path, drop bogus evaluated_keys severity check, handle array/object reports
- summary job fails on cancelled/skipped, not only failure
- GitLab: clear TruffleHog entrypoint, use --fail instead of dumping raw secret JSON,
  build image before scanning, drop native-JSON reports: declarations, check HIGH threshold,
  apply shared rules to all gate-dependency jobs
- emergency bypass now relies on protected environments instead of a caller-supplied APPROVED_BY

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread current-version/2-Process/2-3-Build/2-3-5-Security-Gates.md
Comment thread current-version/2-Process/2-3-Build/2-3-5-Security-Gates.md Outdated
Comment thread current-version/2-Process/2-3-Build/2-3-5-Security-Gates.md
Comment thread current-version/2-Process/2-3-Build/2-3-5-Security-Gates.md Outdated
…e examples

- Kaniko: write /kaniko/.docker/config.json from CI_REGISTRY_* before pushing
- Trivy: pass TRIVY_USERNAME/TRIVY_PASSWORD so the private image can be pulled
- Bypass job: needs: [build-image] so it is a DAG job that can run when gates fail
- License gate: match GPL/AGPL native and SPDX names, exclude LGPL, share one filter

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

The pipeline examples still expose credentials in logs and contain configuration errors that prevent execution in supported scenarios.

Review effort: Balanced
Findings: 1 High severity · 1 Medium severity

Open (2)
Resolved since last review (4)
Previously missed (3)

In code that hasn't changed since last review

Medium severity Add pull-requests read permission for private repository scans

current-version/​2-Process/​2-3-Build/​2-3-5-Security-Gates.md:161

The secrets job inherits only contents: read, but Gitleaks v2 calls the pull-request commits API before scanning. That endpoint requires pull-requests: read for private repositories, so private-repository PRs fail before the scan runs, even with no secrets present. Add that permission to this job while retaining checkout access.

Medium severity Pin security actions to vetted commit SHAs

current-version/​2-Process/​2-3-Build/​2-3-5-Security-Gates.md:171

The workflow runs TruffleHog from mutable @main, both Trivy scans from @master (lines 236 and 303), and Checkov from @master (line 342). Upstream branch changes can therefore replace code running against the repository without a reviewed workflow update, creating supply-chain risk in the security gates themselves. Pin these actions to vetted full commit SHAs, using the same Trivy pin for both scans.

Medium severity Provide Gitleaks license for organization-owned repositories

current-version/​2-Process/​2-3-Build/​2-3-5-Security-Gates.md:179

Gitleaks Action v2 requires GITLEAKS_LICENSE for organization-owned repositories and exits before scanning when it is absent. This example supplies only the token, so organization users cannot run the pipeline even on clean commits. Document and supply the license secret, or use the standalone Gitleaks CLI instead.

Comment thread current-version/2-Process/2-3-Build/2-3-5-Security-Gates.md Outdated
Comment thread current-version/2-Process/2-3-Build/2-3-5-Security-Gates.md Outdated
…fault branch

- TruffleHog: capture --json output outside the workspace and print only count + detector names (plain printer also emits Raw result)
- Bypass job rule now requires CI_COMMIT_BRANCH == CI_DEFAULT_BRANCH so build-image always exists in the pipeline

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

The pipeline examples can accept incomplete scans or miss blocking findings, undermining their security-gate purpose.

Review effort: Balanced
Findings: 4 High severity

Open (4)
Resolved since last review (2)
Previously missed (2)

In code that hasn't changed since last review

Medium severity Gitleaks fails without a required organization license

current-version/​2-Process/​2-3-Build/​2-3-5-Security-Gates.md:179

Gitleaks Action requires GITLEAKS_LICENSE for organization-owned repositories. Passing only GITHUB_TOKEN makes the action fail before scanning in those repositories. Document and pass the required repository or organization secret, or use the license-free Gitleaks CLI instead.

Medium severity Mixed-case repository name breaks Docker image build

current-version/​2-Process/​2-3-Build/​2-3-5-Security-Gates.md:305

github.repository preserves capitalization, but Docker image repository names must be lowercase. A name such as org/DevSecOpsGuideline makes this build fail before scanning. Since the image is used only within this job, use the same fixed lowercase local name for the build and Trivy scan.

# push or pull_request event itself. Hard-coding the default branch as
# base makes base == HEAD on pushes to that branch, which TruffleHog rejects.
- name: TruffleHog Secret Scan
uses: trufflesecurity/trufflehog@main
- name: Run Semgrep
run: |
python3 -m pip install --quiet semgrep
semgrep scan \
echo "SAST Gate ERROR: semgrep.json not produced"
exit 1
fi
CRITICAL=$(jq '[.results[] | select(.extra.severity == "ERROR")] | length' semgrep.json)
Comment on lines +364 to +365
FAILED=$(jq '[.. | objects | select(has("failed_checks")) | .failed_checks[]?] | length' "$REPORT") || {
echo "IaC Gate ERROR: malformed Checkov report"; exit 1; }
@farhanashrafdev

Copy link
Copy Markdown
Contributor Author

Its like a never ending cycle, each time its finding new bugs

@Ali-Yazdani

Copy link
Copy Markdown
Collaborator

Hi @farhanashrafdev , my suggestion is to close this and open a new one based on the head.

@farhanashrafdev

Copy link
Copy Markdown
Contributor Author

Thanks @Ali-Yazdani, done - closing this in favour of #111, which is a single clean commit on top of current master with the same content (plus the #110 edits folded in and scanner actions pinned).

Ali-Yazdani pushed a commit that referenced this pull request Oct 4, 2026
Supersedes #99, rebased onto current master as a single commit.

Adds to 2-3-5-Security-Gates.md:
- Pipeline placement diagram and severity-threshold table
- Policy-as-code example (.security-gates.yaml) and gradual rollout guidance
- End-to-end GitHub Actions and GitLab CI gate pipelines (secrets, SAST, SCA,
  container, IaC) with a single fail-closed summary gate
- Sample gate output, exceptions-as-code, and an auditable emergency bypass
- License gate with SPDX-aware matching
- Additional tools, KPIs and references

Keeps all V0.4 content and the edits from #110 (semgrep ci example, VEX link,
scanner-pinning pitfall, updated references). Third-party actions in the
examples are pinned to release tags.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants