Integration with CI/CD
Integrate GHAS security checks into CI/CD so vulnerable code cannot be merged or deployed unnoticed.
Simple Explanation (ELI5)
CI/CD integration means every code change must pass security checks automatically before it can move forward.
Technical Explanation
Security in CI/CD requires workflow orchestration: scans on PR, policy checks on main, scheduled deep scans, and deployment gates based on severity thresholds. Branch protection enforces compliance.
Visual Section
Hands-on Commands
name: security-gate
on:
pull_request:
branches: ["main"]
jobs:
codeql:
runs-on: ubuntu-latest
permissions:
contents: read
security-events: write
steps:
- uses: actions/checkout@v4
- uses: github/codeql-action/init@v3
with:
languages: javascript
- uses: github/codeql-action/analyze@v3
dependency-audit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: npm ci
- run: npm audit --audit-level=highDebugging Scenarios
- Gate not blocking merges: Required status checks not mapped correctly.
- Fork PR cannot access secrets: Use safe patterns; avoid exposing secrets to untrusted contexts.
- Pipeline unstable: Split scan jobs and isolate flaky dependencies.
- Security checks bypassed via admin merge: Restrict bypass permissions and audit events.
Real-world Use Case
A CI security gate blocked a high-severity vulnerable dependency in a release PR, preventing deployment of exploitable code to production.
Interview Questions
Beginner
Automated check that must pass before merge/deploy.
To catch issues before they reach main.
Branch protection rules.
No, it enforces and verifies but coding practices still matter.
Granting minimal token permissions required by each job.
Intermediate
Fast PR scans plus scheduled full scans.
Use encrypted secrets and avoid exposing on untrusted events.
Block high/critical in PR, track medium via SLA.
Reusable workflows and org-level governance templates.
Track blocked merges, false positives, and post-merge incidents.
Scenario-based
Review coverage gaps, add missing rule, and backfill scans.
Use exception process with approval and time-bound remediation.
Use path-based workflows and targeted scans per service.
Org-level reusable workflows and policy-as-code.
Compare branch-specific workflow conditions and environment settings.
Summary
CI/CD integration is where GHAS becomes enforceable: security findings become merge decisions, not optional reports.