@kevinrabun/judges 3.117.0 → 3.117.1

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.
@@ -11,8 +11,25 @@
11
11
  // - Same-file inter-procedural taint (function parameter → return tracking)
12
12
  // - Guard clause sensitivity (validation guards reduce taint confidence)
13
13
  // ─────────────────────────────────────────────────────────────────────────────
14
- import ts from "typescript";
14
+ import { createRequire } from "node:module";
15
15
  import { normalizeLanguage } from "../language-patterns.js";
16
+ // Lazy-load the TypeScript compiler API so that modules which transitively
17
+ // import this file (e.g. the VS Code extension bundle) do not crash at load
18
+ // time when the `typescript` package is not available at runtime.
19
+ //
20
+ // In CJS bundles (esbuild for VS Code extension), `import.meta.url` is empty
21
+ // but the bundler emits a CJS `require` for externals — so `require` just
22
+ // works. In native ESM (tests, CLI), we use `createRequire` from the real
23
+ // `import.meta.url`.
24
+ let _ts;
25
+ function getTS() {
26
+ if (!_ts) {
27
+ const metaUrl = typeof import.meta?.url === "string" ? import.meta.url : undefined;
28
+ const req = metaUrl ? createRequire(metaUrl) : require;
29
+ _ts = req("typescript");
30
+ }
31
+ return _ts;
32
+ }
16
33
  // ─── Source / Sink Definitions ───────────────────────────────────────────────
17
34
  const SOURCE_PATTERNS = [
18
35
  { pattern: /\breq(?:uest)?\.(?:body|query|params|headers|cookies)\b/i, kind: "http-param" },
@@ -147,6 +164,7 @@ function containsWordBoundary(text, varName) {
147
164
  * Tracks which function parameters flow to return values.
148
165
  */
149
166
  function buildFunctionTaintMap(sourceFile, _taintMap) {
167
+ const ts = getTS();
150
168
  const result = new Map();
151
169
  ts.forEachChild(sourceFile, function walk(node) {
152
170
  if (ts.isFunctionDeclaration(node) ||
@@ -195,6 +213,7 @@ function buildFunctionTaintMap(sourceFile, _taintMap) {
195
213
  return result;
196
214
  }
197
215
  function getFnName(node) {
216
+ const ts = getTS();
198
217
  if (ts.isFunctionDeclaration(node) || ts.isMethodDeclaration(node)) {
199
218
  return node.name?.getText();
200
219
  }
@@ -688,7 +707,14 @@ export function analyzeTaintFlows(code, language) {
688
707
  switch (lang) {
689
708
  case "javascript":
690
709
  case "typescript":
691
- return analyzeTypeScriptTaint(code, lang);
710
+ try {
711
+ return analyzeTypeScriptTaint(code, lang);
712
+ }
713
+ catch {
714
+ // typescript package unavailable (e.g. VS Code extension bundle) —
715
+ // fall through to regex-based analysis
716
+ return analyzeRegexTaint(code, LANGUAGE_PATTERN_MAP[lang]);
717
+ }
692
718
  default: {
693
719
  const langPatterns = LANGUAGE_PATTERN_MAP[lang];
694
720
  return analyzeRegexTaint(code, langPatterns);
@@ -697,6 +723,7 @@ export function analyzeTaintFlows(code, language) {
697
723
  }
698
724
  // ─── TypeScript / JavaScript Taint Analysis ──────────────────────────────────
699
725
  function analyzeTypeScriptTaint(code, language) {
726
+ const ts = getTS();
700
727
  const scriptKind = language === "typescript" ? ts.ScriptKind.TS : ts.ScriptKind.JS;
701
728
  const sourceFile = ts.createSourceFile("input." + (language === "typescript" ? "ts" : "js"), code, ts.ScriptTarget.Latest, true, scriptKind);
702
729
  const flows = [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kevinrabun/judges",
3
- "version": "3.117.0",
3
+ "version": "3.117.1",
4
4
  "description": "45 specialized judges that evaluate AI-generated code for security, cost, and quality.",
5
5
  "mcpName": "io.github.KevinRabun/judges",
6
6
  "type": "module",
package/server.json CHANGED
@@ -7,12 +7,12 @@
7
7
  "url": "https://github.com/kevinrabun/judges",
8
8
  "source": "github"
9
9
  },
10
- "version": "3.117.0",
10
+ "version": "3.117.1",
11
11
  "packages": [
12
12
  {
13
13
  "registryType": "npm",
14
14
  "identifier": "@kevinrabun/judges",
15
- "version": "3.117.0",
15
+ "version": "3.117.1",
16
16
  "transport": {
17
17
  "type": "stdio"
18
18
  }