|
| 1 | +# Vibe-Coding Risk Radar — Reference Model |
| 2 | + |
| 3 | +## Tier Calculation |
| 4 | + |
| 5 | +``` |
| 6 | +Tier = max(codeType, language, deployment, data, blastRadius) |
| 7 | +Mapping: max <= 1 → Tier 1, max <= 2 → Tier 2, max <= 3 → Tier 3, max = 4 → Tier 4 |
| 8 | +``` |
| 9 | + |
| 10 | +Tiers are **cumulative**: Tier N includes all mitigations from Tier 1 through N-1. |
| 11 | + |
| 12 | +--- |
| 13 | + |
| 14 | +## Dimensions (each scored 0–4) |
| 15 | + |
| 16 | +### 1. Code Type (`codeType`) |
| 17 | + |
| 18 | +| Score | Level | Examples | |
| 19 | +|-------|-------|---------| |
| 20 | +| 0 | UI / CSS / Docs | Styling, static pages, documentation | |
| 21 | +| 1 | Build Scripts / Tests | CI configs, test files, Makefiles | |
| 22 | +| 2 | Business Logic | Domain services, data processing, validation | |
| 23 | +| 3 | API / DB Queries | REST/GraphQL endpoints, SQL, ORM code | |
| 24 | +| 4 | Auth / Security / Crypto | Authentication, encryption, access control | |
| 25 | + |
| 26 | +### 2. Language Safety (`language`) |
| 27 | + |
| 28 | +| Score | Level | Languages | |
| 29 | +|-------|-------|-----------| |
| 30 | +| 0 | Static + Memory-safe | Rust | |
| 31 | +| 1 | Statically typed | TypeScript, Java, Go, Kotlin, Scala, Swift | |
| 32 | +| 2 | Dynamically typed | Python, JavaScript, Ruby, PHP, Lua, Elixir | |
| 33 | +| 3 | Memory-unsafe managed | C# with `unsafe` blocks | |
| 34 | +| 4 | Memory-unsafe | C, C++, Assembly | |
| 35 | + |
| 36 | +### 3. Deployment Context (`deployment`) |
| 37 | + |
| 38 | +| Score | Level | Examples | |
| 39 | +|-------|-------|---------| |
| 40 | +| 0 | Personal / Prototype | Local tools, learning projects | |
| 41 | +| 1 | Internal tool | Company-internal dashboards, admin tools | |
| 42 | +| 2 | Public-facing app | SaaS, public APIs, mobile apps | |
| 43 | +| 3 | Regulated system | HIPAA, PCI-DSS, SOC2, GDPR-critical | |
| 44 | +| 4 | Safety-critical | Avionics, medical devices, automotive | |
| 45 | + |
| 46 | +### 4. Data Sensitivity (`data`) |
| 47 | + |
| 48 | +| Score | Level | Examples | |
| 49 | +|-------|-------|---------| |
| 50 | +| 0 | Public data | Open datasets, public content | |
| 51 | +| 1 | Internal business data | Revenue figures, internal docs | |
| 52 | +| 2 | General PII | Name, email, phone, address | |
| 53 | +| 3 | Sensitive PII | SSN, biometrics, passport numbers | |
| 54 | +| 4 | PHI / PCI | Medical records (HIPAA), credit cards (PCI) | |
| 55 | + |
| 56 | +### 5. Blast Radius (`blastRadius`) |
| 57 | + |
| 58 | +| Score | Level | Examples | |
| 59 | +|-------|-------|---------| |
| 60 | +| 0 | Cosmetic / Tech debt | UI glitches, code smell | |
| 61 | +| 1 | Performance / DoS | Slowdowns, service unavailability | |
| 62 | +| 2 | Data loss (recoverable) | Lost data restorable from backups | |
| 63 | +| 3 | Systemic breach | Unrecoverable data exposure | |
| 64 | +| 4 | Safety (life & limb) | Physical harm, loss of life | |
| 65 | + |
| 66 | +--- |
| 67 | + |
| 68 | +## Module Detection Strategy |
| 69 | + |
| 70 | +### Phase 1: Workspace Configs (confidence: 0.9) |
| 71 | + |
| 72 | +Check these files for explicit module declarations: |
| 73 | + |
| 74 | +| Config File | Parse Field | Module = | |
| 75 | +|-------------|-------------|----------| |
| 76 | +| `pnpm-workspace.yaml` | `packages:` array | Each resolved glob path | |
| 77 | +| `package.json` (root) | `"workspaces"` field | Each resolved glob path | |
| 78 | +| `lerna.json` | `"packages"` array | Each resolved path | |
| 79 | +| `Cargo.toml` (root) | `[workspace] members` | Each member path | |
| 80 | +| `settings.gradle(.kts)` | `include(...)` | Each subproject dir | |
| 81 | +| `pom.xml` (root) | `<modules>` elements | Each module dir | |
| 82 | +| `go.work` | `use (...)` | Each module dir | |
| 83 | + |
| 84 | +### Phase 2: Conventional Directories (confidence: 0.6–0.8) |
| 85 | + |
| 86 | +| Pattern | Signal | |
| 87 | +|---------|--------| |
| 88 | +| `packages/*/package.json` | JS/TS monorepo packages | |
| 89 | +| `apps/*/` with build config | Application packages | |
| 90 | +| `services/*/Dockerfile` | Microservices | |
| 91 | +| `frontend/` + `backend/` | Client/server split | |
| 92 | +| `src/client/` + `src/server/` | Co-located client/server | |
| 93 | +| `docker-compose.yml` with multiple `build:` | Multi-service | |
| 94 | + |
| 95 | +### Phase 3: Fallback |
| 96 | + |
| 97 | +Entire repository = single module. |
| 98 | + |
| 99 | +--- |
| 100 | + |
| 101 | +## Auto-Detection Grep Patterns |
| 102 | + |
| 103 | +### Code Type Patterns |
| 104 | + |
| 105 | +**Auth/Security/Crypto (codeType=4):** |
| 106 | +``` |
| 107 | +\b(bcrypt|argon2|scrypt|pbkdf2)\b |
| 108 | +\b(jwt|jsonwebtoken|jose)\b |
| 109 | +\b(oauth|openid|oidc|saml|ldap|kerberos)\b |
| 110 | +\b(passport|express-session|cookie-session)\b |
| 111 | +\b(crypto\.create|createCipher|createHash|createSign)\b |
| 112 | +\b(private.?key|secret.?key|api.?secret)\b |
| 113 | +\b(authenticate|authorization|login|signup|signIn|signUp)\b |
| 114 | +\b(csrf|xss|sanitize|helmet)\b |
| 115 | +\b(tls|ssl|certificate|x509)\b |
| 116 | +``` |
| 117 | + |
| 118 | +**API/DB (codeType=3):** |
| 119 | +``` |
| 120 | +\b(app\.(get|post|put|delete|patch|use)\s*\() |
| 121 | +\b(@(Get|Post|Put|Delete|Patch)Mapping) |
| 122 | +\b(@app\.(route|get|post|put|delete)) |
| 123 | +\b(SELECT\s+.+\s+FROM|INSERT\s+INTO|UPDATE\s+.+\s+SET|DELETE\s+FROM) |
| 124 | +\b(prisma|sequelize|typeorm|knex|mongoose|sqlalchemy|ActiveRecord) |
| 125 | +\b(GraphQL|type\s+Query|type\s+Mutation|gql`) |
| 126 | +``` |
| 127 | + |
| 128 | +### Data Sensitivity Patterns |
| 129 | + |
| 130 | +**PHI/PCI (data=4):** |
| 131 | +``` |
| 132 | +\b(hipaa|phi|protected.health|health.record|medical.record)\b |
| 133 | +\b(pci|pci.dss|credit.card|card.number|cvv|cvc)\b |
| 134 | +\b(stripe|braintree|adyen|paypal.sdk)\b |
| 135 | +\b(hl7|fhir|dicom|icd.?10)\b |
| 136 | +``` |
| 137 | + |
| 138 | +**Sensitive PII (data=3):** |
| 139 | +``` |
| 140 | +\b(ssn|social.security.number|social_security)\b |
| 141 | +\b(passport.number|driver.?license|national.?id)\b |
| 142 | +\b(biometric|fingerprint|face.?recognition|iris.?scan)\b |
| 143 | +\b(tax.?id|tin|ein)\b |
| 144 | +``` |
| 145 | + |
| 146 | +**General PII (data=2):** |
| 147 | +``` |
| 148 | +\b(email|first.?name|last.?name|full.?name|phone.?number)\b |
| 149 | +\b(date.?of.?birth|dob|birth.?date|address|zip.?code)\b |
| 150 | +\b(user.?profile|personal.?data|gdpr|consent)\b |
| 151 | +``` |
| 152 | + |
| 153 | +### Deployment/Regulatory Patterns |
| 154 | + |
| 155 | +**Regulated (deployment>=3):** |
| 156 | +``` |
| 157 | +\b(HIPAA|PCI.DSS|SOC.?2|GDPR|FedRAMP|FISMA|NIST)\b |
| 158 | +``` |
| 159 | + |
| 160 | +**Safety-critical (deployment=4):** |
| 161 | +``` |
| 162 | +\b(DO.?178|IEC.?61508|ISO.?26262|EN.?50128)\b |
| 163 | +\b(SIL|DAL|ASIL|safety.?integrity|safety.?critical)\b |
| 164 | +\b(FDA|CE.?marking|medical.?device)\b |
| 165 | +``` |
| 166 | + |
| 167 | +### Language Detection (file extensions) |
| 168 | + |
| 169 | +| Score | Extensions | |
| 170 | +|-------|-----------| |
| 171 | +| 0 | `.rs` | |
| 172 | +| 1 | `.ts`, `.tsx`, `.java`, `.go`, `.kt`, `.kts`, `.scala`, `.swift` | |
| 173 | +| 2 | `.py`, `.js`, `.jsx`, `.rb`, `.php`, `.lua`, `.pl`, `.ex`, `.exs` | |
| 174 | +| 3 | `.cs` (check for `unsafe` keyword → 3, else → 1) | |
| 175 | +| 4 | `.c`, `.h`, `.cpp`, `.cc`, `.cxx`, `.hpp`, `.asm`, `.s` | |
| 176 | + |
| 177 | +--- |
| 178 | + |
| 179 | +## Auto-Detection Confidence Levels |
| 180 | + |
| 181 | +| Dimension | Confidence | User Confirmation Needed? | |
| 182 | +|-----------|-----------|--------------------------| |
| 183 | +| codeType | 0.7–0.85 | Only if score <= 2 | |
| 184 | +| language | 0.85–0.95 | Rarely | |
| 185 | +| deployment | 0.2–0.5 | **Always** | |
| 186 | +| data | 0.5–0.7 | Usually (confirm >= 2) | |
| 187 | +| blastRadius | 0.1–0.3 | **Always** | |
| 188 | + |
| 189 | +--- |
| 190 | + |
| 191 | +## Mitigations per Tier |
| 192 | + |
| 193 | +### Tier 1 — Automated Gates (always active) |
| 194 | + |
| 195 | +| Measure | Type | Tools | |
| 196 | +|---------|------|-------| |
| 197 | +| Linter & Formatter | deterministic | ESLint, Prettier, Ruff, Black | |
| 198 | +| Type Checking | deterministic | TypeScript strict, mypy | |
| 199 | +| Pre-Commit Hooks | deterministic | husky + lint-staged, pre-commit framework | |
| 200 | +| Dependency Check | deterministic | npm audit, pip-audit, cargo audit | |
| 201 | +| CI Build & Unit Tests | deterministic | GitHub Actions, Jenkins, GitLab CI | |
| 202 | + |
| 203 | +**Detection signals for existing mitigations:** |
| 204 | + |
| 205 | +| Measure | Config Files | |
| 206 | +|---------|-------------| |
| 207 | +| Linter | `.eslintrc*`, `ruff.toml`, `.pylintrc`, `lint` script in package.json | |
| 208 | +| Formatter | `.prettierrc*`, `rustfmt.toml`, `black` in pyproject.toml | |
| 209 | +| Type Checking | `tsconfig.json` (strict: true), `mypy.ini`, `[mypy]` in pyproject.toml | |
| 210 | +| Pre-Commit | `.pre-commit-config.yaml`, `.husky/`, `lint-staged` in package.json | |
| 211 | +| Dependency Check | `audit` in CI workflows, `safety` / `pip-audit` in requirements | |
| 212 | +| CI/CD | `.github/workflows/`, `Jenkinsfile`, `.gitlab-ci.yml` | |
| 213 | + |
| 214 | +### Tier 2 — Extended Assurance |
| 215 | + |
| 216 | +| Measure | Type | Tools | |
| 217 | +|---------|------|-------| |
| 218 | +| SAST | deterministic | Semgrep, CodeQL | |
| 219 | +| AI Code Review | probabilistic | CodeRabbit, Copilot Review | |
| 220 | +| Property-Based Tests | probabilistic | fast-check, Hypothesis | |
| 221 | +| SonarQube Quality Gate | deterministic | SonarQube, SonarCloud | |
| 222 | +| Sampling Review (~20%) | organizational | PR review policy | |
| 223 | + |
| 224 | +**Detection signals:** |
| 225 | + |
| 226 | +| Measure | Config Files | |
| 227 | +|---------|-------------| |
| 228 | +| SAST | `semgrep.yml` in CI, `codeql-analysis.yml`, `.semgrep/` | |
| 229 | +| SonarQube | `sonar-project.properties`, sonar step in CI | |
| 230 | +| Property-Based Tests | `fast-check` / `hypothesis` in dependencies | |
| 231 | + |
| 232 | +### Tier 3 — Mandatory Measures for High Risk |
| 233 | + |
| 234 | +| Measure | Type | Tools | |
| 235 | +|---------|------|-------| |
| 236 | +| Mandatory Human Review | organizational | Branch protection rules | |
| 237 | +| Sandbox / Isolation | deterministic | Firecracker, Deno Sandbox | |
| 238 | +| Fuzzing | probabilistic | AFL++, cargo-fuzz, Fuzz4All | |
| 239 | +| Penetration Testing | organizational | Regular security audits | |
| 240 | +| Canary Deployments | deterministic | Gradual rollout + auto-rollback | |
| 241 | +| PromptBOM / Provenance | organizational | Document model, prompt, approver | |
| 242 | + |
| 243 | +**Detection signals:** |
| 244 | + |
| 245 | +| Measure | Config Files | |
| 246 | +|---------|-------------| |
| 247 | +| Branch Protection | Check via `gh api repos/{owner}/{repo}/branches/main/protection` | |
| 248 | +| Fuzzing | `fuzz/` directory, `cargo-fuzz` in deps, AFL config | |
| 249 | + |
| 250 | +### Tier 4 — Critical (Severely Restrict AI Use) |
| 251 | + |
| 252 | +| Measure | Type | Tools | |
| 253 | +|---------|------|-------| |
| 254 | +| Formal Verification | deterministic | Dafny, TLA+, SPARK | |
| 255 | +| Independent Re-Verification | organizational | Separate team (per DO-178C DAL A) | |
| 256 | +| MC/DC Test Coverage | deterministic | Coverage tools with MC/DC support | |
| 257 | +| Contract-Based Design | deterministic | Pre/postconditions + invariants | |
| 258 | +| Certification Process | organizational | IEC 61508, DO-178C, ISO 26262 | |
| 259 | +| AI as Draft Aid Only | organizational | LLM proposes, human implements | |
| 260 | + |
| 261 | +--- |
| 262 | + |
| 263 | +## CLAUDE.md Output Format |
| 264 | + |
| 265 | +### Per-Module Assessment |
| 266 | + |
| 267 | +```markdown |
| 268 | +## Risk Radar Assessment |
| 269 | + |
| 270 | +_Generated by `/risk-assess` on YYYY-MM-DD_ |
| 271 | + |
| 272 | +### Module: {module-name} |
| 273 | +| Dimension | Score | Level | Evidence | |
| 274 | +|-----------|-------|-------|----------| |
| 275 | +| Code Type | N | {level} | {files/patterns found} | |
| 276 | +| Language | N | {level} | {file counts by extension} | |
| 277 | +| Deployment | N | {level} | {config hints or user input} | |
| 278 | +| Data Sensitivity | N | {level} | {patterns found or user input} | |
| 279 | +| Blast Radius | N | {level} | {user input} | |
| 280 | + |
| 281 | +**Tier: N — {label}** (determined by {dimension} = {score}) |
| 282 | +``` |
| 283 | + |
| 284 | +### Per-Module Mitigation Status |
| 285 | + |
| 286 | +```markdown |
| 287 | +### Mitigations: {module-name} (Tier N) |
| 288 | +| Measure | Status | Details | |
| 289 | +|---------|--------|---------| |
| 290 | +| {name} | {status-emoji} {status} | {config file or note} | |
| 291 | +``` |
| 292 | + |
| 293 | +Status values: `Vorhanden/Present`, `Eingerichtet/Set up`, `Ausstehend/Pending`, `N/A` |
0 commit comments