@jigyasudham/veto 0.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.
Files changed (198) hide show
  1. package/.claude/settings.local.json +9 -0
  2. package/README.md +190 -0
  3. package/dist/adapters/claude.js +57 -0
  4. package/dist/adapters/codex.js +58 -0
  5. package/dist/adapters/gemini.js +58 -0
  6. package/dist/adapters/index.js +156 -0
  7. package/dist/agents/development/api.js +116 -0
  8. package/dist/agents/development/backend.js +82 -0
  9. package/dist/agents/development/coder.js +207 -0
  10. package/dist/agents/development/database.js +81 -0
  11. package/dist/agents/development/debugger.js +234 -0
  12. package/dist/agents/development/devops.js +84 -0
  13. package/dist/agents/development/frontend.js +83 -0
  14. package/dist/agents/development/migration.js +141 -0
  15. package/dist/agents/development/performance.js +142 -0
  16. package/dist/agents/development/refactor.js +85 -0
  17. package/dist/agents/development/reviewer.js +260 -0
  18. package/dist/agents/development/tester.js +143 -0
  19. package/dist/agents/executor.js +144 -0
  20. package/dist/agents/memory/context-manager.js +167 -0
  21. package/dist/agents/memory/decision-logger.js +157 -0
  22. package/dist/agents/memory/knowledge-base.js +120 -0
  23. package/dist/agents/memory/pattern-learner.js +140 -0
  24. package/dist/agents/memory/project-mapper.js +114 -0
  25. package/dist/agents/quality/accessibility.js +89 -0
  26. package/dist/agents/quality/code-quality.js +109 -0
  27. package/dist/agents/quality/compatibility.js +55 -0
  28. package/dist/agents/quality/documentation.js +95 -0
  29. package/dist/agents/quality/error-handling.js +87 -0
  30. package/dist/agents/research/competitor-analyzer.js +44 -0
  31. package/dist/agents/research/cost-analyzer.js +51 -0
  32. package/dist/agents/research/estimator.js +57 -0
  33. package/dist/agents/research/ethics-bias.js +111 -0
  34. package/dist/agents/research/researcher.js +112 -0
  35. package/dist/agents/research/risk-assessor.js +61 -0
  36. package/dist/agents/research/tech-advisor.js +52 -0
  37. package/dist/agents/security/auth.js +269 -0
  38. package/dist/agents/security/dependency-audit.js +273 -0
  39. package/dist/agents/security/penetration.js +245 -0
  40. package/dist/agents/security/privacy.js +259 -0
  41. package/dist/agents/security/scanner.js +288 -0
  42. package/dist/agents/security/secrets.js +212 -0
  43. package/dist/agents/types.js +2 -0
  44. package/dist/agents/workflow/automation.js +56 -0
  45. package/dist/agents/workflow/file-manager.js +49 -0
  46. package/dist/agents/workflow/git-agent.js +52 -0
  47. package/dist/agents/workflow/reporter.js +48 -0
  48. package/dist/agents/workflow/search-agent.js +39 -0
  49. package/dist/agents/workflow/task-coordinator.js +40 -0
  50. package/dist/agents/workflow/task-planner.js +46 -0
  51. package/dist/cli.js +132 -0
  52. package/dist/council/decision-engine.js +136 -0
  53. package/dist/council/devil-advocate.js +106 -0
  54. package/dist/council/index.js +37 -0
  55. package/dist/council/lead-developer.js +108 -0
  56. package/dist/council/legal-compliance.js +142 -0
  57. package/dist/council/product-manager.js +92 -0
  58. package/dist/council/security.js +162 -0
  59. package/dist/council/system-architect.js +122 -0
  60. package/dist/council/types.js +2 -0
  61. package/dist/council/ux-designer.js +109 -0
  62. package/dist/memory/local.js +182 -0
  63. package/dist/memory/schema.js +116 -0
  64. package/dist/memory/sync.js +199 -0
  65. package/dist/router/complexity-scorer.js +78 -0
  66. package/dist/router/context-compressor.js +58 -0
  67. package/dist/router/index.js +29 -0
  68. package/dist/router/learning-updater.js +186 -0
  69. package/dist/router/model-selector.js +51 -0
  70. package/dist/router/rate-monitor.js +73 -0
  71. package/dist/server.js +949 -0
  72. package/dist/skills/development/skill-api-design.js +313 -0
  73. package/dist/skills/development/skill-auth.js +255 -0
  74. package/dist/skills/development/skill-ci-cd.js +2 -0
  75. package/dist/skills/development/skill-crud.js +193 -0
  76. package/dist/skills/development/skill-db-schema.js +2 -0
  77. package/dist/skills/development/skill-docker.js +2 -0
  78. package/dist/skills/development/skill-env-setup.js +2 -0
  79. package/dist/skills/development/skill-scaffold.js +299 -0
  80. package/dist/skills/intelligence/skill-complexity-score.js +66 -0
  81. package/dist/skills/intelligence/skill-cost-track.js +36 -0
  82. package/dist/skills/intelligence/skill-learning-loop.js +66 -0
  83. package/dist/skills/intelligence/skill-pattern-detect.js +35 -0
  84. package/dist/skills/intelligence/skill-rate-watch.js +58 -0
  85. package/dist/skills/memory/skill-context-compress.js +82 -0
  86. package/dist/skills/memory/skill-cross-sync.js +88 -0
  87. package/dist/skills/memory/skill-decision-log.js +103 -0
  88. package/dist/skills/memory/skill-session-restore.js +44 -0
  89. package/dist/skills/memory/skill-session-save.js +78 -0
  90. package/dist/skills/quality/skill-accessibility.js +2 -0
  91. package/dist/skills/quality/skill-code-review.js +60 -0
  92. package/dist/skills/quality/skill-docs-gen.js +2 -0
  93. package/dist/skills/quality/skill-perf-audit.js +2 -0
  94. package/dist/skills/quality/skill-security-scan.js +67 -0
  95. package/dist/skills/quality/skill-test-suite.js +274 -0
  96. package/dist/skills/workflow/skill-deploy.js +2 -0
  97. package/dist/skills/workflow/skill-git-workflow.js +2 -0
  98. package/dist/skills/workflow/skill-rollback.js +2 -0
  99. package/dist/skills/workflow/skill-task-breakdown.js +2 -0
  100. package/package.json +30 -0
  101. package/src/adapters/claude.ts +70 -0
  102. package/src/adapters/codex.ts +71 -0
  103. package/src/adapters/gemini.ts +71 -0
  104. package/src/adapters/index.ts +217 -0
  105. package/src/agents/development/api.ts +120 -0
  106. package/src/agents/development/backend.ts +85 -0
  107. package/src/agents/development/coder.ts +213 -0
  108. package/src/agents/development/database.ts +83 -0
  109. package/src/agents/development/debugger.ts +238 -0
  110. package/src/agents/development/devops.ts +86 -0
  111. package/src/agents/development/frontend.ts +85 -0
  112. package/src/agents/development/migration.ts +144 -0
  113. package/src/agents/development/performance.ts +144 -0
  114. package/src/agents/development/refactor.ts +86 -0
  115. package/src/agents/development/reviewer.ts +268 -0
  116. package/src/agents/development/tester.ts +151 -0
  117. package/src/agents/executor.ts +158 -0
  118. package/src/agents/memory/context-manager.ts +171 -0
  119. package/src/agents/memory/decision-logger.ts +160 -0
  120. package/src/agents/memory/knowledge-base.ts +124 -0
  121. package/src/agents/memory/pattern-learner.ts +143 -0
  122. package/src/agents/memory/project-mapper.ts +118 -0
  123. package/src/agents/quality/accessibility.ts +99 -0
  124. package/src/agents/quality/code-quality.ts +115 -0
  125. package/src/agents/quality/compatibility.ts +58 -0
  126. package/src/agents/quality/documentation.ts +105 -0
  127. package/src/agents/quality/error-handling.ts +96 -0
  128. package/src/agents/research/competitor-analyzer.ts +45 -0
  129. package/src/agents/research/cost-analyzer.ts +54 -0
  130. package/src/agents/research/estimator.ts +60 -0
  131. package/src/agents/research/ethics-bias.ts +113 -0
  132. package/src/agents/research/researcher.ts +114 -0
  133. package/src/agents/research/risk-assessor.ts +63 -0
  134. package/src/agents/research/tech-advisor.ts +55 -0
  135. package/src/agents/security/auth.ts +287 -0
  136. package/src/agents/security/dependency-audit.ts +337 -0
  137. package/src/agents/security/penetration.ts +262 -0
  138. package/src/agents/security/privacy.ts +285 -0
  139. package/src/agents/security/scanner.ts +322 -0
  140. package/src/agents/security/secrets.ts +249 -0
  141. package/src/agents/types.ts +66 -0
  142. package/src/agents/workflow/automation.ts +59 -0
  143. package/src/agents/workflow/file-manager.ts +52 -0
  144. package/src/agents/workflow/git-agent.ts +55 -0
  145. package/src/agents/workflow/reporter.ts +51 -0
  146. package/src/agents/workflow/search-agent.ts +40 -0
  147. package/src/agents/workflow/task-coordinator.ts +41 -0
  148. package/src/agents/workflow/task-planner.ts +47 -0
  149. package/src/cli.ts +143 -0
  150. package/src/council/decision-engine.ts +171 -0
  151. package/src/council/devil-advocate.ts +116 -0
  152. package/src/council/index.ts +44 -0
  153. package/src/council/lead-developer.ts +118 -0
  154. package/src/council/legal-compliance.ts +152 -0
  155. package/src/council/product-manager.ts +102 -0
  156. package/src/council/security.ts +172 -0
  157. package/src/council/system-architect.ts +132 -0
  158. package/src/council/types.ts +33 -0
  159. package/src/council/ux-designer.ts +121 -0
  160. package/src/memory/local.ts +305 -0
  161. package/src/memory/schema.ts +174 -0
  162. package/src/memory/sync.ts +274 -0
  163. package/src/router/complexity-scorer.ts +96 -0
  164. package/src/router/context-compressor.ts +74 -0
  165. package/src/router/index.ts +60 -0
  166. package/src/router/learning-updater.ts +271 -0
  167. package/src/router/model-selector.ts +83 -0
  168. package/src/router/rate-monitor.ts +103 -0
  169. package/src/server.ts +1038 -0
  170. package/src/skills/development/skill-api-design.ts +329 -0
  171. package/src/skills/development/skill-auth.ts +271 -0
  172. package/src/skills/development/skill-ci-cd.ts +0 -0
  173. package/src/skills/development/skill-crud.ts +209 -0
  174. package/src/skills/development/skill-db-schema.ts +0 -0
  175. package/src/skills/development/skill-docker.ts +0 -0
  176. package/src/skills/development/skill-env-setup.ts +0 -0
  177. package/src/skills/development/skill-scaffold.ts +323 -0
  178. package/src/skills/intelligence/skill-complexity-score.ts +69 -0
  179. package/src/skills/intelligence/skill-cost-track.ts +39 -0
  180. package/src/skills/intelligence/skill-learning-loop.ts +69 -0
  181. package/src/skills/intelligence/skill-pattern-detect.ts +38 -0
  182. package/src/skills/intelligence/skill-rate-watch.ts +61 -0
  183. package/src/skills/memory/skill-context-compress.ts +98 -0
  184. package/src/skills/memory/skill-cross-sync.ts +104 -0
  185. package/src/skills/memory/skill-decision-log.ts +119 -0
  186. package/src/skills/memory/skill-session-restore.ts +59 -0
  187. package/src/skills/memory/skill-session-save.ts +94 -0
  188. package/src/skills/quality/skill-accessibility.ts +0 -0
  189. package/src/skills/quality/skill-code-review.ts +84 -0
  190. package/src/skills/quality/skill-docs-gen.ts +0 -0
  191. package/src/skills/quality/skill-perf-audit.ts +0 -0
  192. package/src/skills/quality/skill-security-scan.ts +91 -0
  193. package/src/skills/quality/skill-test-suite.ts +290 -0
  194. package/src/skills/workflow/skill-deploy.ts +0 -0
  195. package/src/skills/workflow/skill-git-workflow.ts +0 -0
  196. package/src/skills/workflow/skill-rollback.ts +0 -0
  197. package/src/skills/workflow/skill-task-breakdown.ts +0 -0
  198. package/tsconfig.json +20 -0
