1212<div align =" center " >
1313
1414[ ![ Security Scan] ( https://github.com/Bulletdev/prostaff-api/actions/workflows/security-scan.yml/badge.svg )] ( https://github.com/Bulletdev/prostaff-api/actions/workflows/security-scan.yml )
15+ [ ![ CodeQL] ( https://github.com/Bulletdev/prostaff-api/actions/workflows/codeql.yml/badge.svg )] ( https://github.com/Bulletdev/prostaff-api/actions/workflows/codeql.yml )
1516[ ![ Codacy Badge] ( https://app.codacy.com/project/badge/Grade/30bf4e093ece4ceb8ea46dbe7aecdee1 )] ( https://app.codacy.com/gh/Bulletdev/prostaff-api/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade )
1617[ ![ FOSSA Status] ( https://app.fossa.com/api/projects/git%2Bgithub.com%2FBulletdev%2Fprostaff-api.svg?type=shield&issueType=license )] ( https://app.fossa.com/projects/git%2Bgithub.com%2FBulletdev%2Fprostaff-api?ref=badge_shield&issueType=license )
1718
5960│ [■] Global Search — Meilisearch full-text search across models │
6061│ [■] Real-time Messaging — Action Cable WebSocket team chat │
6162│ [■] Background Jobs — Sidekiq for async background processing │
62- │ [■] Security Hardened — OWASP Top 10, Brakeman, ZAP tested │
63+ │ [■] Security Hardened — OWASP Top 10, Brakeman, Semgrep, CodeQL, ZAP│
64+ │ [■] Rate Limiting — Rack::Attack: 5 rules + Retry-After headers │
6365│ [■] High Performance — p95: ~500ms · cached: ~50ms │
6466│ [■] Modular Monolith — Scalable modular architecture │
6567│ [■] Observability — /health/live + /health/ready + Sidekiq mon. │
8789│ 09 · Security │
8890│ 10 · Observability & Monitoring │
8991│ 11 · Deployment │
90- │ 12 · CI/CD │
92+ │ 12 · CI/CD & CodeQL │
9193│ 13 · Contributing │
9294│ 14 · License │
9395└──────────────────────────────────────────────────────┘
@@ -931,32 +933,59 @@ open coverage/index.html
931933
932934## 09 · Security
933935
934- ### Security Testing (OWASP)
936+ ### Security Testing
935937
936938``` bash
937939# Complete security audit
938940./security_tests/scripts/full-security-audit.sh
939941
940- # Individual scans
941- ./security_tests/scripts/brakeman-scan.sh # Code analysis
942- ./security_tests/scripts/dependency-scan.sh # Vulnerable gems
943- ./security_tests/scripts/zap-baseline-scan.sh # Web app scan
942+ # SAST — code + dependency analysis
943+ ./security_tests/scripts/brakeman-scan.sh # Rails-specific SAST
944+ ./security_tests/scripts/dependency-scan.sh # Vulnerable gems (bundle-audit)
945+
946+ # DAST — runtime scanning
947+ ./security_tests/scripts/zap-baseline-scan.sh # OWASP ZAP baseline
948+ ./security_tests/scripts/zap-api-scan.sh # ZAP API scan (OpenAPI)
949+
950+ # Application-specific tests
951+ ./security_tests/scripts/test-multi-tenancy-isolation.sh # cross-org data leakage
952+ ./security_tests/scripts/test-ssrf-protection.sh # SSRF in Riot API URLs
953+ ./security_tests/scripts/test-rate-limiting.sh # Rack::Attack throttle rules
954+ ./security_tests/scripts/test-timing-oracle.sh # user enumeration via timing
955+ ./security_tests/scripts/test-body-fuzzing.sh # mass assignment + type confusion
944956```
945957
946958```
947959[✓] OWASP Top 10
948- [✓] Code security (Brakeman)
949- [✓] Dependency vulnerabilities
950- [✓] Runtime security (ZAP)
951- [✓] CI/CD integration
960+ [✓] SAST: Brakeman (Rails) + Semgrep + CodeQL (security-extended)
961+ [✓] Dependency audit: bundle-audit + FOSSA
962+ [✓] Secrets: TruffleHog (verified secrets, full git history)
963+ [✓] DAST: OWASP ZAP baseline + API scan
964+ [✓] Multi-tenancy isolation (cross-org IDOR)
965+ [✓] Rate limiting: Rack::Attack rules validated (5 throttle rules)
966+ [✓] Timing oracle: login/register user enumeration
967+ [✓] Mass assignment: StrongParameters coverage
968+ [✓] CI/CD: security gates on every push + weekly CodeQL
952969```
953970
954971### Security Status
955972
956- ** Last Audit** : 2026-03-04
957- ** Overall Grade** : A (26/27 tests passed - 96% )
973+ ** Last Audit** : 2026-03-11
974+ ** Overall Grade** : A (all application security tests passing )
958975** Status** : Production-ready
959976
977+ ### Rate Limiting (Rack::Attack)
978+
979+ | Rule | Limit | Window |
980+ | ------| -------| --------|
981+ | ` logins/ip ` | 5 requests | 20 seconds |
982+ | ` register/ip ` | 3 requests | 1 hour |
983+ | ` password_reset/ip ` | 5 requests | 1 hour |
984+ | ` req/ip ` | 300 requests (configurable) | per period |
985+ | ` req/authenticated_user ` | 1000 requests | 1 hour |
986+
987+ All 429 responses include a ` Retry-After ` header with the exact seconds until the window resets.
988+
960989### Reporting Vulnerabilities
961990
962991We take security seriously. If you discover a security vulnerability, please follow our [ Security Policy] ( SECURITY.md ) .
@@ -968,9 +997,7 @@ We take security seriously. If you discover a security vulnerability, please fol
968997### Security Resources
969998
970999- [ Security Policy] ( SECURITY.md ) - Vulnerability disclosure process
971- - [ Security Test Results] ( .pentest/SECURITY-TEST-RESULTS.md ) - Latest audit results
9721000- [ Security Testing Guide] ( security_tests/README.md ) - Running security tests
973- - [ CI/CD Security Workflow] ( .github/workflows/README.md ) - Automated security scanning
9741001
9751002---
9761003
@@ -1176,6 +1203,32 @@ docker run -p 3333:3000 prostaff-api
11761203
11771204## 12 · CI/CD
11781205
1206+ ### CI/CD Workflows
1207+
1208+ | Workflow | Trigger | What it does |
1209+ | ----------| ---------| -------------|
1210+ | ` security-scan.yml ` | Push / PR to master | Brakeman, Bundle Audit, Semgrep, TruffleHog, SSRF + auth + SQLi runtime tests |
1211+ | ` codeql.yml ` | Push / PR to master + Saturdays 3am | CodeQL ` security-extended ` on Ruby + Actions workflows; SARIF to GitHub Security tab |
1212+ | ` nightly-security.yml ` | Manual dispatch | Full audit: Brakeman + Bundle Audit + ZAP baseline + ZAP API scan |
1213+ | ` load-test.yml ` | Nightly + manual | k6 smoke/load/stress tests |
1214+ | ` deploy-production.yml ` | Push to master | Build, test, deploy to Coolify + CORS smoke test post-deploy |
1215+ | ` deploy-staging.yml ` | Push to develop | Same pipeline targeting staging |
1216+ | ` update-architecture-diagram.yml ` | Changes in ` app/ ` , ` config/routes.rb ` , ` Gemfile ` | Auto-regenerates Mermaid diagram and commits |
1217+
1218+ ### CodeQL Analysis
1219+
1220+ CodeQL runs as a complementary SAST engine alongside Brakeman and Semgrep, covering different vulnerability classes:
1221+
1222+ - SQL injection patterns outside standard ActiveRecord usage
1223+ - Path traversal in file operations
1224+ - SSRF in custom HTTP clients
1225+ - Code injection via ` eval ` / ` send ` with unsanitized input
1226+ - ReDoS (regex denial of service)
1227+
1228+ Results are published to the ** GitHub Security tab** in SARIF format.
1229+
1230+ Config: ` .github/codeql/codeql-config.yml ` — analysis scoped to ` app/ ` , ` lib/ ` , ` config/ ` (excludes vendor, tests, scripts).
1231+
11791232### Architecture Diagram Auto-Update
11801233
11811234```
@@ -1199,15 +1252,7 @@ docker run -p 3333:3000 prostaff-api
11991252ruby scripts/update_architecture_diagram.rb
12001253```
12011254
1202- ### CI/CD Workflows
1203-
1204- Automated testing on every push:
1205- - ** Security Scan** : Brakeman + dependency check
1206- - ** Load Test** : Nightly smoke tests
1207- - ** Nightly Audit** : Complete security scan
1208- - ** CORS Smoke Test** : Runs after every production deploy — sends a preflight request from each allowed origin and fails the pipeline if CORS is misconfigured
1209-
1210- See ` .github/workflows/ ` for details.
1255+ See ` .github/workflows/ ` for full workflow sources.
12111256
12121257---
12131258
0 commit comments