@kevinrabun/judges 3.56.0 → 3.58.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/CHANGELOG.md +24 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +112 -0
- package/dist/cli.js.map +1 -1
- package/dist/commands/assertion-density.d.ts +5 -0
- package/dist/commands/assertion-density.d.ts.map +1 -0
- package/dist/commands/assertion-density.js +264 -0
- package/dist/commands/assertion-density.js.map +1 -0
- package/dist/commands/async-safety.d.ts +5 -0
- package/dist/commands/async-safety.d.ts.map +1 -0
- package/dist/commands/async-safety.js +267 -0
- package/dist/commands/async-safety.js.map +1 -0
- package/dist/commands/cache-audit.d.ts +5 -0
- package/dist/commands/cache-audit.d.ts.map +1 -0
- package/dist/commands/cache-audit.js +220 -0
- package/dist/commands/cache-audit.js.map +1 -0
- package/dist/commands/clone-detect.d.ts +5 -0
- package/dist/commands/clone-detect.d.ts.map +1 -0
- package/dist/commands/clone-detect.js +233 -0
- package/dist/commands/clone-detect.js.map +1 -0
- package/dist/commands/comment-drift.d.ts +5 -0
- package/dist/commands/comment-drift.d.ts.map +1 -0
- package/dist/commands/comment-drift.js +229 -0
- package/dist/commands/comment-drift.js.map +1 -0
- package/dist/commands/contract-verify.d.ts +5 -0
- package/dist/commands/contract-verify.d.ts.map +1 -0
- package/dist/commands/contract-verify.js +317 -0
- package/dist/commands/contract-verify.js.map +1 -0
- package/dist/commands/dead-code-detect.d.ts +5 -0
- package/dist/commands/dead-code-detect.d.ts.map +1 -0
- package/dist/commands/dead-code-detect.js +256 -0
- package/dist/commands/dead-code-detect.js.map +1 -0
- package/dist/commands/encoding-safety.d.ts +5 -0
- package/dist/commands/encoding-safety.d.ts.map +1 -0
- package/dist/commands/encoding-safety.js +276 -0
- package/dist/commands/encoding-safety.js.map +1 -0
- package/dist/commands/error-ux.d.ts +5 -0
- package/dist/commands/error-ux.d.ts.map +1 -0
- package/dist/commands/error-ux.js +253 -0
- package/dist/commands/error-ux.js.map +1 -0
- package/dist/commands/event-leak.d.ts +5 -0
- package/dist/commands/event-leak.d.ts.map +1 -0
- package/dist/commands/event-leak.js +263 -0
- package/dist/commands/event-leak.js.map +1 -0
- package/dist/commands/idempotency-audit.d.ts +5 -0
- package/dist/commands/idempotency-audit.d.ts.map +1 -0
- package/dist/commands/idempotency-audit.js +223 -0
- package/dist/commands/idempotency-audit.js.map +1 -0
- package/dist/commands/input-guard.d.ts +5 -0
- package/dist/commands/input-guard.d.ts.map +1 -0
- package/dist/commands/input-guard.js +256 -0
- package/dist/commands/input-guard.js.map +1 -0
- package/dist/commands/privilege-path.d.ts +5 -0
- package/dist/commands/privilege-path.d.ts.map +1 -0
- package/dist/commands/privilege-path.js +234 -0
- package/dist/commands/privilege-path.js.map +1 -0
- package/dist/commands/state-integrity.d.ts +5 -0
- package/dist/commands/state-integrity.d.ts.map +1 -0
- package/dist/commands/state-integrity.js +284 -0
- package/dist/commands/state-integrity.js.map +1 -0
- package/dist/commands/timeout-audit.d.ts +5 -0
- package/dist/commands/timeout-audit.d.ts.map +1 -0
- package/dist/commands/timeout-audit.js +211 -0
- package/dist/commands/timeout-audit.js.map +1 -0
- package/dist/commands/type-boundary.d.ts +5 -0
- package/dist/commands/type-boundary.d.ts.map +1 -0
- package/dist/commands/type-boundary.js +236 -0
- package/dist/commands/type-boundary.js.map +1 -0
- package/package.json +1 -1
- package/server.json +2 -2
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Comment drift — detect stale, misleading, or contradictory inline comments.
|
|
3
|
+
*/
|
|
4
|
+
import { readFileSync, readdirSync, statSync } from "fs";
|
|
5
|
+
import { join, extname } from "path";
|
|
6
|
+
// ─── File Collection ────────────────────────────────────────────────────────
|
|
7
|
+
const CODE_EXTS = new Set([".ts", ".tsx", ".js", ".jsx", ".py", ".java", ".go", ".rs"]);
|
|
8
|
+
function collectFiles(dir, max = 300) {
|
|
9
|
+
const files = [];
|
|
10
|
+
function walk(d) {
|
|
11
|
+
if (files.length >= max)
|
|
12
|
+
return;
|
|
13
|
+
let entries;
|
|
14
|
+
try {
|
|
15
|
+
entries = readdirSync(d);
|
|
16
|
+
}
|
|
17
|
+
catch {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
for (const e of entries) {
|
|
21
|
+
if (files.length >= max)
|
|
22
|
+
return;
|
|
23
|
+
if (e.startsWith(".") || e === "node_modules" || e === "dist" || e === "build")
|
|
24
|
+
continue;
|
|
25
|
+
const full = join(d, e);
|
|
26
|
+
try {
|
|
27
|
+
if (statSync(full).isDirectory())
|
|
28
|
+
walk(full);
|
|
29
|
+
else if (CODE_EXTS.has(extname(full)))
|
|
30
|
+
files.push(full);
|
|
31
|
+
}
|
|
32
|
+
catch {
|
|
33
|
+
/* skip */
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
walk(dir);
|
|
38
|
+
return files;
|
|
39
|
+
}
|
|
40
|
+
// ─── Analysis ───────────────────────────────────────────────────────────────
|
|
41
|
+
function analyzeFile(filepath) {
|
|
42
|
+
const issues = [];
|
|
43
|
+
let content;
|
|
44
|
+
try {
|
|
45
|
+
content = readFileSync(filepath, "utf-8");
|
|
46
|
+
}
|
|
47
|
+
catch {
|
|
48
|
+
return issues;
|
|
49
|
+
}
|
|
50
|
+
const lines = content.split("\n");
|
|
51
|
+
for (let i = 0; i < lines.length; i++) {
|
|
52
|
+
const line = lines[i];
|
|
53
|
+
const commentMatch = line.match(/\/\/\s*(.+)|#\s*(.+)/);
|
|
54
|
+
if (!commentMatch)
|
|
55
|
+
continue;
|
|
56
|
+
const comment = (commentMatch[1] || commentMatch[2] || "").trim();
|
|
57
|
+
if (!comment || comment.length < 5)
|
|
58
|
+
continue;
|
|
59
|
+
// TODO/FIXME/HACK without ticket reference
|
|
60
|
+
if (/\b(?:TODO|FIXME|HACK|XXX|TEMP)\b/i.test(comment)) {
|
|
61
|
+
if (!/[A-Z]+-\d+|#\d+|https?:\/\//i.test(comment)) {
|
|
62
|
+
issues.push({
|
|
63
|
+
file: filepath,
|
|
64
|
+
line: i + 1,
|
|
65
|
+
issue: "TODO/FIXME without ticket reference",
|
|
66
|
+
severity: "medium",
|
|
67
|
+
detail: `"${comment.slice(0, 60)}" — link to issue tracker for accountability`,
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
// Comment says "returns X" but function returns different
|
|
72
|
+
if (/returns?\s+(?:true|false|null|undefined|void|nothing|string|number|array)/i.test(comment)) {
|
|
73
|
+
const nextLines = lines.slice(i + 1, Math.min(i + 10, lines.length)).join("\n");
|
|
74
|
+
const returnMatch = comment.match(/returns?\s+(true|false|null|undefined|void|nothing)/i);
|
|
75
|
+
if (returnMatch) {
|
|
76
|
+
const stated = returnMatch[1].toLowerCase();
|
|
77
|
+
if (stated === "true" && /return\s+false/i.test(nextLines)) {
|
|
78
|
+
issues.push({
|
|
79
|
+
file: filepath,
|
|
80
|
+
line: i + 1,
|
|
81
|
+
issue: "Comment contradicts return value",
|
|
82
|
+
severity: "high",
|
|
83
|
+
detail: `Comment says "returns true" but code returns false`,
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
if (stated === "false" && /return\s+true/i.test(nextLines)) {
|
|
87
|
+
issues.push({
|
|
88
|
+
file: filepath,
|
|
89
|
+
line: i + 1,
|
|
90
|
+
issue: "Comment contradicts return value",
|
|
91
|
+
severity: "high",
|
|
92
|
+
detail: `Comment says "returns false" but code returns true`,
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
// Comment references variable name not in nearby code
|
|
98
|
+
const varRefs = comment.match(/`(\w+)`/g);
|
|
99
|
+
if (varRefs) {
|
|
100
|
+
const contextBlock = lines.slice(Math.max(0, i - 3), Math.min(i + 5, lines.length)).join("\n");
|
|
101
|
+
for (const ref of varRefs) {
|
|
102
|
+
const name = ref.replace(/`/g, "");
|
|
103
|
+
if (name.length > 2 &&
|
|
104
|
+
!contextBlock.includes(name) &&
|
|
105
|
+
!/(?:true|false|null|undefined|string|number|boolean)/i.test(name)) {
|
|
106
|
+
issues.push({
|
|
107
|
+
file: filepath,
|
|
108
|
+
line: i + 1,
|
|
109
|
+
issue: "Comment references renamed/deleted variable",
|
|
110
|
+
severity: "high",
|
|
111
|
+
detail: `\`${name}\` mentioned in comment but not found in surrounding code`,
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
// Commented-out code (heuristic: looks like code, not English)
|
|
117
|
+
if (/^\s*\/\/\s*(?:const|let|var|function|if|for|while|return|import|export)\s+/.test(line)) {
|
|
118
|
+
issues.push({
|
|
119
|
+
file: filepath,
|
|
120
|
+
line: i + 1,
|
|
121
|
+
issue: "Commented-out code",
|
|
122
|
+
severity: "low",
|
|
123
|
+
detail: "Remove dead code — use version control to preserve history",
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
// Obvious/tautological comments
|
|
127
|
+
if (/\/\/\s*(?:increment|add one|set|assign|declare|initialize|create|return)/i.test(line)) {
|
|
128
|
+
const codePart = line.replace(/\/\/.*/, "").trim();
|
|
129
|
+
if (codePart) {
|
|
130
|
+
const commentLower = comment.toLowerCase();
|
|
131
|
+
// "increment i" on line "i++"
|
|
132
|
+
if (/\+\+|i\s*\+=\s*1/.test(codePart) && /increment/i.test(commentLower)) {
|
|
133
|
+
issues.push({
|
|
134
|
+
file: filepath,
|
|
135
|
+
line: i + 1,
|
|
136
|
+
issue: "Tautological comment",
|
|
137
|
+
severity: "low",
|
|
138
|
+
detail: "Comment restates the obvious — add 'why' not 'what'",
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
// "return result" on line "return result"
|
|
142
|
+
if (/^return\s+\w+/.test(codePart) && /^return\s/i.test(commentLower)) {
|
|
143
|
+
issues.push({
|
|
144
|
+
file: filepath,
|
|
145
|
+
line: i + 1,
|
|
146
|
+
issue: "Tautological comment",
|
|
147
|
+
severity: "low",
|
|
148
|
+
detail: "Comment restates the code — add context about why",
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
// Outdated parameter names in JSDoc-style comments
|
|
154
|
+
if (/\*\s*@param\s+\{?\w*\}?\s+(\w+)/.test(line)) {
|
|
155
|
+
const paramName = line.match(/@param\s+(?:\{[^}]*\}\s+)?(\w+)/)?.[1];
|
|
156
|
+
if (paramName) {
|
|
157
|
+
// Look for the function definition nearby
|
|
158
|
+
const funcBlock = lines.slice(Math.max(0, i - 5), Math.min(i + 15, lines.length)).join("\n");
|
|
159
|
+
const funcMatch = funcBlock.match(/(?:function|=>|\()\s*\(([^)]*)\)/);
|
|
160
|
+
if (funcMatch && !funcMatch[1].includes(paramName)) {
|
|
161
|
+
issues.push({
|
|
162
|
+
file: filepath,
|
|
163
|
+
line: i + 1,
|
|
164
|
+
issue: "@param references unknown parameter",
|
|
165
|
+
severity: "high",
|
|
166
|
+
detail: `@param ${paramName} not found in function signature — was it renamed?`,
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
return issues;
|
|
173
|
+
}
|
|
174
|
+
// ─── CLI ────────────────────────────────────────────────────────────────────
|
|
175
|
+
export function runCommentDrift(argv) {
|
|
176
|
+
if (argv.includes("--help") || argv.includes("-h")) {
|
|
177
|
+
console.log(`
|
|
178
|
+
judges comment-drift — Detect stale, misleading, or contradictory comments
|
|
179
|
+
|
|
180
|
+
Usage:
|
|
181
|
+
judges comment-drift [dir]
|
|
182
|
+
judges comment-drift src/ --format json
|
|
183
|
+
|
|
184
|
+
Options:
|
|
185
|
+
[dir] Directory to scan (default: .)
|
|
186
|
+
--format json JSON output
|
|
187
|
+
--help, -h Show this help
|
|
188
|
+
|
|
189
|
+
Checks: TODO without tickets, contradictory return comments, renamed variable references,
|
|
190
|
+
commented-out code, tautological comments, outdated @param names.
|
|
191
|
+
`);
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
const format = argv.find((_a, i) => argv[i - 1] === "--format") || "text";
|
|
195
|
+
const dir = argv.find((a) => !a.startsWith("-") && argv.indexOf(a) > 0) || ".";
|
|
196
|
+
const files = collectFiles(dir);
|
|
197
|
+
const allIssues = [];
|
|
198
|
+
for (const f of files)
|
|
199
|
+
allIssues.push(...analyzeFile(f));
|
|
200
|
+
const highCount = allIssues.filter((i) => i.severity === "high").length;
|
|
201
|
+
const medCount = allIssues.filter((i) => i.severity === "medium").length;
|
|
202
|
+
const score = Math.max(0, 100 - highCount * 8 - medCount * 3);
|
|
203
|
+
if (format === "json") {
|
|
204
|
+
console.log(JSON.stringify({
|
|
205
|
+
issues: allIssues,
|
|
206
|
+
score,
|
|
207
|
+
summary: { high: highCount, medium: medCount, total: allIssues.length },
|
|
208
|
+
timestamp: new Date().toISOString(),
|
|
209
|
+
}, null, 2));
|
|
210
|
+
}
|
|
211
|
+
else {
|
|
212
|
+
const badge = score >= 80 ? "✅ FRESH" : score >= 50 ? "⚠️ DRIFTED" : "❌ STALE";
|
|
213
|
+
console.log(`\n Comment Quality: ${badge} (${score}/100)\n ─────────────────────────────`);
|
|
214
|
+
if (allIssues.length === 0) {
|
|
215
|
+
console.log(" No comment drift detected.\n");
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
218
|
+
for (const issue of allIssues.slice(0, 25)) {
|
|
219
|
+
const icon = issue.severity === "high" ? "🔴" : issue.severity === "medium" ? "🟡" : "🔵";
|
|
220
|
+
console.log(` ${icon} ${issue.issue}`);
|
|
221
|
+
console.log(` ${issue.file}:${issue.line}`);
|
|
222
|
+
console.log(` ${issue.detail}`);
|
|
223
|
+
}
|
|
224
|
+
if (allIssues.length > 25)
|
|
225
|
+
console.log(` ... and ${allIssues.length - 25} more`);
|
|
226
|
+
console.log(`\n Total: ${allIssues.length} | High: ${highCount} | Medium: ${medCount} | Score: ${score}/100\n`);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
//# sourceMappingURL=comment-drift.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"comment-drift.js","sourceRoot":"","sources":["../../src/commands/comment-drift.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,IAAI,CAAC;AACzD,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAYrC,+EAA+E;AAE/E,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC;AAExF,SAAS,YAAY,CAAC,GAAW,EAAE,GAAG,GAAG,GAAG;IAC1C,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,SAAS,IAAI,CAAC,CAAS;QACrB,IAAI,KAAK,CAAC,MAAM,IAAI,GAAG;YAAE,OAAO;QAChC,IAAI,OAAiB,CAAC;QACtB,IAAI,CAAC;YACH,OAAO,GAAG,WAAW,CAAC,CAAC,CAAwB,CAAC;QAClD,CAAC;QAAC,MAAM,CAAC;YACP,OAAO;QACT,CAAC;QACD,KAAK,MAAM,CAAC,IAAI,OAAO,EAAE,CAAC;YACxB,IAAI,KAAK,CAAC,MAAM,IAAI,GAAG;gBAAE,OAAO;YAChC,IAAI,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,cAAc,IAAI,CAAC,KAAK,MAAM,IAAI,CAAC,KAAK,OAAO;gBAAE,SAAS;YACzF,MAAM,IAAI,GAAG,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;YACxB,IAAI,CAAC;gBACH,IAAI,QAAQ,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE;oBAAE,IAAI,CAAC,IAAI,CAAC,CAAC;qBACxC,IAAI,SAAS,CAAC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;QAED,KAAK,MAAM,KAAK,IAAI,SAAS,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC;YAC3C,MAAM,IAAI,GAAG,KAAK,CAAC,QAAQ,KAAK,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;YAC1F,OAAO,CAAC,GAAG,CAAC,OAAO,IAAI,IAAI,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC;YAC1C,OAAO,CAAC,GAAG,CAAC,WAAW,KAAK,CAAC,IAAI,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC;YACnD,OAAO,CAAC,GAAG,CAAC,WAAW,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC;QACzC,CAAC;QACD,IAAI,SAAS,CAAC,MAAM,GAAG,EAAE;YAAE,OAAO,CAAC,GAAG,CAAC,eAAe,SAAS,CAAC,MAAM,GAAG,EAAE,OAAO,CAAC,CAAC;QAEpF,OAAO,CAAC,GAAG,CAAC,gBAAgB,SAAS,CAAC,MAAM,YAAY,SAAS,cAAc,QAAQ,aAAa,KAAK,QAAQ,CAAC,CAAC;IACrH,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contract-verify.d.ts","sourceRoot":"","sources":["../../src/commands/contract-verify.ts"],"names":[],"mappings":"AAAA;;GAEG;AA6QH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,IAAI,CAiFtD"}
|
|
@@ -0,0 +1,317 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Contract verify — check that API implementations match declared contracts (OpenAPI, GraphQL, protobuf).
|
|
3
|
+
*/
|
|
4
|
+
import { readFileSync, readdirSync, statSync, existsSync } from "fs";
|
|
5
|
+
import { join, extname } from "path";
|
|
6
|
+
// ─── File Collection ────────────────────────────────────────────────────────
|
|
7
|
+
const CODE_EXTS = new Set([".ts", ".tsx", ".js", ".jsx", ".py", ".java", ".go"]);
|
|
8
|
+
function collectFiles(dir, max = 300) {
|
|
9
|
+
const files = [];
|
|
10
|
+
function walk(d) {
|
|
11
|
+
if (files.length >= max)
|
|
12
|
+
return;
|
|
13
|
+
let entries;
|
|
14
|
+
try {
|
|
15
|
+
entries = readdirSync(d);
|
|
16
|
+
}
|
|
17
|
+
catch {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
for (const e of entries) {
|
|
21
|
+
if (files.length >= max)
|
|
22
|
+
return;
|
|
23
|
+
if (e.startsWith(".") || e === "node_modules" || e === "dist" || e === "build")
|
|
24
|
+
continue;
|
|
25
|
+
const full = join(d, e);
|
|
26
|
+
try {
|
|
27
|
+
if (statSync(full).isDirectory())
|
|
28
|
+
walk(full);
|
|
29
|
+
else if (CODE_EXTS.has(extname(full)) || /\.(json|ya?ml|graphql|gql|proto)$/.test(full))
|
|
30
|
+
files.push(full);
|
|
31
|
+
}
|
|
32
|
+
catch {
|
|
33
|
+
/* skip */
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
walk(dir);
|
|
38
|
+
return files;
|
|
39
|
+
}
|
|
40
|
+
// ─── OpenAPI Analysis ───────────────────────────────────────────────────────
|
|
41
|
+
function findOpenApiSpecs(dir) {
|
|
42
|
+
const specs = [];
|
|
43
|
+
const candidates = [
|
|
44
|
+
"openapi.json",
|
|
45
|
+
"openapi.yaml",
|
|
46
|
+
"openapi.yml",
|
|
47
|
+
"swagger.json",
|
|
48
|
+
"swagger.yaml",
|
|
49
|
+
"swagger.yml",
|
|
50
|
+
"api-spec.json",
|
|
51
|
+
"api-spec.yaml",
|
|
52
|
+
];
|
|
53
|
+
for (const name of candidates) {
|
|
54
|
+
const p = join(dir, name);
|
|
55
|
+
if (existsSync(p))
|
|
56
|
+
specs.push(p);
|
|
57
|
+
}
|
|
58
|
+
// Also check docs/ and api/ subdirectories
|
|
59
|
+
for (const sub of ["docs", "api", "spec", "specs"]) {
|
|
60
|
+
const subDir = join(dir, sub);
|
|
61
|
+
if (existsSync(subDir)) {
|
|
62
|
+
for (const name of candidates) {
|
|
63
|
+
const p = join(subDir, name);
|
|
64
|
+
if (existsSync(p))
|
|
65
|
+
specs.push(p);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return specs;
|
|
70
|
+
}
|
|
71
|
+
function extractOpenApiPaths(specContent) {
|
|
72
|
+
const routes = [];
|
|
73
|
+
try {
|
|
74
|
+
const spec = JSON.parse(specContent);
|
|
75
|
+
const paths = spec.paths || {};
|
|
76
|
+
for (const [path, methods] of Object.entries(paths)) {
|
|
77
|
+
if (typeof methods !== "object" || methods === null)
|
|
78
|
+
continue;
|
|
79
|
+
for (const [method, detail] of Object.entries(methods)) {
|
|
80
|
+
if (["get", "post", "put", "delete", "patch"].includes(method)) {
|
|
81
|
+
const responses = detail && typeof detail === "object" && "responses" in detail
|
|
82
|
+
? Object.keys(detail.responses)
|
|
83
|
+
: [];
|
|
84
|
+
routes.push({ method: method.toUpperCase(), path, responses });
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
catch {
|
|
90
|
+
/* not valid JSON spec */
|
|
91
|
+
}
|
|
92
|
+
return routes;
|
|
93
|
+
}
|
|
94
|
+
// ─── Implementation Analysis ────────────────────────────────────────────────
|
|
95
|
+
function analyzeContractDrift(files, specRoutes) {
|
|
96
|
+
const issues = [];
|
|
97
|
+
const implementedRoutes = new Set();
|
|
98
|
+
// Find implemented routes in code
|
|
99
|
+
for (const filepath of files) {
|
|
100
|
+
let content;
|
|
101
|
+
try {
|
|
102
|
+
content = readFileSync(filepath, "utf-8");
|
|
103
|
+
}
|
|
104
|
+
catch {
|
|
105
|
+
continue;
|
|
106
|
+
}
|
|
107
|
+
if (!/\.(?:ts|tsx|js|jsx|py|java|go)$/.test(filepath))
|
|
108
|
+
continue;
|
|
109
|
+
const lines = content.split("\n");
|
|
110
|
+
for (let i = 0; i < lines.length; i++) {
|
|
111
|
+
const line = lines[i];
|
|
112
|
+
const routeMatch = line.match(/(?:router|app)\.\s*(get|post|put|delete|patch)\s*\(\s*['"]([^'"]+)['"]/i);
|
|
113
|
+
if (routeMatch) {
|
|
114
|
+
const method = routeMatch[1].toUpperCase();
|
|
115
|
+
const path = routeMatch[2];
|
|
116
|
+
implementedRoutes.add(`${method} ${path}`);
|
|
117
|
+
// Check response status codes used
|
|
118
|
+
const handlerBlock = lines.slice(i, Math.min(i + 30, lines.length)).join("\n");
|
|
119
|
+
const usedStatuses = [...handlerBlock.matchAll(/\.status\s*\(\s*(\d+)\s*\)/g)].map((m) => m[1]);
|
|
120
|
+
// Compare with spec
|
|
121
|
+
const specRoute = specRoutes.find((r) => r.method === method && normalizePath(r.path) === normalizePath(path));
|
|
122
|
+
if (specRoute) {
|
|
123
|
+
for (const status of usedStatuses) {
|
|
124
|
+
if (!specRoute.responses.includes(status)) {
|
|
125
|
+
issues.push({
|
|
126
|
+
file: filepath,
|
|
127
|
+
line: i + 1,
|
|
128
|
+
issue: "Undocumented response status",
|
|
129
|
+
severity: "medium",
|
|
130
|
+
detail: `${method} ${path} returns status ${status} but spec only declares ${specRoute.responses.join(", ")}`,
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
// Response shape mismatch (heuristic: returning fields not in type)
|
|
137
|
+
if (/res\.(?:json|send)\s*\(\s*\{/.test(line)) {
|
|
138
|
+
const block = lines.slice(i, Math.min(i + 10, lines.length)).join("\n");
|
|
139
|
+
// Check for ad-hoc response properties that suggest undocumented fields
|
|
140
|
+
if (/password|secret|token|internal|debug|_\w+:/.test(block)) {
|
|
141
|
+
issues.push({
|
|
142
|
+
file: filepath,
|
|
143
|
+
line: i + 1,
|
|
144
|
+
issue: "Potentially sensitive field in response",
|
|
145
|
+
severity: "high",
|
|
146
|
+
detail: "Response object may include sensitive or internal-only fields not in API contract",
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
// Find spec routes not implemented
|
|
153
|
+
for (const route of specRoutes) {
|
|
154
|
+
const key = `${route.method} ${route.path}`;
|
|
155
|
+
const _normalizedKey = `${route.method} ${normalizePath(route.path)}`;
|
|
156
|
+
let found = false;
|
|
157
|
+
for (const impl of implementedRoutes) {
|
|
158
|
+
if (impl === key || normalizePath(impl.split(" ")[1]) === normalizePath(route.path)) {
|
|
159
|
+
found = true;
|
|
160
|
+
break;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
if (!found) {
|
|
164
|
+
issues.push({
|
|
165
|
+
file: "api-spec",
|
|
166
|
+
line: 0,
|
|
167
|
+
issue: "Spec route not implemented",
|
|
168
|
+
severity: "high",
|
|
169
|
+
detail: `${route.method} ${route.path} declared in OpenAPI spec but no matching handler found in code`,
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
return issues;
|
|
174
|
+
}
|
|
175
|
+
function normalizePath(path) {
|
|
176
|
+
return path.replace(/\{[^}]+\}/g, ":param").replace(/\/+$/, "");
|
|
177
|
+
}
|
|
178
|
+
// ─── General Contract Checks ────────────────────────────────────────────────
|
|
179
|
+
function analyzeGeneralContracts(files) {
|
|
180
|
+
const issues = [];
|
|
181
|
+
for (const filepath of files) {
|
|
182
|
+
let content;
|
|
183
|
+
try {
|
|
184
|
+
content = readFileSync(filepath, "utf-8");
|
|
185
|
+
}
|
|
186
|
+
catch {
|
|
187
|
+
continue;
|
|
188
|
+
}
|
|
189
|
+
if (!/\.(?:ts|tsx|js|jsx)$/.test(filepath))
|
|
190
|
+
continue;
|
|
191
|
+
const lines = content.split("\n");
|
|
192
|
+
for (let i = 0; i < lines.length; i++) {
|
|
193
|
+
const line = lines[i];
|
|
194
|
+
// Interface/type declared but response doesn't match
|
|
195
|
+
if (/interface\s+(\w+Response|.*Response)\s*\{/.test(line)) {
|
|
196
|
+
const ifaceName = line.match(/interface\s+(\w+)/)?.[1];
|
|
197
|
+
if (ifaceName && !content.includes(`as ${ifaceName}`) && !content.includes(`: ${ifaceName}`)) {
|
|
198
|
+
issues.push({
|
|
199
|
+
file: filepath,
|
|
200
|
+
line: i + 1,
|
|
201
|
+
issue: "Response type declared but not enforced",
|
|
202
|
+
severity: "medium",
|
|
203
|
+
detail: `\`${ifaceName}\` defined but never used as type constraint — response shape is unverified`,
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
// API version in URL doesn't match spec version
|
|
208
|
+
if (/['"]\/api\/v(\d+)/.test(line)) {
|
|
209
|
+
const version = line.match(/\/api\/v(\d+)/)?.[1];
|
|
210
|
+
if (version) {
|
|
211
|
+
const otherVersions = content.match(/\/api\/v(\d+)/g);
|
|
212
|
+
if (otherVersions) {
|
|
213
|
+
const versions = new Set(otherVersions.map((v) => v.match(/v(\d+)/)?.[1]));
|
|
214
|
+
if (versions.size > 1) {
|
|
215
|
+
issues.push({
|
|
216
|
+
file: filepath,
|
|
217
|
+
line: i + 1,
|
|
218
|
+
issue: "Mixed API versions in same file",
|
|
219
|
+
severity: "medium",
|
|
220
|
+
detail: `Multiple API versions found (${[...versions].join(", ")}) — may indicate incomplete migration`,
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
// Endpoint returns different shape based on condition
|
|
227
|
+
if (/res\.(?:json|send)\s*\(/.test(line)) {
|
|
228
|
+
const funcBlock = lines.slice(Math.max(0, i - 20), Math.min(i + 5, lines.length)).join("\n");
|
|
229
|
+
const jsonCalls = (funcBlock.match(/res\.(?:json|send)\s*\(/g) || []).length;
|
|
230
|
+
if (jsonCalls > 2) {
|
|
231
|
+
issues.push({
|
|
232
|
+
file: filepath,
|
|
233
|
+
line: i + 1,
|
|
234
|
+
issue: "Multiple response shapes in single handler",
|
|
235
|
+
severity: "low",
|
|
236
|
+
detail: `Handler has ${jsonCalls} different response points — clients may receive inconsistent shapes`,
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
return issues;
|
|
243
|
+
}
|
|
244
|
+
// ─── CLI ────────────────────────────────────────────────────────────────────
|
|
245
|
+
export function runContractVerify(argv) {
|
|
246
|
+
if (argv.includes("--help") || argv.includes("-h")) {
|
|
247
|
+
console.log(`
|
|
248
|
+
judges contract-verify — Check API implementations match declared contracts
|
|
249
|
+
|
|
250
|
+
Usage:
|
|
251
|
+
judges contract-verify [dir]
|
|
252
|
+
judges contract-verify src/ --format json
|
|
253
|
+
|
|
254
|
+
Options:
|
|
255
|
+
[dir] Directory to scan (default: .)
|
|
256
|
+
--format json JSON output
|
|
257
|
+
--help, -h Show this help
|
|
258
|
+
|
|
259
|
+
Checks: spec routes not implemented, undocumented response statuses, sensitive fields in responses,
|
|
260
|
+
unenforced response types, mixed API versions, inconsistent response shapes.
|
|
261
|
+
`);
|
|
262
|
+
return;
|
|
263
|
+
}
|
|
264
|
+
const format = argv.find((_a, i) => argv[i - 1] === "--format") || "text";
|
|
265
|
+
const dir = argv.find((a) => !a.startsWith("-") && argv.indexOf(a) > 0) || ".";
|
|
266
|
+
const files = collectFiles(dir);
|
|
267
|
+
// Find OpenAPI specs
|
|
268
|
+
const specFiles = findOpenApiSpecs(dir);
|
|
269
|
+
let specRoutes = [];
|
|
270
|
+
for (const s of specFiles) {
|
|
271
|
+
try {
|
|
272
|
+
const specContent = readFileSync(s, "utf-8");
|
|
273
|
+
specRoutes = specRoutes.concat(extractOpenApiPaths(specContent));
|
|
274
|
+
}
|
|
275
|
+
catch {
|
|
276
|
+
/* skip */
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
const allIssues = [];
|
|
280
|
+
if (specRoutes.length > 0) {
|
|
281
|
+
allIssues.push(...analyzeContractDrift(files, specRoutes));
|
|
282
|
+
}
|
|
283
|
+
allIssues.push(...analyzeGeneralContracts(files));
|
|
284
|
+
const highCount = allIssues.filter((i) => i.severity === "high").length;
|
|
285
|
+
const medCount = allIssues.filter((i) => i.severity === "medium").length;
|
|
286
|
+
const score = Math.max(0, 100 - highCount * 10 - medCount * 4);
|
|
287
|
+
if (format === "json") {
|
|
288
|
+
console.log(JSON.stringify({
|
|
289
|
+
issues: allIssues,
|
|
290
|
+
score,
|
|
291
|
+
summary: { high: highCount, medium: medCount, total: allIssues.length, specRoutes: specRoutes.length },
|
|
292
|
+
timestamp: new Date().toISOString(),
|
|
293
|
+
}, null, 2));
|
|
294
|
+
}
|
|
295
|
+
else {
|
|
296
|
+
const badge = score >= 80 ? "✅ ALIGNED" : score >= 50 ? "⚠️ DRIFTED" : "❌ MISMATCHED";
|
|
297
|
+
console.log(`\n Contract Alignment: ${badge} (${score}/100)\n ─────────────────────────────`);
|
|
298
|
+
if (specRoutes.length > 0)
|
|
299
|
+
console.log(` OpenAPI spec: ${specRoutes.length} routes found`);
|
|
300
|
+
else
|
|
301
|
+
console.log(" No OpenAPI spec found — running general contract checks only");
|
|
302
|
+
if (allIssues.length === 0) {
|
|
303
|
+
console.log(" No contract issues detected.\n");
|
|
304
|
+
return;
|
|
305
|
+
}
|
|
306
|
+
for (const issue of allIssues.slice(0, 25)) {
|
|
307
|
+
const icon = issue.severity === "high" ? "🔴" : issue.severity === "medium" ? "🟡" : "🔵";
|
|
308
|
+
console.log(` ${icon} ${issue.issue}`);
|
|
309
|
+
console.log(` ${issue.file}:${issue.line}`);
|
|
310
|
+
console.log(` ${issue.detail}`);
|
|
311
|
+
}
|
|
312
|
+
if (allIssues.length > 25)
|
|
313
|
+
console.log(` ... and ${allIssues.length - 25} more`);
|
|
314
|
+
console.log(`\n Total: ${allIssues.length} | High: ${highCount} | Medium: ${medCount} | Score: ${score}/100\n`);
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
//# sourceMappingURL=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