@@ -0,0 +1,288 @@
1
+ export function plan(task, context) {
2
+ return {
3
+ agent: 'security-scanner',
4
+ task,
5
+ tier: 2,
6
+ approach: 'Apply OWASP Top 10 methodology: enumerate attack surface, check each category ' +
7
+ 'systematically, prioritise critical and high findings, produce actionable remediation.',
8
+ steps: [
9
+ 'Identify all entry points: HTTP endpoints, file uploads, WebSocket, CLI args',
10
+ 'Map authentication and authorisation boundaries',
11
+ 'A01 – Broken Access Control: ownership checks, privilege escalation paths',
12
+ 'A02 – Cryptographic Failures: cipher strength, data-in-transit, data-at-rest',
13
+ 'A03 – Injection: SQL, NoSQL, OS command, LDAP, template injection',
14
+ 'A04 – Insecure Design: missing input validation, business logic flaws',
15
+ 'A05 – Security Misconfiguration: debug flags, default creds, verbose errors',
16
+ 'A06 – Vulnerable Components: dependency CVEs, outdated libraries',
17
+ 'A07 – Authentication Failures: rate limiting, session management, token strength',
18
+ 'A08 – Software Integrity: deserialization, supply-chain, CI integrity checks',
19
+ 'A09 – Logging Failures: audit trail completeness, sensitive data in logs',
20
+ 'A10 – SSRF: user-supplied URLs in outbound calls',
21
+ 'Aggregate findings, calculate score, produce verdict and remediation plan',
22
+ ],
23
+ checklist: [
24
+ 'All HTTP routes require authentication where data is user-specific',
25
+ 'Object-level authorisation verifies ownership before returning or mutating records',
26
+ 'No MD5 or SHA-1 used for password hashing or data integrity',
27
+ 'TLS enforced on all external connections; HSTS header present',
28
+ 'SQL queries use parameterised statements or ORM; no string concatenation',
29
+ 'eval() and new Function() constructors are absent from production code',
30
+ 'Input validated with schema library (zod/joi) at every API boundary',
31
+ 'Error responses do not leak stack traces or internal file paths',
32
+ 'Debug/development flags disabled in production builds',
33
+ 'Default credentials and example secrets removed from all config files',
34
+ 'Auth endpoints protected by rate limiting and account-lockout logic',
35
+ 'Session tokens stored in httpOnly, Secure, SameSite=Strict cookies',
36
+ 'Deserialisation of untrusted data avoided or performed with strict schema',
37
+ 'Audit log written for every sensitive operation (login, delete, privilege change)',
38
+ 'Passwords and secrets never appear in log output',
39
+ 'Outbound HTTP requests validate/whitelist target URLs; no raw user-supplied URLs',
40
+ 'npm audit / yarn audit run in CI with zero high/critical failure threshold',
41
+ 'Security headers set: CSP, X-Content-Type-Options, X-Frame-Options, Referrer-Policy',
42
+ ],
43
+ pitfalls: [
44
+ 'Trusting client-supplied IDs without server-side ownership validation (IDOR)',
45
+ 'Comparing password hashes with == instead of a constant-time function',
46
+ 'Sending res.json(err) in Express error handlers — leaks internal details',
47
+ 'Forgetting to validate JWT claims server-side; client-side role inflation',
48
+ 'Server-Side Template Injection when user input is interpolated into templates',
49
+ 'Prototype pollution through lodash merge on untrusted objects',
50
+ 'CORS wildcard (*) combined with credentials:true',
51
+ 'Logging req.body at DEBUG level — captures passwords in plaintext',
52
+ ],
53
+ patterns: [
54
+ 'Parameterised queries / prepared statements for all DB access',
55
+ 'Repository pattern isolates data access and makes auth injection consistent',
56
+ 'Middleware chain: authenticate → authorise → validate → handle',
57
+ 'Allow-list validation (reject unknown fields) via zod strict() mode',
58
+ 'Centralised error handler strips internal details before response',
59
+ 'Structured logging with automatic redaction of secret fields',
60
+ ],
61
+ duration_estimate: context?.includes('large') ? '4-6 hours' : '1-2 hours',
62
+ };
63
+ }
64
+ const CHECKS = [
65
+ // A01 – Broken Access Control
66
+ {
67
+ regex: /req\.params\.(id|userId|user_id)\b/,
68
+ severity: 'high',
69
+ category: 'A01 Broken Access Control',
70
+ description: 'req.params.id used — verify ownership check exists to prevent IDOR.',
71
+ fix: 'Assert req.user.id === record.userId before returning or mutating the resource.',
72
+ cwe: 'CWE-639',
73
+ owasp: 'A01:2021',
74
+ },
75
+ {
76
+ regex: /role\s*=\s*req\.body\.role|req\.body\[['"]role['"]\]/,
77
+ severity: 'critical',
78
+ category: 'A01 Broken Access Control',
79
+ description: 'Role assigned directly from request body — allows privilege escalation.',
80
+ fix: 'Never accept role from client input. Derive roles server-side from the session.',
81
+ cwe: 'CWE-269',
82
+ owasp: 'A01:2021',
83
+ },
84
+ // A02 – Cryptographic Failures
85
+ {
86
+ regex: /createHash\s*\(\s*['"](?:md5|sha1)['"]\s*\)/i,
87
+ severity: 'high',
88
+ category: 'A02 Cryptographic Failures',
89
+ description: 'Weak cryptographic hash (MD5/SHA-1) detected.',
90
+ fix: 'Replace with SHA-256 or SHA-512 for hashing; use bcrypt/argon2 for passwords.',
91
+ cwe: 'CWE-327',
92
+ owasp: 'A02:2021',
93
+ },
94
+ {
95
+ regex: /createCipher\s*\(\s*['"](?:des|rc4)['"]\s*\)/i,
96
+ severity: 'high',
97
+ category: 'A02 Cryptographic Failures',
98
+ description: 'Broken symmetric cipher (DES/RC4) detected.',
99
+ fix: 'Replace with AES-256-GCM.',
100
+ cwe: 'CWE-327',
101
+ owasp: 'A02:2021',
102
+ },
103
+ {
104
+ regex: /http:\/\/(?!localhost|127\.0\.0\.1|0\.0\.0\.0)/,
105
+ severity: 'medium',
106
+ category: 'A02 Cryptographic Failures',
107
+ description: 'Plain HTTP URL detected — data transmitted without encryption.',
108
+ fix: 'Use HTTPS for all external URLs. Enforce HSTS in production.',
109
+ cwe: 'CWE-319',
110
+ owasp: 'A02:2021',
111
+ },
112
+ // A03 – Injection
113
+ {
114
+ regex: /['"`]\s*(?:SELECT|INSERT|UPDATE|DELETE)\b[^'"`]*\+\s*(?:req\.|params\.|body\.|query\.)\w+/i,
115
+ severity: 'critical',
116
+ category: 'A03 Injection',
117
+ description: 'String concatenation inside SQL query — SQL injection risk.',
118
+ fix: 'Use parameterised queries: db.query("SELECT ... WHERE id = $1", [id])',
119
+ cwe: 'CWE-89',
120
+ owasp: 'A03:2021',
121
+ },
122
+ {
123
+ regex: /\beval\s*\(|new\s+Function\s*\(/,
124
+ severity: 'critical',
125
+ category: 'A03 Injection',
126
+ description: 'eval() or new Function() detected — JavaScript injection vector.',
127
+ fix: 'Remove eval(). Use JSON.parse() for data or a dedicated expression parser.',
128
+ cwe: 'CWE-95',
129
+ owasp: 'A03:2021',
130
+ },
131
+ {
132
+ regex: /(?:exec|execSync|spawn)\s*\(\s*`[^`]*\$\{(?:req|params|body|query)\./,
133
+ severity: 'critical',
134
+ category: 'A03 Injection',
135
+ description: 'User input interpolated into shell command — OS command injection.',
136
+ fix: 'Use execFile() with a fixed command and an array of sanitised arguments.',
137
+ cwe: 'CWE-78',
138
+ owasp: 'A03:2021',
139
+ },
140
+ // A04 – Insecure Design
141
+ {
142
+ regex: /req\.body\.\w+\s*(?:&&|\|\||,|\))[^;]{0,120}(?:\.save\s*\(|\.create\s*\(|\.insert\s*\()/,
143
+ severity: 'medium',
144
+ category: 'A04 Insecure Design',
145
+ description: 'Request body values passed to persistence layer without visible validation.',
146
+ fix: 'Validate and sanitise all inputs with zod or joi before saving.',
147
+ cwe: 'CWE-20',
148
+ owasp: 'A04:2021',
149
+ },
150
+ // A05 – Security Misconfiguration
151
+ {
152
+ regex: /debug\s*[:=]\s*true/i,
153
+ severity: 'medium',
154
+ category: 'A05 Security Misconfiguration',
155
+ description: 'Debug mode flag set to true in source.',
156
+ fix: 'Guard debug features with NODE_ENV checks; never enable in production.',
157
+ cwe: 'CWE-16',
158
+ owasp: 'A05:2021',
159
+ },
160
+ {
161
+ regex: /password\s*[:=]\s*['"](?:admin|root|password|123456|secret|test|demo)['"]/i,
162
+ severity: 'critical',
163
+ category: 'A05 Security Misconfiguration',
164
+ description: 'Default or trivial credential detected in source.',
165
+ fix: 'Remove default credentials. Store only bcrypt hashes; move to env vars.',
166
+ cwe: 'CWE-1392',
167
+ owasp: 'A05:2021',
168
+ },
169
+ {
170
+ regex: /res\s*\.\s*(?:json|send)\s*\(\s*(?:err|error)\s*\)/,
171
+ severity: 'medium',
172
+ category: 'A05 Security Misconfiguration',
173
+ description: 'Raw error object sent in HTTP response — may expose internals.',
174
+ fix: 'Use a centralised error handler that maps errors to safe user-facing messages.',
175
+ cwe: 'CWE-209',
176
+ owasp: 'A05:2021',
177
+ },
178
+ // A06 – Vulnerable Components
179
+ {
180
+ regex: /require\s*\(\s*['"]node-serialize['"]\s*\)|from\s+['"]node-serialize['"]/,
181
+ severity: 'critical',
182
+ category: 'A06 Vulnerable Components',
183
+ description: 'node-serialize has a known Remote Code Execution vulnerability.',
184
+ fix: 'Remove node-serialize. Use JSON.parse() for safe deserialisation.',
185
+ cwe: 'CWE-502',
186
+ owasp: 'A06:2021',
187
+ },
188
+ {
189
+ regex: /require\s*\(\s*['"]request['"]\s*\)|from\s+['"]request['"]/,
190
+ severity: 'low',
191
+ category: 'A06 Vulnerable Components',
192
+ description: 'The "request" package is deprecated and unmaintained.',
193
+ fix: 'Replace with native fetch() (Node 18+), axios, or got.',
194
+ owasp: 'A06:2021',
195
+ },
196
+ // A07 – Authentication Failures
197
+ {
198
+ regex: /localStorage\s*\.\s*setItem\s*\(\s*['"][^'"]*(?:token|jwt|auth)[^'"]*['"]/i,
199
+ severity: 'high',
200
+ category: 'A07 Authentication Failures',
201
+ description: 'Auth token stored in localStorage — vulnerable to XSS theft.',
202
+ fix: 'Store tokens in httpOnly, Secure, SameSite=Strict cookies.',
203
+ cwe: 'CWE-922',
204
+ owasp: 'A07:2021',
205
+ },
206
+ {
207
+ regex: /router\s*\.\s*post\s*\(\s*['"]\/(?:login|signin|auth)['"]/i,
208
+ severity: 'high',
209
+ category: 'A07 Authentication Failures',
210
+ description: 'Auth endpoint found — verify rate limiting is applied.',
211
+ fix: 'Apply express-rate-limit to all auth routes to prevent brute-force attacks.',
212
+ cwe: 'CWE-307',
213
+ owasp: 'A07:2021',
214
+ },
215
+ // A08 – Software Integrity
216
+ {
217
+ regex: /JSON\.parse\s*\(\s*(?:req\.|body\.|params\.|query\.)\w+/,
218
+ severity: 'medium',
219
+ category: 'A08 Software Integrity',
220
+ description: 'JSON.parse on user-supplied data without visible try/catch or schema validation.',
221
+ fix: 'Wrap JSON.parse in try/catch and validate the result structure with zod.',
222
+ cwe: 'CWE-502',
223
+ owasp: 'A08:2021',
224
+ },
225
+ // A09 – Logging Failures
226
+ {
227
+ regex: /console\s*\.\s*log\s*\([^)]*(?:password|passwd|secret|token|apikey|api_key)[^)]*\)/i,
228
+ severity: 'high',
229
+ category: 'A09 Logging Failures',
230
+ description: 'Sensitive value (password/secret/token) may be written to logs.',
231
+ fix: 'Never log sensitive fields. Redact before passing to the logger.',
232
+ cwe: 'CWE-532',
233
+ owasp: 'A09:2021',
234
+ },
235
+ // A10 – SSRF
236
+ {
237
+ regex: /(?:fetch|axios\.get|axios\.post|http\.get)\s*\(\s*(?:req\.|body\.|params\.|query\.)\w+/,
238
+ severity: 'critical',
239
+ category: 'A10 SSRF',
240
+ description: 'User-supplied value passed directly to HTTP client — SSRF risk.',
241
+ fix: 'Validate the URL against a strict allow-list of permitted domains. Reject internal IP ranges.',
242
+ cwe: 'CWE-918',
243
+ owasp: 'A10:2021',
244
+ },
245
+ ];
246
+ // ─── Public API ────────────────────────────────────────────────────────────
247
+ export function analyze(code, context) {
248
+ const findings = [];
249
+ for (const check of CHECKS) {
250
+ if (check.regex.test(code)) {
251
+ const finding = {
252
+ severity: check.severity,
253
+ category: check.category,
254
+ description: check.description,
255
+ fix: check.fix,
256
+ owasp: check.owasp,
257
+ };
258
+ if (check.cwe)
259
+ finding.cwe = check.cwe;
260
+ findings.push(finding);
261
+ }
262
+ }
263
+ const critical = findings.filter(f => f.severity === 'critical').length;
264
+ const high = findings.filter(f => f.severity === 'high').length;
265
+ const medium = findings.filter(f => f.severity === 'medium').length;
266
+ const low = findings.filter(f => f.severity === 'low').length;
267
+ const raw = 100 - (critical * 25 + high * 10 + medium * 5 + low * 2);
268
+ const score = Math.max(0, raw);
269
+ const verdict = score >= 90 ? 'approved'
270
+ : score >= 70 ? 'approved_with_warnings'
271
+ : score >= 50 ? 'needs_revision'
272
+ : 'rejected';
273
+ const subject = context ?? 'provided code';
274
+ const summary = findings.length === 0
275
+ ? `No OWASP Top 10 violations detected in ${subject}. Score: ${score}/100.`
276
+ : `Found ${findings.length} issue(s) in ${subject}: ${critical} critical, ${high} high, ${medium} medium, ${low} low. Score: ${score}/100 — ${verdict.replace(/_/g, ' ')}.`;
277
+ return {
278
+ agent: 'security-scanner',
279
+ subject,
280
+ findings,
281
+ score,
282
+ verdict,
283
+ summary,
284
+ critical_count: critical,
285
+ high_count: high,
286
+ };
287
+ }
288
+ //# sourceMappingURL=scanner.js.map
@@ -0,0 +1,212 @@
1
+ // ─── Plan ──────────────────────────────────────────────────────────────────
2
+ export function plan(task, _context) {
3
+ return {
4
+ agent: 'secrets',
5
+ task,
6
+ tier: 1,
7
+ approach: 'Systematically detect, rotate, and vault all credentials. ' +
8
+ 'Apply defence-in-depth: scan source, enforce pre-commit hooks, ' +
9
+ 'use a secrets manager, and never let secrets reach version control.',
10
+ steps: [
11
+ 'Run static scan (this agent) across the entire codebase including .env files',
12
+ 'Identify all credential types: API keys, DB connection strings, private keys, tokens',
13
+ 'Rotate any exposed credentials immediately — assume they are compromised',
14
+ 'Move all secrets to a secrets manager (AWS Secrets Manager, Vault, Doppler)',
15
+ 'Replace hardcoded values with environment-variable references',
16
+ 'Add .env* to .gitignore; add .env.example with placeholder values',
17
+ 'Install a pre-commit hook (git-secrets, gitleaks) to block future commits',
18
+ 'Configure CI/CD secret scanning (GitHub secret scanning, Trufflehog action)',
19
+ 'Set minimum secret rotation period in policy (90 days for API keys, 30 for DB)',
20
+ 'Document which services own which secrets in a secrets inventory',
21
+ ],
22
+ checklist: [
23
+ 'No secrets committed to the repository (scan with gitleaks/trufflehog)',
24
+ '.env files listed in .gitignore at the repo root',
25
+ '.env.example present with only placeholder values, no real secrets',
26
+ 'All API keys loaded from process.env at runtime, not import-time constants',
27
+ 'AWS credentials use IAM roles / instance profiles, not access key + secret pairs',
28
+ 'Private keys stored in a hardware security module or secrets manager',
29
+ 'JWT_SECRET is at least 256 bits of random entropy, not a dictionary word',
30
+ 'Database connection strings contain no credentials (use socket auth or Secrets Manager)',
31
+ 'GitHub tokens scoped to minimal required permissions and set to expire',
32
+ 'Secret scanning enabled in GitHub repository settings',
33
+ 'Pre-commit hook configured to block secrets (git-secrets or gitleaks)',
34
+ 'CI pipeline fails if any secret pattern is detected in changed files',
35
+ 'Secrets rotated after any team-member departure or suspected exposure',
36
+ 'Audit log maintained of who accessed each secret and when',
37
+ ],
38
+ pitfalls: [
39
+ 'Committing .env files accidentally when .gitignore is misconfigured',
40
+ 'Hardcoding secrets in Dockerfile ARG/ENV layers visible in image history',
41
+ 'Logging full request headers which include Authorization bearer tokens',
42
+ 'Storing secrets in client-side code bundled into the browser',
43
+ 'Using short or guessable JWT secrets ("secret", "mysecret", "1234")',
44
+ 'Checking in AWS credentials profile files (~/.aws/credentials) via CI runners',
45
+ 'Embedding secrets in CI/CD YAML files instead of using encrypted variables',
46
+ ],
47
+ patterns: [
48
+ 'Twelve-Factor App: config via environment variables',
49
+ 'Secrets manager pattern: centralised vault with short-lived leases',
50
+ 'Secret rotation pattern: automated rotation with zero-downtime swap',
51
+ 'Pre-commit hook pattern: block secrets before they enter git history',
52
+ ],
53
+ duration_estimate: '2-4 hours for full secrets audit and remediation',
54
+ };
55
+ }
56
+ const PATTERNS = [
57
+ {
58
+ type: 'AWS Access Key',
59
+ regex: /AKIA[0-9A-Z]{16}/,
60
+ severity: 'critical',
61
+ fix: 'Immediately revoke this AWS access key in the IAM console. Use IAM roles or instance profiles instead.',
62
+ },
63
+ {
64
+ type: 'AWS Secret Access Key',
65
+ regex: /aws_secret_access_key\s*=\s*['"]?[A-Za-z0-9/+]{40}['"]?/i,
66
+ severity: 'critical',
67
+ fix: 'Rotate the AWS secret access key immediately. Store credentials in AWS Secrets Manager or via instance role.',
68
+ },
69
+ {
70
+ type: 'GitHub Token (ghp_)',
71
+ regex: /ghp_[a-zA-Z0-9]{36}/,
72
+ severity: 'critical',
73
+ fix: 'Revoke this GitHub personal access token immediately. Use short-lived tokens with minimal scopes.',
74
+ },
75
+ {
76
+ type: 'GitHub Token (env var)',
77
+ regex: /github_token\s*=\s*['"][a-zA-Z0-9_]{20,}['"]/i,
78
+ severity: 'high',
79
+ fix: 'Move the GitHub token to a CI/CD secret variable. Never hardcode tokens.',
80
+ },
81
+ {
82
+ type: 'RSA Private Key',
83
+ regex: /-----BEGIN RSA PRIVATE KEY-----/,
84
+ severity: 'critical',
85
+ fix: 'Remove the private key from source. Store in a secrets manager or HSM. Rotate the key pair immediately.',
86
+ },
87
+ {
88
+ type: 'EC Private Key',
89
+ regex: /-----BEGIN EC PRIVATE KEY-----/,
90
+ severity: 'critical',
91
+ fix: 'Remove the private key from source. Store in a secrets manager or HSM. Rotate the key pair immediately.',
92
+ },
93
+ {
94
+ type: 'OpenSSH Private Key',
95
+ regex: /-----BEGIN OPENSSH PRIVATE KEY-----/,
96
+ severity: 'critical',
97
+ fix: 'Remove the private key from source. Store in a secrets manager or HSM. Rotate the key pair immediately.',
98
+ },
99
+ {
100
+ type: 'API Key (generic)',
101
+ regex: /(?:api_key|apikey|api-key)\s*[:=]\s*['"][a-zA-Z0-9_\-]{20,}['"]/i,
102
+ severity: 'high',
103
+ fix: 'Move the API key to an environment variable. Load via process.env.API_KEY at runtime.',
104
+ },
105
+ {
106
+ type: 'JWT Secret',
107
+ regex: /jwt_secret\s*[:=]\s*['"][^'"]{8,}['"]/i,
108
+ severity: 'high',
109
+ fix: 'Move JWT_SECRET to an environment variable. Use at least 256 bits of random entropy.',
110
+ },
111
+ {
112
+ type: 'Hardcoded Password',
113
+ regex: /password\s*[:=]\s*['"][^'"]{4,}['"]/i,
114
+ severity: 'high',
115
+ fix: 'Remove hardcoded password. Store in environment variable and load at runtime.',
116
+ },
117
+ {
118
+ type: 'MongoDB Connection String',
119
+ regex: /mongodb(?:\+srv)?:\/\/[^:]+:[^@]+@/,
120
+ severity: 'critical',
121
+ fix: 'Rotate MongoDB credentials immediately. Use environment variable MONGODB_URI with no credentials in source.',
122
+ },
123
+ {
124
+ type: 'PostgreSQL Connection String',
125
+ regex: /postgres(?:ql)?:\/\/[^:]+:[^@]+@/,
126
+ severity: 'critical',
127
+ fix: 'Rotate PostgreSQL credentials immediately. Use DATABASE_URL environment variable.',
128
+ },
129
+ {
130
+ type: 'MySQL Connection String',
131
+ regex: /mysql:\/\/[^:]+:[^@]+@/,
132
+ severity: 'critical',
133
+ fix: 'Rotate MySQL credentials immediately. Use DATABASE_URL environment variable.',
134
+ },
135
+ {
136
+ type: 'Slack Token',
137
+ regex: /xox[baprs]-[0-9A-Za-z\-]{10,}/,
138
+ severity: 'high',
139
+ fix: 'Revoke this Slack token immediately. Store in a secrets manager.',
140
+ },
141
+ {
142
+ type: 'Generic High-Entropy Secret',
143
+ regex: /(?:secret|token|key|passwd)\s*[:=]\s*['"][A-Za-z0-9+/=_\-]{32,}['"]/i,
144
+ severity: 'medium',
145
+ fix: 'Review this value. If it is a secret, move it to an environment variable or secrets manager.',
146
+ },
147
+ ];
148
+ // ─── Helper: mask value ────────────────────────────────────────────────────
149
+ function maskValue(raw) {
150
+ const match = raw.match(/['"]([^'"]+)['"]/);
151
+ const secret = match ? match[1] : raw.replace(/.*[:=]\s*/, '');
152
+ return secret.length >= 4 ? `${secret.slice(0, 4)}****` : '****';
153
+ }
154
+ // ─── Public API ────────────────────────────────────────────────────────────
155
+ export function scan(text) {
156
+ const findings = [];
157
+ const lines = text.split('\n');
158
+ for (let lineIndex = 0; lineIndex < lines.length; lineIndex++) {
159
+ const line = lines[lineIndex];
160
+ for (const pattern of PATTERNS) {
161
+ const match = line.match(pattern.regex);
162
+ if (match) {
163
+ findings.push({
164
+ type: pattern.type,
165
+ value: maskValue(match[0]),
166
+ line: lineIndex + 1,
167
+ severity: pattern.severity,
168
+ fix: pattern.fix,
169
+ });
170
+ break; // one finding per pattern per line
171
+ }
172
+ }
173
+ }
174
+ return findings;
175
+ }
176
+ export function analyze(code, context) {
177
+ const secretFindings = scan(code);
178
+ const findings = secretFindings.map(sf => ({
179
+ severity: sf.severity,
180
+ category: 'Credential Exposure',
181
+ description: `${sf.type} detected at line ${sf.line} (value: ${sf.value})`,
182
+ fix: sf.fix,
183
+ location: `line ${sf.line}`,
184
+ cwe: 'CWE-798',
185
+ owasp: 'A02:2021',
186
+ }));
187
+ const critical = findings.filter(f => f.severity === 'critical').length;
188
+ const high = findings.filter(f => f.severity === 'high').length;
189
+ const medium = findings.filter(f => f.severity === 'medium').length;
190
+ const low = findings.filter(f => f.severity === 'low').length;
191
+ const raw = 100 - (critical * 25 + high * 10 + medium * 5 + low * 2);
192
+ const score = Math.max(0, raw);
193
+ const verdict = score >= 90 ? 'approved'
194
+ : score >= 70 ? 'approved_with_warnings'
195
+ : score >= 50 ? 'needs_revision'
196
+ : 'rejected';
197
+ const subject = context ?? 'provided code';
198
+ const summary = findings.length === 0
199
+ ? `No credentials or secrets detected in ${subject}. Score: ${score}/100.`
200
+ : `Found ${findings.length} credential(s) in ${subject}: ${critical} critical, ${high} high, ${medium} medium. Score: ${score}/100 — ${verdict.replace(/_/g, ' ')}.`;
201
+ return {
202
+ agent: 'secrets',
203
+ subject,
204
+ findings,
205
+ score,
206
+ verdict,
207
+ summary,
208
+ critical_count: critical,
209
+ high_count: high,
210
+ };
211
+ }
212
+ //# sourceMappingURL=secrets.js.map
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1,56 @@
1
+ export function plan(task, context) {
2
+ const t = (task + ' ' + (context ?? '')).toLowerCase();
3
+ const isCron = t.includes('cron') || t.includes('schedule') || t.includes('recurring') || t.includes('daily') || t.includes('weekly');
4
+ const isPipeline = t.includes('pipeline') || t.includes('ci') || t.includes('workflow') || t.includes('trigger') || t.includes('webhook');
5
+ const isScript = t.includes('script') || t.includes('automat') || t.includes('batch') || t.includes('bulk');
6
+ const approach = isCron
7
+ ? 'Design the cron job with three safety properties: idempotency (running it twice should be safe), observability (every run logs start/end/result), and alerting (failed runs must page someone). The most common cron bug is silent failure — the job stops running and nobody notices for weeks.'
8
+ : isPipeline
9
+ ? 'Design the pipeline with exactly-once execution semantics where possible. Each stage should be independently retryable. Every stage logs its input and output. The pipeline must have a dead-letter mechanism for events that fail after max retries.'
10
+ : isScript
11
+ ? 'Write the automation script as a dry-run first: add a --dry-run flag that shows what would happen without doing it. Test the dry-run output before removing the flag. Automation that cannot be previewed should not exist.'
12
+ : 'Design the automation with four properties: idempotent (safe to re-run), observable (logs start/end/result), alertable (failures surface immediately), and reversible (can undo if wrong).';
13
+ return {
14
+ agent: 'automation',
15
+ task,
16
+ tier: 2,
17
+ approach,
18
+ steps: [
19
+ 'Define the trigger: what starts this automation? (schedule, event, webhook, manual)',
20
+ 'Define the idempotency strategy: what prevents duplicate execution from causing harm?',
21
+ 'Define the happy path: what are the exact steps in order?',
22
+ 'Define the failure modes: what can go wrong at each step?',
23
+ 'Design retry logic: how many retries, with what backoff, before giving up?',
24
+ 'Design the dead-letter path: what happens to items that fail after max retries?',
25
+ 'Add structured logging: every run logs start (with input), each step result, and end (with outcome)',
26
+ 'Add alerting: failed runs must produce an alert, not just a log entry',
27
+ 'Add a dry-run mode for scripts that modify data',
28
+ 'Test the failure path explicitly — do not assume the happy path covers everything',
29
+ ],
30
+ checklist: [
31
+ '[ ] Trigger defined and documented',
32
+ '[ ] Idempotency strategy implemented',
33
+ '[ ] Retry logic with bounded backoff',
34
+ '[ ] Dead-letter mechanism for permanent failures',
35
+ '[ ] Structured logging on every run',
36
+ '[ ] Alert on failure (not just log)',
37
+ '[ ] Dry-run mode for destructive operations',
38
+ '[ ] Failure path tested explicitly',
39
+ ],
40
+ pitfalls: [
41
+ 'Silent failure — cron jobs that fail without alerting are the most dangerous automation',
42
+ 'No idempotency — running the job twice sends duplicate emails, charges customers twice',
43
+ 'Unbounded retries — a failing job retries forever and blocks the queue',
44
+ 'No dry-run — automation that modifies data cannot be safely previewed before running',
45
+ 'Logging only on failure — you cannot diagnose why it failed without knowing what it was doing',
46
+ ],
47
+ patterns: [
48
+ 'IDOA framework: Idempotent → Observable → Alertable → Dry-run-capable',
49
+ 'Dead-letter queue: every event that fails max retries goes here, never silently dropped',
50
+ 'Structured run log: { job, run_id, started_at, input_count, success_count, error_count, ended_at }',
51
+ 'Failure-first testing: write the test for the failure path before the happy path',
52
+ ],
53
+ duration_estimate: '2-6 hours',
54
+ };
55
+ }
56
+ //# sourceMappingURL=automation.js.map
@@ -0,0 +1,49 @@
1
+ export function plan(task, context) {
2
+ const t = (task + ' ' + (context ?? '')).toLowerCase();
3
+ const isCreate = t.includes('creat') || t.includes('scaffold') || t.includes('new file') || t.includes('add');
4
+ const isDelete = t.includes('delet') || t.includes('remov') || t.includes('clean') || t.includes('purge');
5
+ const isMove = t.includes('mov') || t.includes('renam') || t.includes('restructur') || t.includes('reorgan');
6
+ const approach = isDelete
7
+ ? 'Before deleting: verify nothing imports the file (grep for the filename and all its exports). Check git log to understand why it was created. If it is safe to delete, remove it and fix all broken imports. Never delete without checking references first.'
8
+ : isMove
9
+ ? 'Before moving: map all import paths that reference this file. Update every import after moving. Run the build to confirm no broken imports remain. Update any barrel index files that re-export the moved module.'
10
+ : isCreate
11
+ ? 'Create files in the right location: match the existing directory conventions. Add the new file to any relevant barrel index. Do not create a new directory when an existing one fits. Name the file to match its primary export.'
12
+ : 'Execute the file operation safely. For any destructive operation (delete, overwrite): verify the operation is correct before running it. For moves and renames: update all references atomically.';
13
+ return {
14
+ agent: 'file-manager',
15
+ task,
16
+ tier: 1,
17
+ approach,
18
+ steps: [
19
+ 'Identify the exact files to create, modify, move, or delete',
20
+ 'For deletes: grep for all imports/references to the file before touching it',
21
+ 'For moves: list all files that import from the source path',
22
+ 'Execute the operation',
23
+ 'Update all import paths that reference moved or deleted files',
24
+ 'Update barrel index files (index.ts) if the file is re-exported',
25
+ 'Run the TypeScript build to confirm no broken imports',
26
+ 'Update the project map via veto_project_map_update',
27
+ ],
28
+ checklist: [
29
+ '[ ] References checked before any delete or rename',
30
+ '[ ] All import paths updated after move/rename',
31
+ '[ ] Barrel indexes updated',
32
+ '[ ] Build passes after operation',
33
+ '[ ] Project map updated via veto_project_map_update',
34
+ ],
35
+ pitfalls: [
36
+ 'Deleting a file without checking what imports it — silent build breakage',
37
+ 'Moving a file without updating all import paths — TypeScript will error',
38
+ 'Creating a new directory when an existing one is the right home',
39
+ 'Forgetting to update barrel index files after adding/removing a module',
40
+ ],
41
+ patterns: [
42
+ 'Reference-before-delete: always grep for imports before deleting a file',
43
+ 'Atomic rename: update the file and all its references in a single operation',
44
+ 'Barrel maintenance: every add/remove in a directory requires checking the index.ts',
45
+ ],
46
+ duration_estimate: '15-60 minutes',
47
+ };
48
+ }
49
+ //# sourceMappingURL=file-manager.js.map