azcodr 1.5.2 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.agents/hooks.json +42 -42
- package/.agents/hooks.json.example +42 -42
- package/.agents/mcp_config.json.example +29 -29
- package/.agents/scripts/safety_guard.sh +143 -34
- package/.agents/scripts/verify_completion.sh +90 -27
- package/.agents/skills/agentic-architect/SKILL.md +125 -125
- package/.agents/skills/agentic-architect/references/agents_md_template.md +62 -62
- package/.agents/skills/agentic-architect/references/refinement_workflow.md +32 -32
- package/.agents/skills/agentic-architect/references/skill_architecture_inquiry.md +63 -63
- package/.agents/skills/agentic-architect/references/skill_template.md +56 -56
- package/.agents/skills/agentic-architect/scripts/validate_agentic_configs.sh +402 -402
- package/.agents/skills/clean-code-refactor/SKILL.md +91 -91
- package/.agents/skills/clean-code-refactor/references/clean_code_smells.md +27 -27
- package/.agents/skills/clean-code-refactor/references/design_patterns_ts.md +65 -65
- package/.agents/skills/compliance-audit/SKILL.md +120 -120
- package/.agents/skills/compliance-audit/references/owasp_top10_controls.md +16 -16
- package/.agents/skills/compliance-audit/references/soc2_iso_controls.md +28 -28
- package/.agents/skills/lets-build/SKILL.md +173 -173
- package/.agents/skills/lets-build/references/architecture_interview_matrix.md +115 -115
- package/.agents/skills/lets-build/references/hexagonal_bootstrap_scaffolds.md +160 -160
- package/.agents/skills/lets-build/references/project_readme_template.md +79 -79
- package/.agents/skills/lets-build/scripts/bootstrap_workspace.sh +419 -255
- package/.agents/skills/product-analyst/SKILL.md +154 -154
- package/.agents/skills/product-analyst/references/backlog_ordering_techniques.md +107 -107
- package/.agents/skills/product-analyst/references/gherkin_patterns.md +46 -46
- package/.agents/skills/product-analyst/references/invest_checklist.md +38 -38
- package/.agents/skills/product-analyst/references/okr_alignment_guide.md +76 -76
- package/.agents/skills/product-analyst/references/smart_tasks.md +59 -59
- package/.agents/skills/relentless-questioner/SKILL.md +128 -128
- package/.agents/skills/relentless-questioner/references/adaptive_question_trees.md +102 -102
- package/.editorconfig +19 -19
- package/.github/workflows/ci.yml +167 -78
- package/.github/workflows/publish.yml +200 -0
- package/.gitignore +40 -25
- package/AGENTS.md +103 -102
- package/LICENSE +21 -21
- package/README.md +168 -165
- package/bin/azcodr.js +14 -228
- package/docs/knowledge/ubiquitous_language.md +31 -18
- package/docs/rules/agentic_configuration.md +259 -259
- package/docs/rules/api_architecture.md +179 -179
- package/docs/rules/authentication.md +76 -76
- package/docs/rules/authorization.md +75 -75
- package/docs/rules/caching.md +69 -69
- package/docs/rules/clean_code.md +62 -62
- package/docs/rules/cloud_native.md +41 -41
- package/docs/rules/cqrs.md +203 -203
- package/docs/rules/database_design.md +125 -125
- package/docs/rules/database_operations.md +69 -69
- package/docs/rules/design_patterns.md +98 -98
- package/docs/rules/devops_ci_cd.md +76 -76
- package/docs/rules/domain_driven_design.md +122 -122
- package/docs/rules/error_handling.md +54 -52
- package/docs/rules/feature_flags.md +59 -59
- package/docs/rules/frontend_architecture.md +157 -157
- package/docs/rules/multitenancy_architecture.md +98 -98
- package/docs/rules/product_ownership.md +127 -127
- package/docs/rules/project_management.md +49 -49
- package/docs/rules/relentless_questioning.md +52 -52
- package/docs/rules/requirements_engineering.md +98 -98
- package/docs/rules/security_compliance.md +53 -53
- package/docs/rules/server_driven_ui.md +88 -88
- package/docs/rules/test_driven_development.md +185 -185
- package/docs/rules/transactional_email.md +27 -27
- package/docs/rules/type_safety.md +65 -65
- package/docs/rules/ui_ux_architecture.md +150 -150
- package/docs/rules/workflow_state_machines.md +117 -117
- package/lib/cli-parse.js +51 -0
- package/lib/cli-target.js +109 -0
- package/lib/cli.js +180 -0
- package/lib/errors.js +28 -0
- package/lib/git.js +29 -0
- package/lib/guards.js +96 -0
- package/lib/index.d.ts +199 -134
- package/lib/index.js +5 -5
- package/lib/links.js +123 -0
- package/lib/permissions.js +44 -0
- package/lib/repo.js +90 -0
- package/lib/scaffold.js +238 -448
- package/memory.md +119 -36
- package/package.json +65 -62
- package/scripts/test_coverage.js +66 -38
- package/scripts/validate/adr.js +151 -0
- package/scripts/validate/io.js +84 -0
- package/scripts/validate/links.js +167 -0
- package/scripts/validate/parity.js +124 -0
- package/scripts/validate/root.js +184 -0
- package/scripts/validate/rules.js +44 -0
- package/scripts/validate/skills.js +96 -0
- package/scripts/validate/text.js +29 -0
- package/scripts/validate-cli.js +13 -0
- package/scripts/validate.js +140 -258
- package/.github/copilot-instructions.md +0 -1
|
@@ -1,91 +1,91 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: clean-code-refactor
|
|
3
|
-
description: Use when refactoring existing code to comply with Clean Code, SOLID principles, Pragmatic Programmer practices, or modern design patterns (Strategy, Adapter, Repository, Result pattern). Do not use when merely creating a new feature from scratch, fixing a minor typo, or writing initial tests.
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# Clean Code & Design Patterns Refactoring Skill
|
|
7
|
-
|
|
8
|
-
> **Core Purpose:** Transform messy, coupled, or rigid code into clean, expressive, and maintainable implementations adhering to Robert C. Martin's Clean Code, The Pragmatic Programmer, and modern Gang of Four patterns without altering external behavior.
|
|
9
|
-
|
|
10
|
-
---
|
|
11
|
-
|
|
12
|
-
## 1. When to Use This Skill
|
|
13
|
-
- During the **REFACTOR** stage of the Outside-In TDD double loop (after tests are green).
|
|
14
|
-
- Resolving code smells: long functions (> 30 lines), large classes, excessive parameter lists (> 3 args), primitive obsession, duplicate domain knowledge.
|
|
15
|
-
- Decoupling 3rd-party dependencies using the **Adapter Pattern**.
|
|
16
|
-
- Replacing complex conditional logic (`switch`/`if-else` cascades) with the **Strategy Pattern**.
|
|
17
|
-
- Eliminating untyped exception throwing with the **Result / Either Pattern**.
|
|
18
|
-
- Removing dead or commented-out code to restore readability.
|
|
19
|
-
|
|
20
|
-
---
|
|
21
|
-
|
|
22
|
-
## 2. Step-by-Step Refactoring Workflow
|
|
23
|
-
|
|
24
|
-
```
|
|
25
|
-
1. Verify Green Tests ──► 2. Identify Code Smells ──► 3. Select Design Pattern ──► 4. Atomic Surgical Edit ──► 5. Verify 100% Green
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
### Step 1: Establish the Test Safety Net
|
|
29
|
-
- Never refactor without passing tests.
|
|
30
|
-
- Confirm all existing unit and acceptance tests pass: workspace test command (e.g. `npm test`, `cargo test`, `go test ./...`, `pytest`).
|
|
31
|
-
- If coverage is missing or incomplete, write tests *before* touching production code.
|
|
32
|
-
|
|
33
|
-
### Step 2: Identify Specific Code Smells
|
|
34
|
-
Target concrete flaws:
|
|
35
|
-
- **Long Method / Violating Single Responsibility**: Extract smaller private helper functions (SLAP principle).
|
|
36
|
-
- **Coupling to 3rd-Party SDK**: Wrap SDK calls inside an application-owned interface (Adapter pattern).
|
|
37
|
-
- **Duplicated Domain Rules**: Consolidate business logic into a single authoritative value object or service (DRY).
|
|
38
|
-
- **Leaky Exceptions**: Convert error throwing across controller/service boundaries into typed `Result<T, E>` unions.
|
|
39
|
-
|
|
40
|
-
### Step 3: Apply the Appropriate Pattern
|
|
41
|
-
- **Adapter**: Define an interface `IEmailAdapter` or `IPaymentAdapter`. Create an implementation wrapping the open-source library.
|
|
42
|
-
- **Strategy**: Define a strategy interface `ITenantPolicy`. Inject the appropriate strategy based on tenant configuration.
|
|
43
|
-
- **Factory**: Centralize instantiation of complex collaborator graphs.
|
|
44
|
-
- **Repository / Data Mapper**: Decouple domain entities from direct ORM queries.
|
|
45
|
-
|
|
46
|
-
### Step 4: Execute Atomic Surgical Edits
|
|
47
|
-
- Make one micro-refactor at a time (e.g. rename a method, extract a class).
|
|
48
|
-
- Maintain existing naming conventions and idiomatic type safety.
|
|
49
|
-
- Ensure zero lint or type errors: workspace linter and compiler (e.g. `npm run lint && npm run typecheck`, `cargo clippy`, `golangci-lint`, `mypy`).
|
|
50
|
-
|
|
51
|
-
### Step 5: Verify Continuous Green State
|
|
52
|
-
- Run tests after every single atomic change
|
|
53
|
-
- Ensure coverage remains at **100.00%**.
|
|
54
|
-
|
|
55
|
-
---
|
|
56
|
-
|
|
57
|
-
## 3. Gotchas & What NOT to Do
|
|
58
|
-
|
|
59
|
-
- **DO NOT** change external functional behavior while refactoring. Refactoring is strictly structural.
|
|
60
|
-
- **DO NOT** refactor without automated tests. A green test suite is non-negotiable.
|
|
61
|
-
- **DO NOT** introduce over-engineering or speculative design patterns for simple, stable code (YAGNI).
|
|
62
|
-
- **DO NOT** mock external 3rd-party types directly in tests; always mock application-owned adapter interfaces.
|
|
63
|
-
- **DO NOT** leave commented-out blocks of old code behind. Clean up completely.
|
|
64
|
-
|
|
65
|
-
---
|
|
66
|
-
|
|
67
|
-
## 4. Structured Output Template
|
|
68
|
-
|
|
69
|
-
```markdown
|
|
70
|
-
### Clean Code Refactoring Summary: [Module / Class Name]
|
|
71
|
-
|
|
72
|
-
1. **Code Smells Identified**:
|
|
73
|
-
- [Smell 1: e.g. Long method in UserController violating Single Responsibility]
|
|
74
|
-
- [Smell 2: e.g. Direct coupling to external Stripe SDK in domain service]
|
|
75
|
-
|
|
76
|
-
2. **Refactoring Steps & Patterns Applied**:
|
|
77
|
-
- Applied **Adapter Pattern**: Extracted `IPaymentAdapter` to isolate Stripe SDK.
|
|
78
|
-
- Applied **SLAP & Extract Function**: Decomposed 60-line handler into three 15-line functions.
|
|
79
|
-
- Applied **Result Pattern**: Replaced generic `throw Error` with typed `Result<Order, OrderError>`.
|
|
80
|
-
|
|
81
|
-
3. **Verification Evidence**:
|
|
82
|
-
- Tests Status: PASS (100.00% statement, branch, and function coverage preserved)
|
|
83
|
-
- Linter Status: PASS (0 ESLint warnings)
|
|
84
|
-
- Typecheck / Compiler: PASS (0 errors)
|
|
85
|
-
```
|
|
86
|
-
|
|
87
|
-
---
|
|
88
|
-
|
|
89
|
-
## 5. Subdirectories & Progressive Resources
|
|
90
|
-
- [references/clean_code_smells.md](./references/clean_code_smells.md): Catalog of code smells and their refactoring cures.
|
|
91
|
-
- [references/design_patterns_ts.md](./references/design_patterns_ts.md): Reference implementations of Adapter, Strategy, and Result patterns (illustrated in TypeScript).
|
|
1
|
+
---
|
|
2
|
+
name: clean-code-refactor
|
|
3
|
+
description: Use when refactoring existing code to comply with Clean Code, SOLID principles, Pragmatic Programmer practices, or modern design patterns (Strategy, Adapter, Repository, Result pattern). Do not use when merely creating a new feature from scratch, fixing a minor typo, or writing initial tests.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Clean Code & Design Patterns Refactoring Skill
|
|
7
|
+
|
|
8
|
+
> **Core Purpose:** Transform messy, coupled, or rigid code into clean, expressive, and maintainable implementations adhering to Robert C. Martin's Clean Code, The Pragmatic Programmer, and modern Gang of Four patterns without altering external behavior.
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## 1. When to Use This Skill
|
|
13
|
+
- During the **REFACTOR** stage of the Outside-In TDD double loop (after tests are green).
|
|
14
|
+
- Resolving code smells: long functions (> 30 lines), large classes, excessive parameter lists (> 3 args), primitive obsession, duplicate domain knowledge.
|
|
15
|
+
- Decoupling 3rd-party dependencies using the **Adapter Pattern**.
|
|
16
|
+
- Replacing complex conditional logic (`switch`/`if-else` cascades) with the **Strategy Pattern**.
|
|
17
|
+
- Eliminating untyped exception throwing with the **Result / Either Pattern**.
|
|
18
|
+
- Removing dead or commented-out code to restore readability.
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## 2. Step-by-Step Refactoring Workflow
|
|
23
|
+
|
|
24
|
+
```
|
|
25
|
+
1. Verify Green Tests ──► 2. Identify Code Smells ──► 3. Select Design Pattern ──► 4. Atomic Surgical Edit ──► 5. Verify 100% Green
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
### Step 1: Establish the Test Safety Net
|
|
29
|
+
- Never refactor without passing tests.
|
|
30
|
+
- Confirm all existing unit and acceptance tests pass: workspace test command (e.g. `npm test`, `cargo test`, `go test ./...`, `pytest`).
|
|
31
|
+
- If coverage is missing or incomplete, write tests *before* touching production code.
|
|
32
|
+
|
|
33
|
+
### Step 2: Identify Specific Code Smells
|
|
34
|
+
Target concrete flaws:
|
|
35
|
+
- **Long Method / Violating Single Responsibility**: Extract smaller private helper functions (SLAP principle).
|
|
36
|
+
- **Coupling to 3rd-Party SDK**: Wrap SDK calls inside an application-owned interface (Adapter pattern).
|
|
37
|
+
- **Duplicated Domain Rules**: Consolidate business logic into a single authoritative value object or service (DRY).
|
|
38
|
+
- **Leaky Exceptions**: Convert error throwing across controller/service boundaries into typed `Result<T, E>` unions.
|
|
39
|
+
|
|
40
|
+
### Step 3: Apply the Appropriate Pattern
|
|
41
|
+
- **Adapter**: Define an interface `IEmailAdapter` or `IPaymentAdapter`. Create an implementation wrapping the open-source library.
|
|
42
|
+
- **Strategy**: Define a strategy interface `ITenantPolicy`. Inject the appropriate strategy based on tenant configuration.
|
|
43
|
+
- **Factory**: Centralize instantiation of complex collaborator graphs.
|
|
44
|
+
- **Repository / Data Mapper**: Decouple domain entities from direct ORM queries.
|
|
45
|
+
|
|
46
|
+
### Step 4: Execute Atomic Surgical Edits
|
|
47
|
+
- Make one micro-refactor at a time (e.g. rename a method, extract a class).
|
|
48
|
+
- Maintain existing naming conventions and idiomatic type safety.
|
|
49
|
+
- Ensure zero lint or type errors: workspace linter and compiler (e.g. `npm run lint && npm run typecheck`, `cargo clippy`, `golangci-lint`, `mypy`).
|
|
50
|
+
|
|
51
|
+
### Step 5: Verify Continuous Green State
|
|
52
|
+
- Run tests after every single atomic change. Use the workspace's own command — do not assume one exists. Verify with the package manifest first (`node -p "JSON.stringify(require('./package.json').scripts)"`); for this template that is `npm test`, with `npm run test:coverage` for the coverage gate.
|
|
53
|
+
- Ensure coverage remains at **100.00%**.
|
|
54
|
+
|
|
55
|
+
---
|
|
56
|
+
|
|
57
|
+
## 3. Gotchas & What NOT to Do
|
|
58
|
+
|
|
59
|
+
- **DO NOT** change external functional behavior while refactoring. Refactoring is strictly structural.
|
|
60
|
+
- **DO NOT** refactor without automated tests. A green test suite is non-negotiable.
|
|
61
|
+
- **DO NOT** introduce over-engineering or speculative design patterns for simple, stable code (YAGNI).
|
|
62
|
+
- **DO NOT** mock external 3rd-party types directly in tests; always mock application-owned adapter interfaces.
|
|
63
|
+
- **DO NOT** leave commented-out blocks of old code behind. Clean up completely.
|
|
64
|
+
|
|
65
|
+
---
|
|
66
|
+
|
|
67
|
+
## 4. Structured Output Template
|
|
68
|
+
|
|
69
|
+
```markdown
|
|
70
|
+
### Clean Code Refactoring Summary: [Module / Class Name]
|
|
71
|
+
|
|
72
|
+
1. **Code Smells Identified**:
|
|
73
|
+
- [Smell 1: e.g. Long method in UserController violating Single Responsibility]
|
|
74
|
+
- [Smell 2: e.g. Direct coupling to external Stripe SDK in domain service]
|
|
75
|
+
|
|
76
|
+
2. **Refactoring Steps & Patterns Applied**:
|
|
77
|
+
- Applied **Adapter Pattern**: Extracted `IPaymentAdapter` to isolate Stripe SDK.
|
|
78
|
+
- Applied **SLAP & Extract Function**: Decomposed 60-line handler into three 15-line functions.
|
|
79
|
+
- Applied **Result Pattern**: Replaced generic `throw Error` with typed `Result<Order, OrderError>`.
|
|
80
|
+
|
|
81
|
+
3. **Verification Evidence**:
|
|
82
|
+
- Tests Status: PASS (100.00% statement, branch, and function coverage preserved)
|
|
83
|
+
- Linter Status: PASS (0 ESLint warnings)
|
|
84
|
+
- Typecheck / Compiler: PASS (0 errors)
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
---
|
|
88
|
+
|
|
89
|
+
## 5. Subdirectories & Progressive Resources
|
|
90
|
+
- [references/clean_code_smells.md](./references/clean_code_smells.md): Catalog of code smells and their refactoring cures.
|
|
91
|
+
- [references/design_patterns_ts.md](./references/design_patterns_ts.md): Reference implementations of Adapter, Strategy, and Result patterns (illustrated in TypeScript).
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
# Code Smells & Refactoring Cures Reference
|
|
2
|
-
|
|
3
|
-
Catalog of common code smells and their remedies in modern TypeScript codebases.
|
|
4
|
-
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
## 1. Bloated Functions (> 25–30 Lines)
|
|
8
|
-
- **Smell**: A single function performs input parsing, business calculation, database persistence, and response formatting.
|
|
9
|
-
- **Cure**: Apply *Extract Function* and *Single Level of Abstraction (SLAP)*. Group lower-level details into descriptive helper functions.
|
|
10
|
-
|
|
11
|
-
---
|
|
12
|
-
|
|
13
|
-
## 2. Deep Conditional Nesting (Arrow Anti-Pattern)
|
|
14
|
-
- **Smell**: 3+ levels of nested `if / else` blocks checking permissions, status, and input validity.
|
|
15
|
-
- **Cure**: Apply *Guard Clauses* (Return Early) or the *Strategy Pattern* for polymorphic behavior.
|
|
16
|
-
|
|
17
|
-
---
|
|
18
|
-
|
|
19
|
-
## 3. Direct 3rd-Party Coupling
|
|
20
|
-
- **Smell**: Domain controllers directly importing external SDKs (e.g. `import Stripe from 'stripe'`).
|
|
21
|
-
- **Cure**: Apply the *Adapter Pattern*. Define an interface `IPaymentGateway` owned by the domain. Create an infrastructure adapter implementing the interface.
|
|
22
|
-
|
|
23
|
-
---
|
|
24
|
-
|
|
25
|
-
## 4. Primitive Obsession & Long Parameter Lists (> 3 Parameters)
|
|
26
|
-
- **Smell**: Methods taking 6 primitive strings and numbers (`createUser(first, last, email, role, phone, tenantId)`).
|
|
27
|
-
- **Cure**: Bundle related fields into a strongly typed DTO or Zod schema (`CreateUserInput`).
|
|
1
|
+
# Code Smells & Refactoring Cures Reference
|
|
2
|
+
|
|
3
|
+
Catalog of common code smells and their remedies in modern TypeScript codebases.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## 1. Bloated Functions (> 25–30 Lines)
|
|
8
|
+
- **Smell**: A single function performs input parsing, business calculation, database persistence, and response formatting.
|
|
9
|
+
- **Cure**: Apply *Extract Function* and *Single Level of Abstraction (SLAP)*. Group lower-level details into descriptive helper functions.
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## 2. Deep Conditional Nesting (Arrow Anti-Pattern)
|
|
14
|
+
- **Smell**: 3+ levels of nested `if / else` blocks checking permissions, status, and input validity.
|
|
15
|
+
- **Cure**: Apply *Guard Clauses* (Return Early) or the *Strategy Pattern* for polymorphic behavior.
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## 3. Direct 3rd-Party Coupling
|
|
20
|
+
- **Smell**: Domain controllers directly importing external SDKs (e.g. `import Stripe from 'stripe'`).
|
|
21
|
+
- **Cure**: Apply the *Adapter Pattern*. Define an interface `IPaymentGateway` owned by the domain. Create an infrastructure adapter implementing the interface.
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
## 4. Primitive Obsession & Long Parameter Lists (> 3 Parameters)
|
|
26
|
+
- **Smell**: Methods taking 6 primitive strings and numbers (`createUser(first, last, email, role, phone, tenantId)`).
|
|
27
|
+
- **Cure**: Bundle related fields into a strongly typed DTO or Zod schema (`CreateUserInput`).
|
|
@@ -1,65 +1,65 @@
|
|
|
1
|
-
# Modern Design Patterns in TypeScript Reference
|
|
2
|
-
|
|
3
|
-
Production implementations of essential design patterns in full-stack TypeScript.
|
|
4
|
-
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
## 1. Adapter Pattern (Dependency Isolation)
|
|
8
|
-
|
|
9
|
-
```typescript
|
|
10
|
-
// 1. Domain Interface (Owned by the application)
|
|
11
|
-
export interface IEmailAdapter {
|
|
12
|
-
send(to: string, subject: string, html: string): Promise<Result<void, Error>>;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
// 2. Open-Source Infrastructure Implementation (e.g. Mailpit/Nodemailer)
|
|
16
|
-
export class NodemailerEmailAdapter implements IEmailAdapter {
|
|
17
|
-
constructor(private readonly transporter: nodemailer.Transporter) {}
|
|
18
|
-
|
|
19
|
-
async send(to: string, subject: string, html: string): Promise<Result<void, Error>> {
|
|
20
|
-
try {
|
|
21
|
-
await this.transporter.sendMail({ to, subject, html });
|
|
22
|
-
return { success: true, value: undefined };
|
|
23
|
-
} catch (error) {
|
|
24
|
-
return { success: false, error: error as Error };
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
---
|
|
31
|
-
|
|
32
|
-
## 2. Strategy Pattern (Runtime Policy Swapping)
|
|
33
|
-
|
|
34
|
-
```typescript
|
|
35
|
-
// 1. Strategy Contract
|
|
36
|
-
export interface ITenantPricingStrategy {
|
|
37
|
-
calculateMonthlyRate(activeSeats: number): number;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
// 2. Concrete Strategies
|
|
41
|
-
export class StandardPricingStrategy implements ITenantPricingStrategy {
|
|
42
|
-
calculateMonthlyRate(activeSeats: number): number {
|
|
43
|
-
return activeSeats * 15;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export class EnterprisePricingStrategy implements ITenantPricingStrategy {
|
|
48
|
-
calculateMonthlyRate(activeSeats: number): number {
|
|
49
|
-
return activeSeats * 10 + 500; // Flat base fee
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
---
|
|
55
|
-
|
|
56
|
-
## 3. Result / Either Pattern (Type-Safe Errors)
|
|
57
|
-
|
|
58
|
-
```typescript
|
|
59
|
-
export type Result<T, E = Error> =
|
|
60
|
-
| { success: true; value: T }
|
|
61
|
-
| { success: false; error: E };
|
|
62
|
-
|
|
63
|
-
export const Ok = <T>(value: T): Result<T, never> => ({ success: true, value });
|
|
64
|
-
export const Err = <E>(error: E): Result<never, E> => ({ success: false, error });
|
|
65
|
-
```
|
|
1
|
+
# Modern Design Patterns in TypeScript Reference
|
|
2
|
+
|
|
3
|
+
Production implementations of essential design patterns in full-stack TypeScript.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## 1. Adapter Pattern (Dependency Isolation)
|
|
8
|
+
|
|
9
|
+
```typescript
|
|
10
|
+
// 1. Domain Interface (Owned by the application)
|
|
11
|
+
export interface IEmailAdapter {
|
|
12
|
+
send(to: string, subject: string, html: string): Promise<Result<void, Error>>;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// 2. Open-Source Infrastructure Implementation (e.g. Mailpit/Nodemailer)
|
|
16
|
+
export class NodemailerEmailAdapter implements IEmailAdapter {
|
|
17
|
+
constructor(private readonly transporter: nodemailer.Transporter) {}
|
|
18
|
+
|
|
19
|
+
async send(to: string, subject: string, html: string): Promise<Result<void, Error>> {
|
|
20
|
+
try {
|
|
21
|
+
await this.transporter.sendMail({ to, subject, html });
|
|
22
|
+
return { success: true, value: undefined };
|
|
23
|
+
} catch (error) {
|
|
24
|
+
return { success: false, error: error as Error };
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
## 2. Strategy Pattern (Runtime Policy Swapping)
|
|
33
|
+
|
|
34
|
+
```typescript
|
|
35
|
+
// 1. Strategy Contract
|
|
36
|
+
export interface ITenantPricingStrategy {
|
|
37
|
+
calculateMonthlyRate(activeSeats: number): number;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// 2. Concrete Strategies
|
|
41
|
+
export class StandardPricingStrategy implements ITenantPricingStrategy {
|
|
42
|
+
calculateMonthlyRate(activeSeats: number): number {
|
|
43
|
+
return activeSeats * 15;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export class EnterprisePricingStrategy implements ITenantPricingStrategy {
|
|
48
|
+
calculateMonthlyRate(activeSeats: number): number {
|
|
49
|
+
return activeSeats * 10 + 500; // Flat base fee
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
---
|
|
55
|
+
|
|
56
|
+
## 3. Result / Either Pattern (Type-Safe Errors)
|
|
57
|
+
|
|
58
|
+
```typescript
|
|
59
|
+
export type Result<T, E = Error> =
|
|
60
|
+
| { success: true; value: T }
|
|
61
|
+
| { success: false; error: E };
|
|
62
|
+
|
|
63
|
+
export const Ok = <T>(value: T): Result<T, never> => ({ success: true, value });
|
|
64
|
+
export const Err = <E>(error: E): Result<never, E> => ({ success: false, error });
|
|
65
|
+
```
|
|
@@ -1,120 +1,120 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: compliance-audit
|
|
3
|
-
description: Use when conducting a security, compliance, or vulnerability audit against SOC 2 Type II, ISO/IEC 27001, or OWASP Top 10 controls using open-source scanners (Trivy, Semgrep, Gitleaks, Steampipe, Syft, Grype). Do not use for writing application business logic or routine test authoring.
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# Compliance & Security Audit Skill (100% Open-Source)
|
|
7
|
-
|
|
8
|
-
> **Core Purpose:** Execute systematic compliance and vulnerability evaluations against SOC 2 Type II Trust Services Criteria, ISO/IEC 27001 ISMS standards, and the OWASP Top 10 using exclusively open-source security toolchains.
|
|
9
|
-
|
|
10
|
-
---
|
|
11
|
-
|
|
12
|
-
## 1. When to Use This Skill
|
|
13
|
-
- Preparing for or validating SOC 2 Type II readiness (access controls, tamper-evident audit logging, encryption).
|
|
14
|
-
- Verifying ISO/IEC 27001 Annex A technical security controls.
|
|
15
|
-
- Running comprehensive static analysis and vulnerability scans before a production release.
|
|
16
|
-
- Generating software bill of materials (SBOM) and container vulnerability reports.
|
|
17
|
-
- Reviewing sensitive data handling and GDPR/privacy erasure compliance.
|
|
18
|
-
|
|
19
|
-
---
|
|
20
|
-
|
|
21
|
-
## 2. Step-by-Step Audit Workflow
|
|
22
|
-
|
|
23
|
-
```
|
|
24
|
-
1. Secrets & Credentials ──► 2. SAST Analysis ──► 3. Dependency CVEs ──► 4. Architecture & Access ──► 5. Audit Report
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
### Step 1: Secret & Credential Scan (Open-Source)
|
|
28
|
-
Run open-source secret scanners to verify zero committed keys, tokens, or credentials:
|
|
29
|
-
```bash
|
|
30
|
-
# Using open-source Gitleaks
|
|
31
|
-
gitleaks detect --source . -v
|
|
32
|
-
# Using open-source Secretlint
|
|
33
|
-
npx secretlint "**/*"
|
|
34
|
-
```
|
|
35
|
-
*Pass Criteria:* 0 detected secrets or private keys in git history and working tree.
|
|
36
|
-
|
|
37
|
-
### Step 2: Static Application Security Testing (SAST)
|
|
38
|
-
Run open-source `semgrep` with security rulesets to detect injection flaws, insecure deserialization, and dangerous sinks:
|
|
39
|
-
```bash
|
|
40
|
-
semgrep --config p/security-audit --config p/owasp-top-ten .
|
|
41
|
-
```
|
|
42
|
-
*Pass Criteria:* 0 High or Critical vulnerabilities.
|
|
43
|
-
|
|
44
|
-
### Step 3: Dependency & Container Vulnerability Scan
|
|
45
|
-
Run open-source `trivy` and `grype` to audit lockfiles and containers for known CVEs:
|
|
46
|
-
```bash
|
|
47
|
-
# Filesystem CVE scan via Trivy
|
|
48
|
-
trivy fs --severity HIGH,CRITICAL --scanners vuln,misconfig .
|
|
49
|
-
# Generate CycloneDX SBOM via Syft
|
|
50
|
-
syft dir:. -o cyclonedx-json=bom.json
|
|
51
|
-
# Scan SBOM via Grype
|
|
52
|
-
grype sbom:bom.json
|
|
53
|
-
```
|
|
54
|
-
*Pass Criteria:* 0 unpatched Critical or High CVEs in production dependencies.
|
|
55
|
-
|
|
56
|
-
### Step 4: SOC 2 & ISO 27001 Control Verification
|
|
57
|
-
Audit architectural implementation against compliance baselines:
|
|
58
|
-
- **Audit Logging (CC7.2 / A.12)**: Are all state mutations logged with `{ timestamp, actorId, tenantId, action, entityType, entityId, ipAddress, userAgent, changes: { before, after } }`? Are audit logs write-only and tamper-evident?
|
|
59
|
-
- **Access Control & RBAC (CC6.1 / A.9)**: Are built-in roles protected against mutation (`403 Forbidden`)? Is tenant isolation enforced on every query (`tenantId` predicate)?
|
|
60
|
-
- **Cryptography (CC6.6 / A.10)**: Is TLS 1.3 enforced? Are passwords hashed using Argon2id or bcrypt? Is AES-256-GCM used for sensitive data at rest?
|
|
61
|
-
- **Data Erasure & GDPR**: Does the tenant deletion endpoint cascade purge or pseudonymize user PII across all entities?
|
|
62
|
-
|
|
63
|
-
---
|
|
64
|
-
|
|
65
|
-
## 3. Gotchas & What NOT to Do
|
|
66
|
-
|
|
67
|
-
- **DO NOT** use proprietary cloud security scanners when open-source equivalents exist (`trivy`, `semgrep`, `gitleaks`, `syft`, `grype`).
|
|
68
|
-
- **DO NOT** ignore medium/low secrets warnings if they indicate staging credentials or API endpoints.
|
|
69
|
-
- **DO NOT** pass an audit if audit logs lack the `actorId` or `tenantId`. Traceability is a mandatory SOC 2 requirement.
|
|
70
|
-
- **DO NOT** accept raw SQL concatenation anywhere in the codebase. All queries must be parameterized.
|
|
71
|
-
- **DO NOT** recommend disabling security checks or silencing scanner rules without a documented ADR exception in `memory.md`.
|
|
72
|
-
|
|
73
|
-
---
|
|
74
|
-
|
|
75
|
-
## 4. Structured Audit Output Template
|
|
76
|
-
|
|
77
|
-
```markdown
|
|
78
|
-
# Security & Compliance Audit Report
|
|
79
|
-
|
|
80
|
-
- **Date:** [YYYY-MM-DD]
|
|
81
|
-
- **Auditor:** AI Assistant (Compliance Audit Skill)
|
|
82
|
-
- **Frameworks Evaluated:** SOC 2 Type II, ISO/IEC 27001, OWASP Top 10
|
|
83
|
-
|
|
84
|
-
---
|
|
85
|
-
|
|
86
|
-
## 1. Executive Summary
|
|
87
|
-
- **Overall Status:** [PASS / CONDITIONAL PASS / FAIL]
|
|
88
|
-
- **Critical Issues:** [Count]
|
|
89
|
-
- **High Issues:** [Count]
|
|
90
|
-
|
|
91
|
-
---
|
|
92
|
-
|
|
93
|
-
## 2. Open-Source Tool Execution Evidence
|
|
94
|
-
| Tool | Target | Status | Findings |
|
|
95
|
-
|---|---|---|---|
|
|
96
|
-
| `gitleaks` | Git Tree | PASS | 0 secrets found |
|
|
97
|
-
| `semgrep` | Source Code | PASS | 0 critical SAST flaws |
|
|
98
|
-
| `trivy` | Dependencies | PASS | 0 high/critical CVEs |
|
|
99
|
-
|
|
100
|
-
---
|
|
101
|
-
|
|
102
|
-
## 3. Compliance Control Evaluation Matrix
|
|
103
|
-
| Framework | Control ID | Control Description | Status | Evidence / Notes |
|
|
104
|
-
|---|---|---|---|---|
|
|
105
|
-
| **SOC 2** | CC6.1 | Least-privilege RBAC & tenant isolation | PASS | Scoped database queries / RLS |
|
|
106
|
-
| **SOC 2** | CC7.2 | Tamper-evident mutation audit logging | PASS | Audit table with actor tracing |
|
|
107
|
-
| **ISO 27001** | A.10.1 | Cryptographic controls (AES-256, TLS 1.3) | PASS | TLS 1.3 configured, Argon2id auth |
|
|
108
|
-
| **OWASP** | A01 | Broken Access Control checks | PASS | Server-side guards on all routes |
|
|
109
|
-
|
|
110
|
-
---
|
|
111
|
-
|
|
112
|
-
## 4. Required Remediation Actions
|
|
113
|
-
1. [Action item #1 with assigned file and timeline]
|
|
114
|
-
```
|
|
115
|
-
|
|
116
|
-
---
|
|
117
|
-
|
|
118
|
-
## 5. Subdirectories & Progressive Resources
|
|
119
|
-
- [references/soc2_iso_controls.md](./references/soc2_iso_controls.md): Detailed mapping of SOC 2 Trust Services Criteria and ISO 27001 Annex A controls.
|
|
120
|
-
- [references/owasp_top10_controls.md](./references/owasp_top10_controls.md): OWASP Top 10 verification checklist and remediation patterns.
|
|
1
|
+
---
|
|
2
|
+
name: compliance-audit
|
|
3
|
+
description: Use when conducting a security, compliance, or vulnerability audit against SOC 2 Type II, ISO/IEC 27001, or OWASP Top 10 controls using open-source scanners (Trivy, Semgrep, Gitleaks, Steampipe, Syft, Grype). Do not use for writing application business logic or routine test authoring.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Compliance & Security Audit Skill (100% Open-Source)
|
|
7
|
+
|
|
8
|
+
> **Core Purpose:** Execute systematic compliance and vulnerability evaluations against SOC 2 Type II Trust Services Criteria, ISO/IEC 27001 ISMS standards, and the OWASP Top 10 using exclusively open-source security toolchains.
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## 1. When to Use This Skill
|
|
13
|
+
- Preparing for or validating SOC 2 Type II readiness (access controls, tamper-evident audit logging, encryption).
|
|
14
|
+
- Verifying ISO/IEC 27001 Annex A technical security controls.
|
|
15
|
+
- Running comprehensive static analysis and vulnerability scans before a production release.
|
|
16
|
+
- Generating software bill of materials (SBOM) and container vulnerability reports.
|
|
17
|
+
- Reviewing sensitive data handling and GDPR/privacy erasure compliance.
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## 2. Step-by-Step Audit Workflow
|
|
22
|
+
|
|
23
|
+
```
|
|
24
|
+
1. Secrets & Credentials ──► 2. SAST Analysis ──► 3. Dependency CVEs ──► 4. Architecture & Access ──► 5. Audit Report
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### Step 1: Secret & Credential Scan (Open-Source)
|
|
28
|
+
Run open-source secret scanners to verify zero committed keys, tokens, or credentials:
|
|
29
|
+
```bash
|
|
30
|
+
# Using open-source Gitleaks
|
|
31
|
+
gitleaks detect --source . -v
|
|
32
|
+
# Using open-source Secretlint
|
|
33
|
+
npx secretlint "**/*"
|
|
34
|
+
```
|
|
35
|
+
*Pass Criteria:* 0 detected secrets or private keys in git history and working tree.
|
|
36
|
+
|
|
37
|
+
### Step 2: Static Application Security Testing (SAST)
|
|
38
|
+
Run open-source `semgrep` with security rulesets to detect injection flaws, insecure deserialization, and dangerous sinks:
|
|
39
|
+
```bash
|
|
40
|
+
semgrep --config p/security-audit --config p/owasp-top-ten .
|
|
41
|
+
```
|
|
42
|
+
*Pass Criteria:* 0 High or Critical vulnerabilities.
|
|
43
|
+
|
|
44
|
+
### Step 3: Dependency & Container Vulnerability Scan
|
|
45
|
+
Run open-source `trivy` and `grype` to audit lockfiles and containers for known CVEs:
|
|
46
|
+
```bash
|
|
47
|
+
# Filesystem CVE scan via Trivy
|
|
48
|
+
trivy fs --severity HIGH,CRITICAL --scanners vuln,misconfig .
|
|
49
|
+
# Generate CycloneDX SBOM via Syft
|
|
50
|
+
syft dir:. -o cyclonedx-json=bom.json
|
|
51
|
+
# Scan SBOM via Grype
|
|
52
|
+
grype sbom:bom.json
|
|
53
|
+
```
|
|
54
|
+
*Pass Criteria:* 0 unpatched Critical or High CVEs in production dependencies.
|
|
55
|
+
|
|
56
|
+
### Step 4: SOC 2 & ISO 27001 Control Verification
|
|
57
|
+
Audit architectural implementation against compliance baselines:
|
|
58
|
+
- **Audit Logging (CC7.2 / A.12)**: Are all state mutations logged with `{ timestamp, actorId, tenantId, action, entityType, entityId, ipAddress, userAgent, changes: { before, after } }`? Are audit logs write-only and tamper-evident?
|
|
59
|
+
- **Access Control & RBAC (CC6.1 / A.9)**: Are built-in roles protected against mutation (`403 Forbidden`)? Is tenant isolation enforced on every query (`tenantId` predicate)?
|
|
60
|
+
- **Cryptography (CC6.6 / A.10)**: Is TLS 1.3 enforced? Are passwords hashed using Argon2id or bcrypt? Is AES-256-GCM used for sensitive data at rest?
|
|
61
|
+
- **Data Erasure & GDPR**: Does the tenant deletion endpoint cascade purge or pseudonymize user PII across all entities?
|
|
62
|
+
|
|
63
|
+
---
|
|
64
|
+
|
|
65
|
+
## 3. Gotchas & What NOT to Do
|
|
66
|
+
|
|
67
|
+
- **DO NOT** use proprietary cloud security scanners when open-source equivalents exist (`trivy`, `semgrep`, `gitleaks`, `syft`, `grype`).
|
|
68
|
+
- **DO NOT** ignore medium/low secrets warnings if they indicate staging credentials or API endpoints.
|
|
69
|
+
- **DO NOT** pass an audit if audit logs lack the `actorId` or `tenantId`. Traceability is a mandatory SOC 2 requirement.
|
|
70
|
+
- **DO NOT** accept raw SQL concatenation anywhere in the codebase. All queries must be parameterized.
|
|
71
|
+
- **DO NOT** recommend disabling security checks or silencing scanner rules without a documented ADR exception in `memory.md`.
|
|
72
|
+
|
|
73
|
+
---
|
|
74
|
+
|
|
75
|
+
## 4. Structured Audit Output Template
|
|
76
|
+
|
|
77
|
+
```markdown
|
|
78
|
+
# Security & Compliance Audit Report
|
|
79
|
+
|
|
80
|
+
- **Date:** [YYYY-MM-DD]
|
|
81
|
+
- **Auditor:** AI Assistant (Compliance Audit Skill)
|
|
82
|
+
- **Frameworks Evaluated:** SOC 2 Type II, ISO/IEC 27001, OWASP Top 10
|
|
83
|
+
|
|
84
|
+
---
|
|
85
|
+
|
|
86
|
+
## 1. Executive Summary
|
|
87
|
+
- **Overall Status:** [PASS / CONDITIONAL PASS / FAIL]
|
|
88
|
+
- **Critical Issues:** [Count]
|
|
89
|
+
- **High Issues:** [Count]
|
|
90
|
+
|
|
91
|
+
---
|
|
92
|
+
|
|
93
|
+
## 2. Open-Source Tool Execution Evidence
|
|
94
|
+
| Tool | Target | Status | Findings |
|
|
95
|
+
|---|---|---|---|
|
|
96
|
+
| `gitleaks` | Git Tree | PASS | 0 secrets found |
|
|
97
|
+
| `semgrep` | Source Code | PASS | 0 critical SAST flaws |
|
|
98
|
+
| `trivy` | Dependencies | PASS | 0 high/critical CVEs |
|
|
99
|
+
|
|
100
|
+
---
|
|
101
|
+
|
|
102
|
+
## 3. Compliance Control Evaluation Matrix
|
|
103
|
+
| Framework | Control ID | Control Description | Status | Evidence / Notes |
|
|
104
|
+
|---|---|---|---|---|
|
|
105
|
+
| **SOC 2** | CC6.1 | Least-privilege RBAC & tenant isolation | PASS | Scoped database queries / RLS |
|
|
106
|
+
| **SOC 2** | CC7.2 | Tamper-evident mutation audit logging | PASS | Audit table with actor tracing |
|
|
107
|
+
| **ISO 27001** | A.10.1 | Cryptographic controls (AES-256, TLS 1.3) | PASS | TLS 1.3 configured, Argon2id auth |
|
|
108
|
+
| **OWASP** | A01 | Broken Access Control checks | PASS | Server-side guards on all routes |
|
|
109
|
+
|
|
110
|
+
---
|
|
111
|
+
|
|
112
|
+
## 4. Required Remediation Actions
|
|
113
|
+
1. [Action item #1 with assigned file and timeline]
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
---
|
|
117
|
+
|
|
118
|
+
## 5. Subdirectories & Progressive Resources
|
|
119
|
+
- [references/soc2_iso_controls.md](./references/soc2_iso_controls.md): Detailed mapping of SOC 2 Trust Services Criteria and ISO 27001 Annex A controls.
|
|
120
|
+
- [references/owasp_top10_controls.md](./references/owasp_top10_controls.md): OWASP Top 10 verification checklist and remediation patterns.
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
# OWASP Top 10 Verification Reference
|
|
2
|
-
|
|
3
|
-
Verification guidelines for evaluating codebase resistance against the OWASP Top 10 vulnerabilities.
|
|
4
|
-
|
|
5
|
-
| Vulnerability | Verification Target | Required Implementation Pattern |
|
|
6
|
-
|---|---|---|
|
|
7
|
-
| **A01: Broken Access Control** | Controllers, Route Guards | Server-side role and tenant checks on every endpoint. No client-only route security. |
|
|
8
|
-
| **A02: Cryptographic Failures** | Config, Auth Services | TLS 1.3, Argon2id/Bcrypt for passwords, AES-256-GCM for sensitive fields. No custom hashing. |
|
|
9
|
-
| **A03: Injection** | Database queries, OS calls | Parameterized Prisma queries; prohibit string template concatenation in SQL; avoid `child_process.exec`. |
|
|
10
|
-
| **A04: Insecure Design** | Architectural Flows | Rate-limiting on public/auth routes via Redis; defense-in-depth threat modeling. |
|
|
11
|
-
| **A05: Security Misconfig** | HTTP Headers, Errors | Helmet headers (`CSP`, `HSTS`, `nosniff`); mask stack traces via Standard Error Envelope. |
|
|
12
|
-
| **A06: Vulnerable Components** | Dependencies | Zero high/critical CVEs in `npm audit` / `trivy fs .`; lockfiles committed and verified. |
|
|
13
|
-
| **A07: Auth Failures** | Auth Controller, JWT | In-memory access tokens, HttpOnly refresh cookies, instant Redis JTI blocklisting. |
|
|
14
|
-
| **A08: Software Integrity** | CI/CD, Dependencies | Lockfile SHA-512 hashes enforced; open-source `cosign` container signing. |
|
|
15
|
-
| **A09: Logging Failures** | Logging, Middleware | Structured JSON logs (`pino`) with `x-request-id`; zero credentials or PII in logs. |
|
|
16
|
-
| **A10: SSRF** | Outbound HTTP Clients | Block outbound requests to internal/private IPs (`127.0.0.1`, `10.0.0.0/8`, `169.254.169.254`). |
|
|
1
|
+
# OWASP Top 10 Verification Reference
|
|
2
|
+
|
|
3
|
+
Verification guidelines for evaluating codebase resistance against the OWASP Top 10 vulnerabilities.
|
|
4
|
+
|
|
5
|
+
| Vulnerability | Verification Target | Required Implementation Pattern |
|
|
6
|
+
|---|---|---|
|
|
7
|
+
| **A01: Broken Access Control** | Controllers, Route Guards | Server-side role and tenant checks on every endpoint. No client-only route security. |
|
|
8
|
+
| **A02: Cryptographic Failures** | Config, Auth Services | TLS 1.3, Argon2id/Bcrypt for passwords, AES-256-GCM for sensitive fields. No custom hashing. |
|
|
9
|
+
| **A03: Injection** | Database queries, OS calls | Parameterized Prisma queries; prohibit string template concatenation in SQL; avoid `child_process.exec`. |
|
|
10
|
+
| **A04: Insecure Design** | Architectural Flows | Rate-limiting on public/auth routes via Redis; defense-in-depth threat modeling. |
|
|
11
|
+
| **A05: Security Misconfig** | HTTP Headers, Errors | Helmet headers (`CSP`, `HSTS`, `nosniff`); mask stack traces via Standard Error Envelope. |
|
|
12
|
+
| **A06: Vulnerable Components** | Dependencies | Zero high/critical CVEs in `npm audit` / `trivy fs .`; lockfiles committed and verified. |
|
|
13
|
+
| **A07: Auth Failures** | Auth Controller, JWT | In-memory access tokens, HttpOnly refresh cookies, instant Redis JTI blocklisting. |
|
|
14
|
+
| **A08: Software Integrity** | CI/CD, Dependencies | Lockfile SHA-512 hashes enforced; open-source `cosign` container signing. |
|
|
15
|
+
| **A09: Logging Failures** | Logging, Middleware | Structured JSON logs (`pino`) with `x-request-id`; zero credentials or PII in logs. |
|
|
16
|
+
| **A10: SSRF** | Outbound HTTP Clients | Block outbound requests to internal/private IPs (`127.0.0.1`, `10.0.0.0/8`, `169.254.169.254`). |
|