Skip to content

Commit 4491c62

Browse files
expand security gates doc with CI/CD examples
1 parent 7853329 commit 4491c62

1 file changed

Lines changed: 32 additions & 31 deletions

File tree

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

Lines changed: 32 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
# Security Gates
22

3-
Security gates are automated checkpoints in your CI/CD pipeline that enforce security policies before code can proceed to the next stage. They act as quality gates specifically focused on security, ensuring that vulnerabilities, misconfigurations, and policy violations are caught early in the development lifecycle.
3+
Security gates are checkpoints in your CI/CD pipeline that block or warn when security issues are detected. Think of them like quality gates, but for security - if a scan finds a critical vulnerability, the pipeline stops and the code doesn't get deployed.
44

5-
## Why Security Gates Matter
5+
The idea is simple: catch problems before they hit production. A vulnerability found during a pull request costs minutes to fix. The same vulnerability found in production? That's an incident, potentially a breach, and weeks of cleanup.
66

7-
Without security gates, vulnerabilities can slip through the pipeline and reach production, leading to:
7+
## Why Bother?
88

9-
- Data breaches and security incidents
10-
- Costly remediation efforts
11-
- Compliance violations
12-
- Reputation damage
9+
Most teams already run linters and unit tests in CI. Security gates extend this to:
1310

14-
Security gates shift security left by making it an integral part of the development process rather than an afterthought.
11+
- Block code with hardcoded secrets or API keys
12+
- Catch vulnerable dependencies before they ship
13+
- Flag container images with known CVEs
14+
- Enforce infrastructure-as-code policies (no public S3 buckets, etc.)
15+
16+
Without gates, security becomes a manual review bottleneck or gets skipped entirely when deadlines hit.
1517

1618
## Types of Security Gates
1719

@@ -30,11 +32,11 @@ Security gates shift security left by making it an integral part of the developm
3032
+-------------+-------------+-------------+-------------+---------------------+
3133
```
3234

33-
## Implementing Security Gates
35+
## Setting Up Security Gates
3436

35-
### 1. Define Security Thresholds
37+
### Define Your Thresholds First
3638

37-
Establish clear criteria for what constitutes a passing or failing security gate:
39+
Before wiring up tools, decide what blocks a deployment vs. what just logs a warning. Here's a common starting point:
3840

3941
| Severity | Action | Example Threshold |
4042
|----------|--------|-------------------|
@@ -43,9 +45,9 @@ Establish clear criteria for what constitutes a passing or failing security gate
4345
| Medium | Warn, require approval | 5 or fewer allowed |
4446
| Low | Warn only | No limit (track) |
4547

46-
### 2. Security Gate Configuration
48+
### Centralized Config
4749

48-
Create a centralized security gate configuration file:
50+
Keep your gate policies in a single config file so teams know what's enforced:
4951

5052
```yaml
5153
# .security-gates.yaml
@@ -98,7 +100,7 @@ gates:
98100
- dockerfile
99101
```
100102
101-
### 3. GitHub Actions Security Gate Pipeline
103+
### GitHub Actions Example
102104
103105
```yaml
104106
# .github/workflows/security-gates.yaml
@@ -347,7 +349,7 @@ jobs:
347349
exit 1
348350
```
349351
350-
### 4. GitLab CI Security Gates
352+
### GitLab CI Example
351353
352354
```yaml
353355
# .gitlab-ci.yml
@@ -442,11 +444,11 @@ security-gate:
442444
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
443445
```
444446
445-
## Security Gate Best Practices
447+
## Tips From the Field
446448
447-
### 1. Progressive Gate Enforcement
449+
### Roll Out Gradually
448450
449-
Start with warnings, then gradually enforce stricter policies:
451+
Don't flip everything to "block" on day one - you'll just frustrate developers and get the gates disabled. Start soft:
450452
451453
```yaml
452454
# Phase 1: Warn only (Week 1-2)
@@ -459,9 +461,9 @@ security_gate_mode: "block_critical"
459461
security_gate_mode: "block_critical_high"
460462
```
461463
462-
### 2. Exception Management
464+
### Handle False Positives
463465
464-
Implement a process for security exceptions:
466+
Scanners aren't perfect. You'll need a way to suppress findings that don't apply:
465467
466468
```yaml
467469
# .security-exceptions.yaml
@@ -478,7 +480,7 @@ exceptions:
478480
expires: "2024-03-15"
479481
```
480482
481-
### 3. Gate Bypass for Emergencies
483+
### Emergency Bypass (Use Sparingly)
482484
483485
```yaml
484486
# Emergency bypass (requires approval)
@@ -515,19 +517,18 @@ Pipeline blocked: IaC gate failed
515517
Action Required: Fix the critical IaC issue before merge.
516518
```
517519
518-
### Remediation Workflow
520+
### When a Gate Fails
519521
520-
1. **Review the failure details** in the CI/CD logs
521-
2. **Fix the identified issues** in your code
522-
3. **Re-run the pipeline** to verify fixes
523-
4. **If exception needed**, create a security exception request
522+
1. Check the CI logs - most tools show exactly what's wrong and where
523+
2. Fix it or file an exception if it's a false positive
524+
3. Re-run the pipeline
524525
525-
## Security Caveats
526+
## Watch Out For
526527
527-
- **False Positives**: Security gates may block legitimate code. Implement an exception process.
528-
- **Tool Limitations**: No single tool catches everything. Use defense in depth with multiple tools.
529-
- **Performance Impact**: Running multiple security scans increases pipeline time. Optimize with caching and parallel execution.
530-
- **Bypass Risks**: Emergency bypasses should be audited and time-limited.
528+
- **False positives will happen** - have an exception process ready or developers will just disable the gates
529+
- **No scanner catches everything** - layer multiple tools, don't rely on just one
530+
- **Scans add time** - run them in parallel and cache where possible, or developers will complain about slow pipelines
531+
- **Audit your bypasses** - if someone needs an emergency bypass, make sure there's a ticket tracking when it expires
531532
532533
---
533534

0 commit comments

Comments
 (0)