Skip to content

Commit 1f14de2

Browse files
authored
Merge pull request #29 from wendev27/checkpoint-19-owasp-security-practices
docs(checkpoint): complete checkpoint 19 - OWASP security practices
2 parents b00f33c + 29c7786 commit 1f14de2

7 files changed

Lines changed: 1486 additions & 2 deletions

File tree

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ This repository was created to:
7676
- [x] Trivy Container Scanning
7777
- [x] Container Security
7878
- [x] Secure CI/CD Pipelines
79-
- [ ] Branch Protection
80-
- [ ] OWASP Security Practices
79+
- [x] Branch Protection
80+
- [x] OWASP Security Practices
8181

8282
---
8383

Lines changed: 271 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,271 @@
1+
# 🛡️ Checkpoint 19 — OWASP Security Practices
2+
3+
## 🎯 Objective
4+
5+
Understand how OWASP security principles connect to modern DevSecOps tools and workflows.
6+
7+
This checkpoint focused on answering an important question:
8+
9+
> "How do real-world security risks connect to the tools used in modern CI/CD pipelines?"
10+
11+
To answer that question, I explored:
12+
13+
- OWASP Top 10 risks
14+
- Secrets management
15+
- Dependency scanning
16+
- Static Application Security Testing (SAST)
17+
- Container security
18+
- Secure CI/CD pipelines
19+
- Branch protection rules
20+
21+
---
22+
23+
# 📚 What I Learned
24+
25+
OWASP is not a tool.
26+
27+
OWASP is a collection of security risks, best practices, and guidelines that help developers build secure applications.
28+
29+
Many of the tools and practices explored throughout Phase 4 exist to mitigate OWASP risks.
30+
31+
---
32+
33+
# 🔥 OWASP Risks and Their DevSecOps Counterparts
34+
35+
| OWASP Risk | Tool / Practice |
36+
| :-------------------------- | :------------------------------------- |
37+
| Injection | Semgrep, CodeQL, Parameterized Queries |
38+
| Sensitive Data Exposure | `.env`, GitHub Secrets |
39+
| Vulnerable Components | `npm audit`, Trivy |
40+
| Security Misconfiguration | Branch Protection, CI/CD |
41+
| Broken Access Control | RBAC |
42+
| Software Integrity Failures | CodeQL, Secure Pipelines |
43+
| Denial of Service (DoS) | Rate Limiting |
44+
45+
---
46+
47+
# 🧪 Labs and Experiments
48+
49+
## Environment Variables and Secrets
50+
51+
Created:
52+
53+
```text
54+
labs/security/secrets-lab/
55+
```
56+
57+
Practiced:
58+
59+
- Storing secrets inside `.env`
60+
- Preventing secret leaks using `.gitignore`
61+
- Using GitHub Secrets inside workflows
62+
63+
---
64+
65+
## Dependency Scanning
66+
67+
Commands:
68+
69+
```bash
70+
npm audit
71+
npm audit fix
72+
```
73+
74+
Experiment:
75+
76+
- Installed an old version of `lodash`
77+
- Observed HIGH severity vulnerabilities
78+
- Learned the risks of forced updates
79+
80+
---
81+
82+
## SAST (Static Application Security Testing)
83+
84+
Tool:
85+
86+
```bash
87+
semgrep
88+
```
89+
90+
Practiced:
91+
92+
- Detecting insecure code patterns
93+
- Understanding static analysis
94+
95+
---
96+
97+
## CodeQL
98+
99+
Integrated GitHub CodeQL scanning.
100+
101+
Observed:
102+
103+
- Detection of clear-text logging
104+
- Detection of SQL Injection risks
105+
- Detection of missing rate limiting on database endpoints
106+
- Security findings inside the GitHub Security tab
107+
108+
Learned:
109+
110+
- Secure code is not only about preventing SQL Injection.
111+
- Security tools analyze data flow between application components.
112+
- API endpoints that access databases should implement rate limiting.
113+
- Security also includes protecting application availability.
114+
115+
---
116+
117+
## OWASP Practice: SQL Injection and Rate Limiting
118+
119+
Created:
120+
121+
```text
122+
labs/security/owasp-lab/
123+
```
124+
125+
Practiced:
126+
127+
- Writing intentionally vulnerable SQL queries
128+
- Detecting SQL Injection using CodeQL
129+
- Fixing vulnerabilities using parameterized queries
130+
- Protecting endpoints with `express-rate-limit`
131+
132+
Vulnerable query:
133+
134+
```javascript
135+
const sql = `SELECT * FROM users WHERE name = '${query}'`;
136+
```
137+
138+
Secure query:
139+
140+
```javascript
141+
const [rows] = await db.execute('SELECT * FROM users WHERE name = ?', [query]);
142+
```
143+
144+
Added rate limiting:
145+
146+
```javascript
147+
const rateLimit = require('express-rate-limit');
148+
149+
const limiter = rateLimit({
150+
windowMs: 15 * 60 * 1000,
151+
max: 100,
152+
});
153+
154+
app.use(limiter);
155+
```
156+
157+
Learned:
158+
159+
- User input should never be directly concatenated into SQL queries.
160+
- Databases should receive queries and parameters separately.
161+
- Public endpoints should implement rate limiting to prevent denial-of-service attacks.
162+
163+
---
164+
165+
## Trivy Container Scanning
166+
167+
Commands:
168+
169+
```bash
170+
trivy image my-first-image
171+
172+
trivy image node:24-slim
173+
```
174+
175+
Learned:
176+
177+
- Containers inherit vulnerabilities from their base images.
178+
- Smaller images reduce the attack surface.
179+
- Security is not only about application code.
180+
181+
---
182+
183+
## Secure CI/CD
184+
185+
Integrated Trivy into GitHub Actions:
186+
187+
```yaml
188+
- name: Scan Docker image with Trivy
189+
uses: aquasecurity/trivy-action@master
190+
```
191+
192+
Configured:
193+
194+
```yaml
195+
severity: CRITICAL
196+
exit-code: 1
197+
```
198+
199+
Result:
200+
201+
- The pipeline automatically failed when critical vulnerabilities were detected.
202+
203+
---
204+
205+
## Branch Protection Rules
206+
207+
Learned how GitHub can enforce security policies by requiring:
208+
209+
- Pull requests
210+
- Passing CI checks
211+
- CodeQL scans
212+
- Trivy scans
213+
214+
---
215+
216+
# 🧠 Key Insights
217+
218+
Security is not a single tool.
219+
220+
Modern DevSecOps combines:
221+
222+
```text
223+
Developer
224+
225+
Secrets Management
226+
227+
Dependency Scanning
228+
229+
SAST
230+
231+
CodeQL
232+
233+
Container Security
234+
235+
Secure CI/CD
236+
237+
Branch Protection
238+
239+
Deployment
240+
```
241+
242+
OWASP provides the security model that connects all of these layers.
243+
244+
---
245+
246+
# 💭 Reflection
247+
248+
Before this checkpoint, I viewed security as individual tools and isolated vulnerabilities.
249+
250+
After completing Phase 4, I understand that modern application security is a chain of defenses that protects code before it reaches production.
251+
252+
I also learned that security is not limited to preventing SQL Injection or protecting secrets. Modern applications must also defend against denial-of-service attacks, insecure dependencies, vulnerable containers, and unsafe deployment pipelines.
253+
254+
---
255+
256+
# 🚀 Phase 4 Complete
257+
258+
Completed:
259+
260+
- ✅ Environment Variables & Secrets Management
261+
- ✅ Dependency Scanning
262+
- ✅ SAST
263+
- ✅ CodeQL
264+
- ✅ Trivy Container Scanning
265+
- ✅ Container Security
266+
- ✅ Secure CI/CD Pipelines
267+
- ✅ OWASP Security Practices
268+
269+
The next step is:
270+
271+
🌐 **Phase 5 — Infrastructure**

0 commit comments

Comments
 (0)