@ryuenn3123/agentic-senior-core 1.8.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/.agent-context/blueprints/api-nextjs.md +184 -0
- package/.agent-context/blueprints/aspnet-api.md +247 -0
- package/.agent-context/blueprints/ci-github-actions.md +226 -0
- package/.agent-context/blueprints/ci-gitlab.md +200 -0
- package/.agent-context/blueprints/fastapi-service.md +210 -0
- package/.agent-context/blueprints/go-service.md +217 -0
- package/.agent-context/blueprints/graphql-grpc-api.md +51 -0
- package/.agent-context/blueprints/infrastructure-as-code.md +62 -0
- package/.agent-context/blueprints/kubernetes-manifests.md +76 -0
- package/.agent-context/blueprints/laravel-api.md +223 -0
- package/.agent-context/blueprints/nestjs-logic.md +247 -0
- package/.agent-context/blueprints/observability.md +227 -0
- package/.agent-context/blueprints/spring-boot-api.md +218 -0
- package/.agent-context/policies/llm-judge-threshold.json +20 -0
- package/.agent-context/profiles/platform.md +13 -0
- package/.agent-context/profiles/regulated.md +13 -0
- package/.agent-context/profiles/startup.md +13 -0
- package/.agent-context/prompts/init-project.md +86 -0
- package/.agent-context/prompts/refactor.md +45 -0
- package/.agent-context/prompts/review-code.md +47 -0
- package/.agent-context/review-checklists/architecture-review.md +70 -0
- package/.agent-context/review-checklists/frontend-usability.md +33 -0
- package/.agent-context/review-checklists/performance-audit.md +65 -0
- package/.agent-context/review-checklists/pr-checklist.md +97 -0
- package/.agent-context/review-checklists/release-operations.md +29 -0
- package/.agent-context/review-checklists/security-audit.md +113 -0
- package/.agent-context/rules/api-docs.md +186 -0
- package/.agent-context/rules/architecture.md +198 -0
- package/.agent-context/rules/database-design.md +202 -0
- package/.agent-context/rules/efficiency-vs-hype.md +143 -0
- package/.agent-context/rules/error-handling.md +234 -0
- package/.agent-context/rules/event-driven.md +226 -0
- package/.agent-context/rules/frontend-architecture.md +66 -0
- package/.agent-context/rules/git-workflow.md +200 -0
- package/.agent-context/rules/microservices.md +174 -0
- package/.agent-context/rules/naming-conv.md +141 -0
- package/.agent-context/rules/performance.md +168 -0
- package/.agent-context/rules/realtime.md +47 -0
- package/.agent-context/rules/security.md +195 -0
- package/.agent-context/rules/testing.md +178 -0
- package/.agent-context/stacks/csharp.md +149 -0
- package/.agent-context/stacks/go.md +181 -0
- package/.agent-context/stacks/java.md +135 -0
- package/.agent-context/stacks/php.md +178 -0
- package/.agent-context/stacks/python.md +153 -0
- package/.agent-context/stacks/ruby.md +80 -0
- package/.agent-context/stacks/rust.md +86 -0
- package/.agent-context/stacks/typescript.md +317 -0
- package/.agent-context/state/architecture-map.md +25 -0
- package/.agent-context/state/dependency-map.md +32 -0
- package/.agent-override.md +36 -0
- package/.agents/workflows/init-project.md +29 -0
- package/.agents/workflows/refactor.md +29 -0
- package/.agents/workflows/review-code.md +29 -0
- package/.cursorrules +140 -0
- package/.gemini/instructions.md +97 -0
- package/.github/ISSUE_TEMPLATE/v1.7-frontend-work-item.yml +54 -0
- package/.github/copilot-instructions.md +104 -0
- package/.github/workflows/benchmark-detection.yml +38 -0
- package/.github/workflows/frontend-usability-gate.yml +36 -0
- package/.github/workflows/release-gate.yml +32 -0
- package/.github/workflows/sbom-compliance.yml +32 -0
- package/.windsurfrules +106 -0
- package/AGENTS.md +131 -0
- package/CONTRIBUTING.md +136 -0
- package/LICENSE +21 -0
- package/README.md +239 -0
- package/bin/agentic-senior-core.js +1147 -0
- package/mcp.json +29 -0
- package/package.json +50 -0
- package/scripts/detection-benchmark.mjs +138 -0
- package/scripts/frontend-usability-audit.mjs +87 -0
- package/scripts/generate-sbom.mjs +61 -0
- package/scripts/init-project.ps1 +105 -0
- package/scripts/init-project.sh +131 -0
- package/scripts/llm-judge.mjs +664 -0
- package/scripts/release-gate.mjs +116 -0
- package/scripts/validate.mjs +554 -0
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# Architecture Review Checklist
|
|
2
|
+
|
|
3
|
+
> Run this when reviewing module structure, new feature design, or refactoring.
|
|
4
|
+
> Bad architecture is invisible until it becomes unmaintainable.
|
|
5
|
+
|
|
6
|
+
## Instructions for Agent
|
|
7
|
+
|
|
8
|
+
Evaluate every item against the current project structure. For each violation, explain:
|
|
9
|
+
1. What layer or boundary is broken
|
|
10
|
+
2. Why it leads to maintenance or scalability problems
|
|
11
|
+
3. The correct architectural pattern to apply
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## Layer Separation
|
|
16
|
+
|
|
17
|
+
- [ ] **Controllers/Handlers contain NO business logic** — Only parsing input, calling service, formatting response
|
|
18
|
+
- [ ] **Services contain NO HTTP concepts** — No `Request`, `Response`, `HttpStatus` imports
|
|
19
|
+
- [ ] **Services contain NO raw SQL or direct DB access** — Use repository/DAO layer
|
|
20
|
+
- [ ] **Repositories contain NO business rules** — Only CRUD and query operations
|
|
21
|
+
- [ ] **Domain entities have NO framework dependencies** — Pure language types only
|
|
22
|
+
- [ ] **Dependencies flow inward** — Transport → Service → Repository → Domain (never reverse)
|
|
23
|
+
|
|
24
|
+
## Module Boundaries
|
|
25
|
+
|
|
26
|
+
- [ ] **Modules don't import from each other's internal files** — Only public exports
|
|
27
|
+
- [ ] **No circular dependencies between modules** — A → B → A is forbidden
|
|
28
|
+
- [ ] **Each module has a clear single responsibility** — Not a "kitchen sink" module
|
|
29
|
+
- [ ] **Shared code is genuinely shared** — Not domain-specific code disguised as "common"
|
|
30
|
+
- [ ] **Module size is reasonable** — If a module has 20+ files, consider splitting
|
|
31
|
+
|
|
32
|
+
## Dependency Management
|
|
33
|
+
|
|
34
|
+
- [ ] **No God classes** — No class/file with 500+ lines or 10+ dependencies
|
|
35
|
+
- [ ] **Constructor injection only** — No service locator, no field injection, no global state
|
|
36
|
+
- [ ] **Interfaces defined where consumed** — Not in the implementation module
|
|
37
|
+
- [ ] **External services abstracted behind interfaces** — Swappable, testable
|
|
38
|
+
- [ ] **Configuration injected, not hardcoded** — No magic strings for URLs, ports, keys
|
|
39
|
+
|
|
40
|
+
## Data Flow
|
|
41
|
+
|
|
42
|
+
- [ ] **DTOs at boundaries** — Internal models don't leak to external interfaces
|
|
43
|
+
- [ ] **Validation at entry points** — Zod / Pydantic / Bean Validation at transport layer
|
|
44
|
+
- [ ] **No raw request objects passed deep** — Transform to domain types ASAP
|
|
45
|
+
- [ ] **Response transformation explicit** — Dedicated serializers / resources / mappers
|
|
46
|
+
- [ ] **Sensitive data excluded from responses** — Passwords, tokens, internal IDs
|
|
47
|
+
|
|
48
|
+
## Database Design
|
|
49
|
+
|
|
50
|
+
- [ ] **Migrations are incremental** — No destructive changes without migration plan
|
|
51
|
+
- [ ] **Foreign keys for data integrity** — Relations enforced at DB level
|
|
52
|
+
- [ ] **Indexes for query patterns** — Not just primary keys
|
|
53
|
+
- [ ] **No business logic in DB** — Triggers and stored procs used sparingly
|
|
54
|
+
- [ ] **Soft delete considered** — For audit-sensitive entities
|
|
55
|
+
|
|
56
|
+
## Error Architecture
|
|
57
|
+
|
|
58
|
+
- [ ] **Error hierarchy defined** — Base error class with domain-specific subtypes
|
|
59
|
+
- [ ] **Global error handler exists** — Catches unhandled errors, returns safe responses
|
|
60
|
+
- [ ] **Error codes are typed** — Enum or const, not arbitrary strings
|
|
61
|
+
- [ ] **Client errors vs server errors distinguished** — 4xx vs 5xx with different handling
|
|
62
|
+
- [ ] **Errors don't leak internals** — No stack traces, SQL errors, or file paths to client
|
|
63
|
+
|
|
64
|
+
## Scalability Readiness
|
|
65
|
+
|
|
66
|
+
- [ ] **Stateless services** — No in-memory session or request state across requests
|
|
67
|
+
- [ ] **Background jobs for heavy work** — Long operations don't block HTTP responses
|
|
68
|
+
- [ ] **Idempotent endpoints where needed** — POST with idempotency keys for payment/creation
|
|
69
|
+
- [ ] **Feature flags for gradual rollout** — New features can be toggled without deploy
|
|
70
|
+
- [ ] **Health check endpoint exists** — `/health` returning service status
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# Frontend Usability Checklist — V1.7 Gate
|
|
2
|
+
|
|
3
|
+
Run this checklist before claiming frontend work is production-ready.
|
|
4
|
+
|
|
5
|
+
## 1. Visual System
|
|
6
|
+
- [ ] Typography scale is consistent and tokenized.
|
|
7
|
+
- [ ] Color usage follows design tokens and avoids ad-hoc values.
|
|
8
|
+
- [ ] Spacing and layout rhythm is coherent across pages.
|
|
9
|
+
|
|
10
|
+
## 2. Responsiveness
|
|
11
|
+
- [ ] Core pages are usable at mobile, tablet, and desktop breakpoints.
|
|
12
|
+
- [ ] Navigation remains accessible and understandable on small screens.
|
|
13
|
+
- [ ] No content overlap, clipped text, or horizontal scroll regressions.
|
|
14
|
+
|
|
15
|
+
## 3. Accessibility
|
|
16
|
+
- [ ] Keyboard-only navigation covers all critical user paths.
|
|
17
|
+
- [ ] Primary text and actionable controls meet WCAG AA contrast.
|
|
18
|
+
- [ ] Reduced-motion mode is respected for non-essential animations.
|
|
19
|
+
|
|
20
|
+
## 4. Interaction Quality
|
|
21
|
+
- [ ] Motion is meaningful, not decorative noise.
|
|
22
|
+
- [ ] Loading, empty, and error states are explicitly designed.
|
|
23
|
+
- [ ] CTA hierarchy is clear and supports user intent.
|
|
24
|
+
|
|
25
|
+
## 5. Performance and Stability
|
|
26
|
+
- [ ] Lighthouse mobile performance target is met on core pages.
|
|
27
|
+
- [ ] No severe layout shift during load and transition.
|
|
28
|
+
- [ ] Visual regression checks cover protected pages.
|
|
29
|
+
|
|
30
|
+
## 6. Documentation and Release Evidence
|
|
31
|
+
- [ ] Frontend architecture decision is documented.
|
|
32
|
+
- [ ] Visual baseline update process is documented.
|
|
33
|
+
- [ ] Release note includes usability and responsiveness evidence.
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# Performance Audit Checklist
|
|
2
|
+
|
|
3
|
+
> Run this on any code path that handles data, queries, or network requests.
|
|
4
|
+
> Performance problems are architectural — they don't fix themselves.
|
|
5
|
+
|
|
6
|
+
## Instructions for Agent
|
|
7
|
+
|
|
8
|
+
Evaluate every item below. For each finding, rate impact:
|
|
9
|
+
- **CRITICAL** — Will cause outage or severe degradation under normal load
|
|
10
|
+
- **HIGH** — Will degrade at scale, fix before production traffic
|
|
11
|
+
- **MEDIUM** — Wasted resources, fix in this sprint
|
|
12
|
+
- **LOW** — Optimization opportunity, track for later
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## Database & Queries
|
|
17
|
+
|
|
18
|
+
- [ ] **No N+1 queries** — No database queries inside loops. Use eager loading or joins.
|
|
19
|
+
- [ ] **No unbounded queries** — Every list query has LIMIT / pagination
|
|
20
|
+
- [ ] **No `SELECT *`** — Only select columns that are actually needed
|
|
21
|
+
- [ ] **Indexes exist for frequently queried columns** — WHERE, JOIN, ORDER BY columns
|
|
22
|
+
- [ ] **Composite indexes match query patterns** — Column order matters
|
|
23
|
+
- [ ] **No unnecessary COUNT(*)** — Use EXISTS for existence checks
|
|
24
|
+
- [ ] **Bulk operations used** — insertAll/updateAll instead of loops for batch work
|
|
25
|
+
- [ ] **Connection pool configured** — Not creating new connections per request
|
|
26
|
+
- [ ] **Query execution time logged** — Slow query detection enabled (> 200ms threshold)
|
|
27
|
+
|
|
28
|
+
## I/O & Network
|
|
29
|
+
|
|
30
|
+
- [ ] **No synchronous I/O in async context** — No blocking calls in event-loop code
|
|
31
|
+
- [ ] **HTTP requests have timeouts** — Connect (5s) and read (30s) timeouts configured
|
|
32
|
+
- [ ] **Parallel requests when independent** — Use Promise.all / asyncio.gather
|
|
33
|
+
- [ ] **Retry with backoff** — Network calls retry with exponential backoff + jitter
|
|
34
|
+
- [ ] **Response streaming for large data** — Don't buffer entire response in memory
|
|
35
|
+
- [ ] **File uploads size-limited** — Max upload size configured at server level
|
|
36
|
+
|
|
37
|
+
## Caching
|
|
38
|
+
|
|
39
|
+
- [ ] **Cache has invalidation strategy** — If cache exists, invalidation is documented
|
|
40
|
+
- [ ] **TTL is reasonable** — Not too long (stale data), not too short (no benefit)
|
|
41
|
+
- [ ] **Cache stampede prevented** — Locking or staggered TTL for popular keys
|
|
42
|
+
- [ ] **Cache key includes relevant context** — User ID, locale, version where needed
|
|
43
|
+
- [ ] **No caching of user-specific data in shared cache** — Privacy and correctness
|
|
44
|
+
|
|
45
|
+
## Memory
|
|
46
|
+
|
|
47
|
+
- [ ] **No unbounded in-memory collections** — Arrays/lists don't grow without limit
|
|
48
|
+
- [ ] **Streaming for large datasets** — Cursor/stream instead of loading all into memory
|
|
49
|
+
- [ ] **No memory leaks** — Event listeners cleaned up, intervals cleared, no circular refs
|
|
50
|
+
- [ ] **Resource cleanup** — File handles, DB connections, HTTP clients properly closed
|
|
51
|
+
|
|
52
|
+
## Frontend Performance (If Applicable)
|
|
53
|
+
|
|
54
|
+
- [ ] **No unnecessary re-renders** — Memoization where component receives same props
|
|
55
|
+
- [ ] **Images optimized** — Proper format (WebP), lazy loading, responsive sizes
|
|
56
|
+
- [ ] **Bundle size checked** — No 500KB library for a 5-function use case
|
|
57
|
+
- [ ] **API calls deduplicated** — Same data not fetched multiple times in same render
|
|
58
|
+
- [ ] **Pagination/virtualization for long lists** — Not rendering 10,000 DOM nodes
|
|
59
|
+
|
|
60
|
+
## General
|
|
61
|
+
|
|
62
|
+
- [ ] **No premature optimization** — Changes based on evidence, not assumptions
|
|
63
|
+
- [ ] **Hot paths identified** — Critical user-facing paths are optimized first
|
|
64
|
+
- [ ] **Compression enabled** — gzip/brotli for HTTP responses
|
|
65
|
+
- [ ] **Rate limiting configured** — API endpoints have request limits
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
# PR Checklist — The Quality Gate
|
|
2
|
+
|
|
3
|
+
> Run this before declaring any task "done."
|
|
4
|
+
> If ANY item fails, the task is NOT complete.
|
|
5
|
+
|
|
6
|
+
## Instructions for Agent
|
|
7
|
+
|
|
8
|
+
When asked to review code using this checklist, evaluate EVERY item below.
|
|
9
|
+
For each failed item, provide a Reasoning Chain (see `.cursorrules` → Reasoning Clause).
|
|
10
|
+
Output format:
|
|
11
|
+
|
|
12
|
+
```
|
|
13
|
+
## PR REVIEW RESULTS
|
|
14
|
+
━━━━━━━━━━━━━━━━━━━
|
|
15
|
+
|
|
16
|
+
✅ [Item] — Passes
|
|
17
|
+
❌ [Item] — FAILS
|
|
18
|
+
📌 Rule: [rule file + section]
|
|
19
|
+
❌ Problem: [specific issue found]
|
|
20
|
+
✅ Fix: [what to change]
|
|
21
|
+
|
|
22
|
+
VERDICT: PASS ✅ / FAIL ❌ (X/Y items passed)
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
## The Checklist
|
|
28
|
+
|
|
29
|
+
### 1. Naming (→ rules/naming-conv.md)
|
|
30
|
+
- [ ] All variables are descriptive nouns (no `data`, `temp`, `val`, `x`)
|
|
31
|
+
- [ ] All functions start with a verb (no `userData()`, `orderLogic()`)
|
|
32
|
+
- [ ] All booleans use `is/has/can/should` prefix
|
|
33
|
+
- [ ] Constants use SCREAMING_SNAKE_CASE with unit suffix
|
|
34
|
+
- [ ] No single-letter variables (except `i` in classic for-loops)
|
|
35
|
+
- [ ] File names follow the project's chosen convention consistently
|
|
36
|
+
|
|
37
|
+
### 2. Architecture (→ rules/architecture.md)
|
|
38
|
+
- [ ] No layer leaks (controllers don't query DB, services don't return HTTP responses)
|
|
39
|
+
- [ ] Feature-based file organization (not technical grouping)
|
|
40
|
+
- [ ] Dependencies flow inward (transport → service → repository)
|
|
41
|
+
- [ ] Module boundaries respected (no reaching into another module's internals)
|
|
42
|
+
- [ ] Domain layer has zero external dependencies
|
|
43
|
+
|
|
44
|
+
### 3. Type Safety (→ stacks/typescript.md)
|
|
45
|
+
- [ ] No `any` type anywhere (use `unknown` + narrowing)
|
|
46
|
+
- [ ] No `// @ts-ignore` (use `@ts-expect-error` with justification comment)
|
|
47
|
+
- [ ] All function return types are explicit
|
|
48
|
+
- [ ] Zod schemas validate ALL external input at boundaries
|
|
49
|
+
- [ ] Types derived from Zod schemas (single source of truth)
|
|
50
|
+
|
|
51
|
+
### 4. Error Handling (→ rules/error-handling.md)
|
|
52
|
+
- [ ] No empty catch blocks
|
|
53
|
+
- [ ] No `catch(e) { console.log(e) }` without re-throw or recovery
|
|
54
|
+
- [ ] Typed error classes used (not generic `new Error('...')`)
|
|
55
|
+
- [ ] Error responses don't leak internal details to clients
|
|
56
|
+
- [ ] Structured logging with context (traceId, userId, action)
|
|
57
|
+
|
|
58
|
+
### 5. Security (→ rules/security.md)
|
|
59
|
+
- [ ] All user input validated at boundaries (Zod/schema)
|
|
60
|
+
- [ ] No SQL/command string concatenation with user input
|
|
61
|
+
- [ ] No secrets hardcoded in source code
|
|
62
|
+
- [ ] Auth checked server-side (not client-side only)
|
|
63
|
+
- [ ] Error messages don't reveal internal system details
|
|
64
|
+
- [ ] CORS configured (not `*` in production)
|
|
65
|
+
|
|
66
|
+
### 6. Performance (→ rules/performance.md)
|
|
67
|
+
- [ ] No N+1 queries (no queries inside loops)
|
|
68
|
+
- [ ] All list queries have LIMIT/pagination
|
|
69
|
+
- [ ] No `SELECT *` (only needed columns)
|
|
70
|
+
- [ ] No synchronous I/O in async context
|
|
71
|
+
- [ ] Cache has documented invalidation strategy (if caching used)
|
|
72
|
+
|
|
73
|
+
### 7. Testing (→ rules/testing.md)
|
|
74
|
+
- [ ] Business logic has unit tests
|
|
75
|
+
- [ ] Test names follow `should [behavior] when [condition]`
|
|
76
|
+
- [ ] Tests follow AAA pattern (Arrange → Act → Assert)
|
|
77
|
+
- [ ] No implementation detail testing (test behavior, not structure)
|
|
78
|
+
- [ ] Test data uses factories (no copy-pasted objects)
|
|
79
|
+
|
|
80
|
+
### 8. Dependencies (→ rules/efficiency-vs-hype.md)
|
|
81
|
+
- [ ] No new dependencies added without justification
|
|
82
|
+
- [ ] No dependency that replaces < 20 lines of code
|
|
83
|
+
- [ ] New packages checked for maintenance health
|
|
84
|
+
- [ ] Bundle impact considered (frontend)
|
|
85
|
+
|
|
86
|
+
### 9. Git (→ rules/git-workflow.md)
|
|
87
|
+
- [ ] Commit messages follow Conventional Commits
|
|
88
|
+
- [ ] No `console.log` debugging statements
|
|
89
|
+
- [ ] No `// TODO` without a linked issue
|
|
90
|
+
- [ ] No commented-out code blocks
|
|
91
|
+
- [ ] `.env` not committed
|
|
92
|
+
|
|
93
|
+
### 10. Documentation
|
|
94
|
+
- [ ] API endpoints have OpenAPI/Swagger documentation
|
|
95
|
+
- [ ] Complex business logic has comments explaining WHY
|
|
96
|
+
- [ ] Public functions/methods have JSDoc/docstrings
|
|
97
|
+
- [ ] README updated if new setup steps required
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# Release Operations Checklist (V1.8)
|
|
2
|
+
|
|
3
|
+
Use this checklist before promoting any release tag or package publish operation.
|
|
4
|
+
|
|
5
|
+
## 1) Versioning and Changelog Integrity
|
|
6
|
+
- `package.json` version is valid semantic version (`x.y.z`).
|
|
7
|
+
- `CHANGELOG.md` has a matching release header for the package version.
|
|
8
|
+
- `docs/roadmap.md` reflects release status and scope for the current milestone.
|
|
9
|
+
|
|
10
|
+
## 2) Quality Gates and Test Evidence
|
|
11
|
+
- `npm run validate` passes with zero failures.
|
|
12
|
+
- `npm run test` passes on the full suite.
|
|
13
|
+
- Frontend governance gate (`npm run audit:frontend-usability`) passes.
|
|
14
|
+
- Release governance gate (`npm run gate:release`) passes.
|
|
15
|
+
|
|
16
|
+
## 3) Supply Chain and Compliance Evidence
|
|
17
|
+
- SBOM is generated with `npm run sbom:generate`.
|
|
18
|
+
- CI uploads SBOM artifact for retention and audit traceability.
|
|
19
|
+
- CI uploads release-gate report artifact for each run.
|
|
20
|
+
|
|
21
|
+
## 4) Security and Override Governance
|
|
22
|
+
- `.agent-override.md` entries have valid `Owner` and `Expiry` metadata.
|
|
23
|
+
- No expired overrides remain active.
|
|
24
|
+
- Any temporary exception has explicit rollback owner and date.
|
|
25
|
+
|
|
26
|
+
## 5) Publish Readiness
|
|
27
|
+
- Release notes summarize scope, risks, and rollback steps.
|
|
28
|
+
- Required GitHub workflows are green on target commit.
|
|
29
|
+
- Tag and publish command are executed only after all checks pass.
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
# Security Audit Checklist — OWASP-Aligned
|
|
2
|
+
|
|
3
|
+
> Run this on any code that handles authentication, authorization,
|
|
4
|
+
> user input, or external data. When in doubt, run it anyway.
|
|
5
|
+
|
|
6
|
+
## Instructions for Agent
|
|
7
|
+
|
|
8
|
+
Evaluate every item below against the current code. For each finding, rate severity:
|
|
9
|
+
- 🔴 **CRITICAL** — Exploitable now, must fix before deploy
|
|
10
|
+
- 🟠 **HIGH** — Likely exploitable, fix in this PR
|
|
11
|
+
- 🟡 **MEDIUM** — Potential risk, fix before production
|
|
12
|
+
- 🟢 **LOW** — Minor, fix when convenient
|
|
13
|
+
|
|
14
|
+
Output format:
|
|
15
|
+
```
|
|
16
|
+
## SECURITY AUDIT RESULTS
|
|
17
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
18
|
+
|
|
19
|
+
🔴 CRITICAL: [finding title]
|
|
20
|
+
Location: [file:line]
|
|
21
|
+
Risk: [what an attacker could do]
|
|
22
|
+
Fix: [specific remediation]
|
|
23
|
+
|
|
24
|
+
VERDICT: X findings (🔴 N critical, 🟠 N high, 🟡 N medium, 🟢 N low)
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
## A1: Injection (SQL, NoSQL, OS, LDAP)
|
|
30
|
+
|
|
31
|
+
- [ ] No string concatenation in SQL queries → use parameterized queries
|
|
32
|
+
- [ ] No string interpolation in OS commands → use argument arrays
|
|
33
|
+
- [ ] No raw user input in regex → escape or use validated patterns
|
|
34
|
+
- [ ] ORM/query builder used correctly (no raw queries with user input)
|
|
35
|
+
- [ ] No `eval()`, `new Function()`, or `exec()` with user-controlled input
|
|
36
|
+
|
|
37
|
+
## A2: Broken Authentication
|
|
38
|
+
|
|
39
|
+
- [ ] Passwords hashed with bcrypt (cost ≥ 12) or argon2
|
|
40
|
+
- [ ] No MD5, SHA1, or SHA256 for password hashing
|
|
41
|
+
- [ ] Rate limiting on login endpoints (max 5 per minute per IP)
|
|
42
|
+
- [ ] Session tokens are cryptographically random (≥ 256 bits)
|
|
43
|
+
- [ ] JWT tokens have reasonable expiration (≤ 15 min for access, ≤ 7 days refresh)
|
|
44
|
+
- [ ] Refresh token rotation implemented (invalidate old token on use)
|
|
45
|
+
- [ ] Password reset tokens are single-use and time-limited (≤ 1 hour)
|
|
46
|
+
|
|
47
|
+
## A3: Sensitive Data Exposure
|
|
48
|
+
|
|
49
|
+
- [ ] No secrets in source code (API keys, passwords, tokens)
|
|
50
|
+
- [ ] No secrets in git history (check with `git log -p | grep -i secret`)
|
|
51
|
+
- [ ] Sensitive fields excluded from API responses (password, tokens, internal IDs)
|
|
52
|
+
- [ ] Sensitive fields excluded from logs (passwords, tokens, PII)
|
|
53
|
+
- [ ] HTTPS enforced (HSTS header present)
|
|
54
|
+
- [ ] Sensitive cookies have `Secure`, `HttpOnly`, `SameSite` flags
|
|
55
|
+
|
|
56
|
+
## A4: Broken Access Control
|
|
57
|
+
|
|
58
|
+
- [ ] Authorization enforced server-side (not just client-side UI hiding)
|
|
59
|
+
- [ ] Resource ownership verified (user can only access their own data)
|
|
60
|
+
- [ ] Default deny — if no rule grants access, deny
|
|
61
|
+
- [ ] Admin endpoints require admin role verification
|
|
62
|
+
- [ ] No direct object reference without access check (IDOR prevention)
|
|
63
|
+
- [ ] CORS configured with specific origins (not `*`)
|
|
64
|
+
- [ ] File upload paths don't allow directory traversal
|
|
65
|
+
|
|
66
|
+
## A5: Security Misconfiguration
|
|
67
|
+
|
|
68
|
+
- [ ] Debug mode disabled in production (no stack traces to client)
|
|
69
|
+
- [ ] Default credentials changed
|
|
70
|
+
- [ ] Unnecessary features/endpoints disabled
|
|
71
|
+
- [ ] Security headers present:
|
|
72
|
+
- `Strict-Transport-Security`
|
|
73
|
+
- `Content-Security-Policy`
|
|
74
|
+
- `X-Content-Type-Options: nosniff`
|
|
75
|
+
- `X-Frame-Options: DENY`
|
|
76
|
+
- `Referrer-Policy`
|
|
77
|
+
- [ ] Error responses don't reveal framework/version info
|
|
78
|
+
|
|
79
|
+
## A6: XSS (Cross-Site Scripting)
|
|
80
|
+
|
|
81
|
+
- [ ] No `innerHTML`, `dangerouslySetInnerHTML`, or `v-html` with user data
|
|
82
|
+
- [ ] Output encoding applied when rendering user input
|
|
83
|
+
- [ ] Content-Security-Policy header restricts inline scripts
|
|
84
|
+
- [ ] URL parameters validated before rendering
|
|
85
|
+
|
|
86
|
+
## A7: Insecure Dependencies
|
|
87
|
+
|
|
88
|
+
- [ ] No known vulnerabilities in dependencies (`npm audit` clean)
|
|
89
|
+
- [ ] Dependencies are actively maintained (check pulse)
|
|
90
|
+
- [ ] Lock files committed and up-to-date
|
|
91
|
+
- [ ] No unnecessary dependencies (check efficiency-vs-hype.md)
|
|
92
|
+
|
|
93
|
+
## A8: Logging & Monitoring
|
|
94
|
+
|
|
95
|
+
- [ ] Authentication failures logged with IP and timestamp
|
|
96
|
+
- [ ] Authorization failures logged with userId and resource
|
|
97
|
+
- [ ] Critical operations logged (data deletion, role changes, exports)
|
|
98
|
+
- [ ] Logs do NOT contain passwords, tokens, or full credit card numbers
|
|
99
|
+
- [ ] Log injection prevented (sanitize user input before logging)
|
|
100
|
+
|
|
101
|
+
## A9: Rate Limiting
|
|
102
|
+
|
|
103
|
+
- [ ] Auth endpoints rate-limited
|
|
104
|
+
- [ ] API endpoints have reasonable rate limits
|
|
105
|
+
- [ ] File upload size limits configured
|
|
106
|
+
- [ ] Pagination limits enforced (prevent requesting 1M records)
|
|
107
|
+
|
|
108
|
+
## A10: Mass Assignment
|
|
109
|
+
|
|
110
|
+
- [ ] Input DTOs explicitly whitelist allowed fields
|
|
111
|
+
- [ ] No `Object.assign(entity, req.body)` without field filtering
|
|
112
|
+
- [ ] Admin-only fields (role, permissions) can't be set by regular users
|
|
113
|
+
- [ ] Database updates use explicit field sets, not spread operators on raw input
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
# API Documentation — The "Invisible API" Rule
|
|
2
|
+
|
|
3
|
+
> An undocumented API is an unusable API.
|
|
4
|
+
> If it's not in the spec, it doesn't exist.
|
|
5
|
+
|
|
6
|
+
## The Zero-Doc Death Penalty
|
|
7
|
+
|
|
8
|
+
Every API endpoint MUST have machine-readable documentation that covers:
|
|
9
|
+
1. HTTP method + path
|
|
10
|
+
2. Request body schema with field descriptions and examples
|
|
11
|
+
3. All response codes with typed schemas
|
|
12
|
+
4. Authentication requirements
|
|
13
|
+
5. Rate limiting (if applicable)
|
|
14
|
+
|
|
15
|
+
```
|
|
16
|
+
BANNED: An endpoint without a defined Request/Response schema.
|
|
17
|
+
BANNED: Using generic `object` or `any` in documentation types.
|
|
18
|
+
BANNED: "See code for details" as documentation.
|
|
19
|
+
BANNED: Swagger UI with auto-generated summaries only (no descriptions, no examples).
|
|
20
|
+
|
|
21
|
+
REQUIRED: Every field MUST have a `description` and an `example` value.
|
|
22
|
+
REQUIRED: Every error response MUST be documented (400, 401, 403, 404, 409, 500).
|
|
23
|
+
REQUIRED: Documentation MUST be updated in the SAME commit as the endpoint change.
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## Documentation Format: OpenAPI 3.1 (Non-Negotiable)
|
|
29
|
+
|
|
30
|
+
All APIs produce an OpenAPI 3.1 specification. Not 3.0, not proprietary formats, not "we'll add Swagger later."
|
|
31
|
+
|
|
32
|
+
### Why OpenAPI
|
|
33
|
+
- Machine-readable: clients, tests, and mocks can be generated from the spec
|
|
34
|
+
- Full JSON Schema Draft 2020-12 compatibility (3.1+ only)
|
|
35
|
+
- Vendor-neutral: works with Scalar, Swagger UI, Redoc, Postman, Stoplight
|
|
36
|
+
- Version-controllable: the spec is a file you can diff and review
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
## Tooling by Framework
|
|
41
|
+
|
|
42
|
+
### NestJS
|
|
43
|
+
Use `@nestjs/swagger` with Scalar UI (not default Swagger UI — Scalar is faster and more readable).
|
|
44
|
+
|
|
45
|
+
```typescript
|
|
46
|
+
// main.ts — Setup
|
|
47
|
+
import { SwaggerModule, DocumentBuilder } from '@nestjs/swagger';
|
|
48
|
+
import { apiReference } from '@scalar/nestjs-api-reference';
|
|
49
|
+
|
|
50
|
+
const config = new DocumentBuilder()
|
|
51
|
+
.setTitle('Service Name')
|
|
52
|
+
.setDescription('Brief service purpose')
|
|
53
|
+
.setVersion('1.0')
|
|
54
|
+
.addBearerAuth()
|
|
55
|
+
.build();
|
|
56
|
+
|
|
57
|
+
const document = SwaggerModule.createDocument(app, config);
|
|
58
|
+
|
|
59
|
+
// Scalar UI at /docs
|
|
60
|
+
app.use('/docs', apiReference({ spec: { content: document } }));
|
|
61
|
+
|
|
62
|
+
// Raw spec at /api-json
|
|
63
|
+
SwaggerModule.setup('api', app, document);
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Every controller method requires these decorators at minimum:
|
|
67
|
+
```typescript
|
|
68
|
+
@ApiOperation({ summary: 'Create a user account' })
|
|
69
|
+
@ApiBody({ type: CreateUserDto, description: 'User registration data' })
|
|
70
|
+
@ApiResponse({ status: 201, type: UserResponseDto, description: 'User created successfully' })
|
|
71
|
+
@ApiResponse({ status: 400, description: 'Validation error — invalid input fields' })
|
|
72
|
+
@ApiResponse({ status: 409, description: 'Conflict — email already registered' })
|
|
73
|
+
@Post()
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
Every DTO property requires `@ApiProperty`:
|
|
77
|
+
```typescript
|
|
78
|
+
export class CreateUserDto {
|
|
79
|
+
@ApiProperty({
|
|
80
|
+
description: 'User email address, must be unique across the system',
|
|
81
|
+
example: 'jane.doe@example.com',
|
|
82
|
+
})
|
|
83
|
+
email: string;
|
|
84
|
+
|
|
85
|
+
@ApiProperty({
|
|
86
|
+
description: 'Display name shown in the UI',
|
|
87
|
+
example: 'Jane Doe',
|
|
88
|
+
minLength: 1,
|
|
89
|
+
maxLength: 100,
|
|
90
|
+
})
|
|
91
|
+
name: string;
|
|
92
|
+
}
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### Next.js (App Router)
|
|
96
|
+
Use `zod-to-openapi` or `next-swagger-doc` to generate OpenAPI from Zod schemas.
|
|
97
|
+
|
|
98
|
+
```typescript
|
|
99
|
+
import { extendZodWithOpenApi } from '@asteasolutions/zod-to-openapi';
|
|
100
|
+
import { z } from 'zod';
|
|
101
|
+
|
|
102
|
+
extendZodWithOpenApi(z);
|
|
103
|
+
|
|
104
|
+
export const CreateUserSchema = z.object({
|
|
105
|
+
email: z.string().email().openapi({
|
|
106
|
+
description: 'User email address, must be unique',
|
|
107
|
+
example: 'jane.doe@example.com',
|
|
108
|
+
}),
|
|
109
|
+
name: z.string().min(1).max(100).openapi({
|
|
110
|
+
description: 'Display name shown in the UI',
|
|
111
|
+
example: 'Jane Doe',
|
|
112
|
+
}),
|
|
113
|
+
}).openapi('CreateUserRequest');
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
Expose the spec at `/api/docs` or `/api/openapi.json`.
|
|
117
|
+
|
|
118
|
+
### Other Frameworks (Express, Fastify, Hono)
|
|
119
|
+
Use `swagger-jsdoc` + TSDoc comments, or `@asteasolutions/zod-to-openapi`.
|
|
120
|
+
The output MUST be a valid OpenAPI 3.1 JSON/YAML file served at a known endpoint.
|
|
121
|
+
|
|
122
|
+
---
|
|
123
|
+
|
|
124
|
+
## Response Documentation Standard
|
|
125
|
+
|
|
126
|
+
Every endpoint MUST document these response scenarios:
|
|
127
|
+
|
|
128
|
+
| Status | When | Schema Required |
|
|
129
|
+
|--------|------|----------------|
|
|
130
|
+
| `200` | Successful retrieval or update | Yes — typed response body |
|
|
131
|
+
| `201` | Successful creation | Yes — the created resource |
|
|
132
|
+
| `204` | Successful deletion | No body |
|
|
133
|
+
| `400` | Validation error | Yes — field-level error details |
|
|
134
|
+
| `401` | Missing or invalid authentication | Fixed message, no details |
|
|
135
|
+
| `403` | Authenticated but insufficient permissions | Fixed message |
|
|
136
|
+
| `404` | Resource not found | Fixed message |
|
|
137
|
+
| `409` | Conflict (duplicate resource) | Description of conflict |
|
|
138
|
+
| `429` | Rate limit exceeded | Retry-After header |
|
|
139
|
+
| `500` | Internal error | `{ traceId }` only — NO stack traces |
|
|
140
|
+
|
|
141
|
+
### Error Response Schema (Standardized)
|
|
142
|
+
```json
|
|
143
|
+
{
|
|
144
|
+
"error": {
|
|
145
|
+
"code": "VALIDATION_ERROR",
|
|
146
|
+
"message": "One or more fields are invalid",
|
|
147
|
+
"details": [
|
|
148
|
+
{ "field": "email", "message": "Invalid email format" }
|
|
149
|
+
],
|
|
150
|
+
"traceId": "req-abc-123"
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
This schema MUST be documented in OpenAPI as a reusable component (`#/components/schemas/ErrorResponse`).
|
|
156
|
+
|
|
157
|
+
---
|
|
158
|
+
|
|
159
|
+
## Documentation Sync Rule
|
|
160
|
+
|
|
161
|
+
```
|
|
162
|
+
Endpoint changed + docs NOT updated = PR REJECTED.
|
|
163
|
+
|
|
164
|
+
The spec is a contract. If the contract is wrong, consumers will break.
|
|
165
|
+
"I'll update the docs later" means "the docs will never be updated."
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
### Enforcement
|
|
169
|
+
1. API docs live next to the code (same module, same directory)
|
|
170
|
+
2. Docs update in the SAME commit as the endpoint change
|
|
171
|
+
3. CI can validate the spec: `openapi-generator validate -i openapi.json`
|
|
172
|
+
4. Generated clients (if any) must be regenerated after spec changes
|
|
173
|
+
|
|
174
|
+
---
|
|
175
|
+
|
|
176
|
+
## The Documentation Quality Test
|
|
177
|
+
|
|
178
|
+
Open your API docs URL (`/docs`). For a randomly chosen endpoint, verify:
|
|
179
|
+
|
|
180
|
+
1. Can a developer who has never seen the codebase call this endpoint correctly? (Must be YES)
|
|
181
|
+
2. Are all required fields clearly marked? (Must be YES)
|
|
182
|
+
3. Does every field have a realistic example value? (Must be YES)
|
|
183
|
+
4. Are all error responses documented with their conditions? (Must be YES)
|
|
184
|
+
5. Can you copy the example request and it works? (Must be YES)
|
|
185
|
+
|
|
186
|
+
If any answer is "no", the documentation is incomplete.
|