This repository implements comprehensive security scanning as part of the CI/CD pipeline. This guide explains how to configure branch protection to enforce security gates.
Triggers:
- Pull requests to
main - Pushes to
main - Nightly schedule (2 AM UTC)
- Manual dispatch
Jobs:
- CodeQL SAST (
codeql) - Static analysis for JavaScript/TypeScript - Dependency Audit (
dependency-scan) - npm vulnerability scanning - Container Scan (
container-scan) - Docker image scanning (conditional) - Security Summary (
security-summary) - PR comments and notifications
Jobs:
- Build and test validation
To enforce security gates, configure branch protection rules for main:
- Navigate to: Settings → Branches → Add rule
- Branch pattern:
main - Enable the following:
-
✅ Require a pull request before merging
- Required approving reviews:
1(minimum) - ✅ Dismiss stale pull request approvals when new commits are pushed
- ✅ Require review from Code Owners (if applicable)
- Required approving reviews:
-
✅ Require status checks to pass before merging
- ✅ Require branches to be up to date before merging
Required status checks:
build-test(from CI workflow)CodeQL SAST(from Security workflow)Dependency Security Audit(from Security workflow)Container Security Scan(optional - only if Dockerfile exists)
-
✅ Require conversation resolution before merging
-
✅ Include administrators (recommended for security compliance)
- ✅ Restrict who can push to matching branches
- Limit to maintainers/security team
- ✅ Do not allow bypassing the above settings
- Prevents emergency bypasses that could introduce vulnerabilities
Repository Settings
└── Branches
└── Branch protection rules
└── Add rule
├── Branch name pattern: main
├── ☑ Require a pull request before merging
│ ├── Required approvals: 1
│ ├── ☑ Dismiss stale approvals
│ └── ☑ Require Code Owner review
├── ☑ Require status checks to pass
│ ├── ☑ Require branches up to date
│ └── Status checks:
│ ├── build-test
│ ├── CodeQL SAST
│ └── Dependency Security Audit
├── ☑ Require conversation resolution
└── ☑ Include administrators
Edit .github/security-exemptions.json:
{
"exemptions": [
{
"id": "EXEMPT-001",
"cve_id": "CVE-2024-XXXXX",
"package": "affected-package",
"version": "1.2.3",
"severity": "critical",
"reason": "Brief justification for exemption",
"expiry_date": "2026-07-30",
"created_by": "your-name",
"advisory_id": "GHSA-xxxx-xxxx-xxxx",
"mitigation": "Plan to fix or workarounds applied",
"container_rule": null
}
]
}- Maximum duration: 90 days
- Auto-renewal: Disabled (requires manual review)
- Notification: 14 days before expiry
- Review required: Yes, security team must approve
- Check expiring exemptions (automated notification)
- Verify if vulnerability has been patched upstream
- If fixed: Remove exemption and update dependency
- If still vulnerable: Create new exemption with fresh justification
- Document decision in security review log
The workflow automatically comments on PRs with:
- Scan status table
- Exempted vulnerabilities with advisory links
- High severity informational findings
- Action items for blocked vulnerabilities
Configure by adding SLACK_WEBHOOK_URL secret:
- Triggers on security scan failures
- Includes repository, branch, commit, and run link
- Automated GitHub issue creation on failures
- Labels:
security,urgent - Includes links to detailed run logs
# Test locally
npm audit
# Verify exemptions file is valid JSON
node -e "JSON.parse(require('fs').readFileSync('.github/security-exemptions.json'))"- Create a test branch:
git checkout -b test/security-scan - Make a small change
- Push and create PR
- Verify security checks appear in PR status checks
- Check for security summary comment
# Add a known vulnerable package (for testing only)
npm install --save-dev example-vulnerable-package
# Run audit
npm audit
# Verify workflow would block
# Then remove the test package
npm uninstall example-vulnerable-package- Ensure workflow has run at least once on the branch
- Check workflow file syntax with GitHub Actions linting tools
- Verify
on.pull_request.branchesincludesmain
- Review CodeQL query documentation
- Add inline comments to suppress specific warnings if appropriate
- Update CodeQL configuration in
.github/codeql-config.ymlif needed
- Run
npm auditlocally to see details - Check if exemption exists and is valid
- Update affected packages if patches available
- Run
npm audit fixfor automatic fixes (review changes carefully)
- Verify Dockerfile exists in repository root
- Check workflow conditional:
if: ${{ hashFiles('Dockerfile') != '' }} - Review Docker build logs for errors
- SAST (CodeQL): Scans source code for security patterns, logic flaws, injection vulnerabilities
- Dependency Scan: Checks third-party packages against known vulnerability databases
- Container Scan: Analyzes runtime image for OS-level and library vulnerabilities
All three are complementary and necessary for fintech security compliance.
- Payment stream handling requires strict security validation
- All money movement code paths must pass security gates
- No silent
continue-on-erroron critical vulnerabilities - Exemptions require documented justification and expiry
- Runtime Application Self-Protection (RASP)
- Dynamic Application Security Testing (DAST)
- Penetration testing (should be conducted separately)
- Infrastructure security (Terraform, Kubernetes scans)
For security concerns or questions:
- Review this documentation
- Check workflow run logs for detailed error messages
- Contact security team for exemption reviews
- Open GitHub issue for workflow bugs