@noego/trust 0.1.0 → 0.2.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/README.md +32 -1
- package/dist/chunk-APNT6ZSM.js +2168 -0
- package/dist/chunk-APNT6ZSM.js.map +1 -0
- package/dist/cli/index.js +1 -1
- package/dist/eslint/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-2KNNLUSN.js +0 -1084
- package/dist/chunk-2KNNLUSN.js.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/eslint/guard.ts","../src/eslint/presets.ts","../src/eslint/zones.ts","../src/eslint/config.ts","../src/eslint/origin.ts","../src/eslint/policy.ts","../src/eslint/rule-setup.ts","../src/eslint/typescript.ts","../src/eslint/rules/untrusted-call-must-return-result.ts","../src/eslint/baseline.ts"],"sourcesContent":["// \"Is this node guarded?\" A node is guarded when, within the same function, it sits in the `try`\n// block of a TryStatement whose `catch` returns Result.err(...) on every path, or when the function\n// it sits in is the callback passed directly to Result.try / Result.tryAsync.\n\n/** Minimal ESTree node shape (avoids coupling to a specific @types/estree version). */\nexport interface AstNode {\n readonly type: string;\n parent?: AstNode;\n readonly [key: string]: unknown;\n}\n\nexport type CatchProblem = 'rethrow' | 'notResultErr' | 'rawCatchValue' | 'notAllPaths';\n\nexport type Guard =\n | { readonly status: 'unguarded' }\n | { readonly status: 'guarded'; readonly via: 'try' | 'sync-callback' | 'async-callback' }\n | { readonly status: 'badCatch'; readonly problem: CatchProblem };\n\nexport interface GuardContext {\n /** The returned expression is an `Err` (typed: by declaration; untyped: `Result.err(...)`/`err(...)` by name). */\n isResultErr(expression: AstNode): boolean;\n /** The call is `Result.err(...)` / `err(...)` itself (for the raw-caught-value check). */\n isErrCall(expression: AstNode): boolean;\n /** 'sync' for Result.try, 'async' for Result.tryAsync, else null. */\n trustTryKind(call: AstNode): 'sync' | 'async' | null;\n}\n\nexport const FUNCTION_TYPES = new Set(['FunctionDeclaration', 'FunctionExpression', 'ArrowFunctionExpression']);\nconst LOOP_OR_SWITCH = new Set(['ForStatement', 'ForInStatement', 'ForOfStatement', 'WhileStatement', 'DoWhileStatement', 'SwitchStatement']);\n\nexport const CATCH_MESSAGES: Record<CatchProblem, string> = {\n rethrow: '`catch` guarding {{target}} must return Result.err(...), not re-throw.',\n notResultErr: '`catch` guarding {{target}} must return Result.err(...) on every return.',\n rawCatchValue: 'Result.err(...) guarding {{target}} must not pass the raw caught value; normalize it to a typed error.',\n notAllPaths: '`catch` guarding {{target}} must return Result.err(...) on every path.',\n};\n\nfunction children(node: AstNode): AstNode[] {\n const result: AstNode[] = [];\n for (const key of Object.keys(node)) {\n if (key === 'parent') continue;\n const value = node[key];\n if (Array.isArray(value)) {\n for (const item of value) if (item && typeof (item as AstNode).type === 'string') result.push(item as AstNode);\n } else if (value && typeof (value as AstNode).type === 'string') {\n result.push(value as AstNode);\n }\n }\n return result;\n}\n\nfunction collectExits(node: AstNode, exits: AstNode[]): void {\n if (FUNCTION_TYPES.has(node.type)) return;\n if (node.type === 'ReturnStatement' || node.type === 'ThrowStatement') exits.push(node);\n for (const child of children(node)) collectExits(child, exits);\n}\n\nfunction containsBreakFor(node: AstNode, isRoot = true): boolean {\n if (FUNCTION_TYPES.has(node.type)) return false;\n if (!isRoot && LOOP_OR_SWITCH.has(node.type)) return false;\n if (node.type === 'BreakStatement' && !node.label) return true;\n return children(node).some((child) => containsBreakFor(child, false));\n}\n\n/** Every path through `statement` ends in return (or throw). */\nexport function alwaysExits(statement: AstNode | null | undefined): boolean {\n if (!statement) return false;\n switch (statement.type) {\n case 'ReturnStatement':\n case 'ThrowStatement':\n return true;\n case 'BlockStatement':\n return (statement.body as AstNode[]).some((child) => alwaysExits(child));\n case 'IfStatement':\n return alwaysExits(statement.consequent as AstNode) && alwaysExits(statement.alternate as AstNode | null);\n case 'SwitchStatement': {\n const cases = statement.cases as AstNode[];\n if (!cases.some((entry) => entry.test === null)) return false;\n if (containsBreakFor(statement)) return false;\n const last = cases[cases.length - 1];\n return (last.consequent as AstNode[]).some((child) => alwaysExits(child));\n }\n case 'TryStatement': {\n if (alwaysExits(statement.finalizer as AstNode | null)) return true;\n const handler = statement.handler as AstNode | null;\n return alwaysExits(statement.block as AstNode) && (!handler || alwaysExits(handler.body as AstNode));\n }\n case 'LabeledStatement':\n return alwaysExits(statement.body as AstNode);\n default:\n return false;\n }\n}\n\n/** Null when the catch clause returns Result.err(...) on every path, else the problem. */\nexport function catchProblem(handler: AstNode, context: GuardContext): CatchProblem | null {\n const exits: AstNode[] = [];\n collectExits(handler.body as AstNode, exits);\n const param = handler.param as AstNode | null;\n const paramName = param?.type === 'Identifier' ? (param.name as string) : null;\n for (const exit of exits) {\n if (exit.type === 'ThrowStatement') return 'rethrow';\n const argument = exit.argument as AstNode | null;\n if (!argument || !context.isResultErr(argument)) return 'notResultErr';\n if (paramName && context.isErrCall(argument)) {\n const [first] = argument.arguments as AstNode[];\n if (first?.type === 'Identifier' && first.name === paramName) return 'rawCatchValue';\n }\n }\n return alwaysExits(handler.body as AstNode) ? null : 'notAllPaths';\n}\n\n/** Innermost guard of `node` within its own function. */\nexport function guardOf(node: AstNode, context: GuardContext): Guard {\n let child: AstNode = node;\n let current = node.parent;\n while (current) {\n if (FUNCTION_TYPES.has(current.type)) {\n const call = current.parent;\n if (call?.type === 'CallExpression' && (call.arguments as AstNode[])[0] === current) {\n const kind = context.trustTryKind(call);\n if (kind) return { status: 'guarded', via: kind === 'sync' ? 'sync-callback' : 'async-callback' };\n }\n return { status: 'unguarded' };\n }\n if (current.type === 'TryStatement' && current.block === child) {\n const handler = current.handler as AstNode | null;\n if (handler) {\n const problem = catchProblem(handler, context);\n return problem ? { status: 'badCatch', problem } : { status: 'guarded', via: 'try' };\n }\n }\n child = current;\n current = current.parent;\n }\n return { status: 'unguarded' };\n}\n\nfunction isNamedErrCall(node: AstNode): boolean {\n if (node.type !== 'CallExpression') return false;\n const callee = node.callee as AstNode;\n if (callee.type === 'Identifier') return callee.name === 'err';\n if (callee.type !== 'MemberExpression') return false;\n const object = callee.object as AstNode;\n const property = callee.property as AstNode;\n return object.type === 'Identifier' && object.name === 'Result' && property.type === 'Identifier' && property.name === 'err';\n}\n\nfunction namedTryKind(call: AstNode): 'sync' | 'async' | null {\n const callee = call.callee as AstNode;\n if (callee.type === 'Identifier') {\n if (callee.name === 'tryResult') return 'sync';\n if (callee.name === 'tryResultAsync') return 'async';\n return null;\n }\n if (callee.type !== 'MemberExpression') return null;\n const object = callee.object as AstNode;\n const property = callee.property as AstNode;\n if (object.type !== 'Identifier' || object.name !== 'Result' || property.type !== 'Identifier') return null;\n if (property.name === 'try') return 'sync';\n if (property.name === 'tryAsync') return 'async';\n return null;\n}\n\n/** Name-based fallback for untyped linting. */\nexport const NAME_BASED_GUARD_CONTEXT: GuardContext = {\n isResultErr: isNamedErrCall,\n isErrCall: isNamedErrCall,\n trustTryKind: namedTryKind,\n};\n","// Built-in presets, referenced from a trust config as `\"extend\": \"<name>\"`.\n// Presets may only carry trust/distrust (no globs: those are relative to a project).\n\nexport interface PresetDefinition {\n readonly $comment?: string;\n readonly extend?: string;\n readonly trust?: readonly string[];\n readonly distrust?: readonly string[];\n}\n\nconst DEFAULT_PRESET: PresetDefinition = {\n $comment:\n 'Pure, in-memory JavaScript built-ins and Node APIs that do no I/O and cannot fail on typed input. ' +\n 'Deliberately NOT trusted: js:JSON (parse throws), js:URL, js:BigInt, js:structuredClone, ' +\n 'js:encodeURI*/decodeURI* (throw URIError), node:fs (except existsSync), node:child_process (except ' +\n 'ChildProcess listeners), node:net, node:http(s), node:crypto (except Hash, Hmac, randomUUID), ' +\n 'Buffer.from/alloc, process.*, EventEmitter.emit, every npm package.',\n trust: [\n // JavaScript built-ins (TypeScript lib).\n 'js:Array',\n 'js:ReadonlyArray',\n 'js:String',\n 'js:Number',\n 'js:Boolean',\n 'js:Math',\n 'js:Object',\n 'js:Map',\n 'js:ReadonlyMap',\n 'js:Set',\n 'js:ReadonlySet',\n 'js:WeakMap',\n 'js:WeakSet',\n 'js:Date',\n 'js:Error',\n 'js:RegExp',\n 'js:Promise',\n 'js:PromiseLike',\n 'js:Symbol',\n 'js:Iterator',\n 'js:IterableIterator',\n 'js:CallableFunction',\n 'js:Function',\n 'js:AbortController',\n 'js:AbortSignal',\n 'js:parseInt',\n 'js:parseFloat',\n 'js:isNaN',\n 'js:isFinite',\n 'js:TextEncoder',\n 'js:URLSearchParams',\n // Node built-in modules.\n // Member-level: existsSync returns false instead of throwing; the rest of node:fs stays untrusted.\n 'node:fs.existsSync',\n 'node:path',\n 'node:timers',\n 'node:util',\n 'node:events',\n // Member-level, in-memory only. Deliberately NOT trusted: node:crypto.createHash (unknown algorithm),\n // node:crypto.randomBytes (RangeError), ChildProcess.kill / process.kill (signal, permission).\n 'node:crypto.randomUUID',\n 'node:crypto.Hash',\n 'node:crypto.Hmac',\n 'node:os.tmpdir',\n 'node:os.platform',\n 'node:os.arch',\n 'node:os.EOL',\n 'node:child_process.ChildProcess.on',\n 'node:child_process.ChildProcess.once',\n 'node:child_process.ChildProcess.unref',\n // Node globals: in-memory Buffer operations. Deliberately NOT trusted: Buffer.from (wrong input\n // type), Buffer.alloc (RangeError), process.cwd (ENOENT when the directory is gone).\n 'node:global.Buffer.toString',\n 'node:global.Buffer.byteLength',\n 'node:global.Buffer.concat',\n 'node:global.Buffer.subarray',\n 'node:global.Buffer.equals',\n 'node:global.Buffer.indexOf',\n 'node:global.Buffer.isBuffer',\n // Listener bookkeeping only. Deliberately NOT trusted: EventEmitter.emit (re-throws listener errors,\n // throws on an unhandled 'error' event).\n 'node:global.EventEmitter.on',\n 'node:global.EventEmitter.off',\n 'node:global.EventEmitter.once',\n 'node:global.EventEmitter.removeListener',\n 'node:global.EventEmitter.listenerCount',\n // Node globals: the timer functions the node:timers module also exports, and their handles.\n 'node:global.setTimeout',\n 'node:global.clearTimeout',\n 'node:global.setInterval',\n 'node:global.clearInterval',\n 'node:global.setImmediate',\n 'node:global.clearImmediate',\n 'node:global.Timeout',\n 'node:global.Immediate',\n ],\n};\n\nexport const PRESETS: Readonly<Record<string, PresetDefinition>> = {\n default: DEFAULT_PRESET,\n};\n","// Glob zones (passthrough / ignore), with the same matcher ESLint flat config uses for\n// `files`/`ignores`: minimatch with `{ dot: true }`, a leading `./` stripped, patterns relative\n// to the directory of the config file that declared them, `!pattern` re-includes (last match wins).\n// Paths are realpath-resolved and posix-normalized before matching.\nimport { readdirSync, realpathSync } from 'node:fs';\nimport { isAbsolute, join, relative, sep } from 'node:path';\nimport { Minimatch } from 'minimatch';\n\nexport type Zone = 'checked' | 'passthrough' | 'ignore' | 'external';\n\nexport interface ZoneGroup {\n /** Config file that declared the patterns (for error messages). */\n readonly source: string;\n /** Realpath of the directory the patterns are relative to. */\n readonly baseDir: string;\n readonly patterns: readonly string[];\n}\n\nconst MINIMATCH_OPTIONS = { dot: true } as const;\nconst SKIPPED_DIRECTORIES = new Set(['node_modules', '.git']);\nconst matcherCache = new Map<string, Minimatch>();\n\nfunction matcher(pattern: string): Minimatch {\n let cached = matcherCache.get(pattern);\n if (!cached) {\n cached = new Minimatch(pattern, MINIMATCH_OPTIONS);\n matcherCache.set(pattern, cached);\n }\n return cached;\n}\n\nexport function toPosix(path: string): string {\n return sep === '/' ? path : path.split(sep).join('/');\n}\n\nexport function realpathOrSelf(path: string): string {\n try {\n return realpathSync.native(path);\n } catch {\n return path;\n }\n}\n\n/** Normalizes one configured pattern; returns an error message for an invalid one. */\nexport function normalizePattern(raw: string): { pattern: string } | { error: string } {\n const negated = raw.startsWith('!');\n let body = negated ? raw.slice(1) : raw;\n if (body.startsWith('./')) body = body.slice(2);\n if (body.length === 0) return { error: `empty glob \"${raw}\"` };\n if (isAbsolute(body) || /^[A-Za-z]:[\\\\/]/.test(body)) {\n return { error: `glob \"${raw}\" must be relative to the config file's directory` };\n }\n if (body.startsWith('../')) return { error: `glob \"${raw}\" must not leave the config file's directory` };\n if (body.endsWith('/')) body = `${body}**`;\n return { pattern: negated ? `!${body}` : body };\n}\n\n/** Posix path of `absolutePath` relative to `baseDir`, or null when it lies outside. */\nexport function relativeInside(baseDir: string, absolutePath: string): string | null {\n const rel = toPosix(relative(baseDir, absolutePath));\n if (rel === '' || rel.startsWith('../') || rel === '..' || isAbsolute(rel)) return null;\n return rel;\n}\n\n/** ESLint `ignores` semantics: patterns apply in order, a `!pattern` match un-includes. */\nexport function matchesPatterns(patterns: readonly string[], rel: string): boolean {\n let included = false;\n for (const pattern of patterns) {\n if (pattern.startsWith('!')) {\n if (included && matcher(pattern.slice(1)).match(rel)) included = false;\n } else if (!included && matcher(pattern).match(rel)) {\n included = true;\n }\n }\n return included;\n}\n\nexport function groupMatches(group: ZoneGroup, absoluteRealPath: string): boolean {\n const rel = relativeInside(group.baseDir, absoluteRealPath);\n return rel !== null && matchesPatterns(group.patterns, rel);\n}\n\nconst MAGIC = /[*?[\\]{}()!+@]/;\n\nfunction staticPrefix(pattern: string): string {\n const parts = pattern.split('/');\n const fixed: string[] = [];\n for (let index = 0; index < parts.length - 1; index += 1) {\n if (MAGIC.test(parts[index])) break;\n fixed.push(parts[index]);\n }\n return fixed.join('/');\n}\n\nfunction* walkFiles(baseDir: string, prefix: string): Generator<string> {\n const start = prefix ? join(baseDir, prefix) : baseDir;\n const stack = [start];\n while (stack.length > 0) {\n const directory = stack.pop() as string;\n let entries;\n try {\n entries = readdirSync(directory, { withFileTypes: true });\n } catch {\n continue;\n }\n for (const entry of entries) {\n const full = join(directory, entry.name);\n if (entry.isDirectory()) {\n if (!SKIPPED_DIRECTORIES.has(entry.name)) stack.push(full);\n } else {\n yield toPosix(relative(baseDir, full));\n }\n }\n }\n}\n\n/** True when at least one file under `baseDir` (node_modules and .git skipped) matches `pattern`. */\nexport function patternMatchesAnyFile(baseDir: string, pattern: string): boolean {\n const body = pattern.startsWith('!') ? pattern.slice(1) : pattern;\n const compiled = matcher(body);\n for (const rel of walkFiles(baseDir, staticPrefix(body))) {\n if (compiled.match(rel)) return true;\n }\n return false;\n}\n\nexport class Zones {\n private readonly cache = new Map<string, Zone>();\n\n constructor(\n /** Realpath of the project root (directory of the leaf trust config). */\n readonly rootDir: string,\n private readonly passthrough: readonly ZoneGroup[],\n private readonly ignore: readonly ZoneGroup[],\n ) {}\n\n /** Zone of a file. Ignore wins over passthrough; files outside the root or in node_modules are external. */\n zoneOf(fileName: string): Zone {\n const cached = this.cache.get(fileName);\n if (cached) return cached;\n const zone = this.compute(fileName);\n this.cache.set(fileName, zone);\n return zone;\n }\n\n /** Project-relative posix path (for `local:` origins and baselines), or the absolute path when outside. */\n relativePath(fileName: string): string {\n const real = realpathOrSelf(fileName);\n return relativeInside(this.rootDir, real) ?? toPosix(real);\n }\n\n private compute(fileName: string): Zone {\n const real = realpathOrSelf(fileName);\n const rel = relativeInside(this.rootDir, real);\n if (rel === null || rel.split('/').includes('node_modules')) return 'external';\n if (this.ignore.some((group) => groupMatches(group, real))) return 'ignore';\n if (this.passthrough.some((group) => groupMatches(group, real))) return 'passthrough';\n return 'checked';\n }\n}\n","// Loads trust.config.json:\n//\n// {\n// \"extend\": \"default\", // preset name or a path relative to this file\n// \"trust\": [\"zod\", { \"origin\": \"@noego/ioc\", \"reason\": \"DI container, no I/O\" }],\n// \"distrust\": [\"builtin:Array.from\"], // remove something inherited from the extend chain\n// \"passthrough\": [\"server/repositories/**\"], // not checked inside; calls into them are untrusted\n// \"ignore\": [\"**/*.test.ts\"] // not checked inside; calls into them are reported\n// }\n//\n// Trust resolution walks the chain from this file toward the root preset: the first level whose\n// distrust matches wins (untrusted), else the first level whose trust matches wins (trusted).\n// So a file's `distrust` beats everything it inherits. Within one file the same origin may not be\n// both trusted and distrusted.\n//\n// Globs use ESLint flat-config semantics (see ./zones.ts) and are relative to the directory of the\n// file that declares them. A glob that matches no file is a load error (typo protection).\nimport { existsSync, readFileSync, statSync } from 'node:fs';\nimport { dirname, isAbsolute, resolve } from 'node:path';\nimport { PRESETS, type PresetDefinition } from './presets.js';\nimport { normalizePattern, patternMatchesAnyFile, realpathOrSelf, type ZoneGroup } from './zones.js';\n\nexport type TrustEntry = string | { readonly origin: string; readonly reason?: string };\n\nexport interface TrustLevel {\n /** Config file path or `preset:<name>`. */\n readonly source: string;\n readonly trust: readonly string[];\n readonly distrust: readonly string[];\n}\n\nexport interface TrustConfig {\n /** Absolute path of the leaf config file. */\n readonly file: string;\n /** Realpath of the leaf config file's directory: the project root for zones and `local:` origins. */\n readonly rootDir: string;\n /** Leaf first, root preset last. */\n readonly levels: readonly TrustLevel[];\n readonly passthrough: readonly ZoneGroup[];\n readonly ignore: readonly ZoneGroup[];\n}\n\nexport interface LoadTrustConfigOptions {\n /** Check that every glob matches at least one file (default true). */\n readonly validateGlobs?: boolean;\n}\n\nexport class TrustConfigError extends Error {\n override readonly name = 'TrustConfigError';\n}\n\nconst FILE_KEYS = new Set(['$comment', 'extend', 'trust', 'distrust', 'passthrough', 'ignore']);\nconst PRESET_KEYS = new Set(['$comment', 'extend', 'trust', 'distrust']);\nconst ENTRY_KEYS = new Set(['origin', 'reason']);\n\ninterface RawLevel {\n readonly source: string;\n readonly baseDir: string | null;\n readonly extend?: string;\n readonly trust: string[];\n readonly distrust: string[];\n readonly passthrough: string[];\n readonly ignore: string[];\n}\n\n/**\n * Trust entries are matched exactly as written. Origin namespaces:\n * js:JSON.parse JavaScript built-ins (TypeScript lib)\n * node:fs.existsSync Node built-in modules (the `node:` import specifier)\n * node:global.process.cwd Node globals\n * zod.object, @scope/pkg.fn npm packages (bare package name)\n */\nexport function normalizeOrigin(origin: string): string {\n return origin.trim();\n}\n\n/** Prefixes from earlier origin naming; rejected with the replacement so a stale entry never silently stops matching. */\nfunction legacyOriginHint(origin: string): string | null {\n if (origin.startsWith('builtin:')) return `\"${origin}\" uses the old \"builtin:\" prefix; use \"js:${origin.slice('builtin:'.length)}\"`;\n if (origin === 'node' || origin.startsWith('node.')) {\n return `\"${origin}\" uses the old \"node.\" prefix for Node globals; use \"node:global${origin.slice('node'.length)}\"`;\n }\n return null;\n}\n\nfunction fail(source: string, message: string): never {\n throw new TrustConfigError(`trust config ${source}: ${message}`);\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\nfunction checkedOrigin(source: string, key: string, index: number, origin: string): string {\n const normalized = normalizeOrigin(origin);\n const hint = legacyOriginHint(normalized);\n if (hint) fail(source, `\"${key}[${index}]\": ${hint}`);\n return normalized;\n}\n\nfunction readEntries(source: string, key: string, value: unknown): string[] {\n if (value === undefined) return [];\n if (!Array.isArray(value)) fail(source, `\"${key}\" must be an array`);\n return value.map((entry, index) => {\n if (typeof entry === 'string') {\n if (!entry.trim()) fail(source, `\"${key}[${index}]\" must not be empty`);\n return checkedOrigin(source, key, index, entry);\n }\n if (!isRecord(entry)) fail(source, `\"${key}[${index}]\" must be a string or { origin, reason }`);\n for (const entryKey of Object.keys(entry)) {\n if (!ENTRY_KEYS.has(entryKey)) fail(source, `\"${key}[${index}]\" has unknown key \"${entryKey}\"`);\n }\n if (typeof entry.origin !== 'string' || !entry.origin.trim()) {\n fail(source, `\"${key}[${index}].origin\" must be a non-empty string`);\n }\n if (entry.reason !== undefined && typeof entry.reason !== 'string') {\n fail(source, `\"${key}[${index}].reason\" must be a string`);\n }\n return checkedOrigin(source, key, index, entry.origin);\n });\n}\n\nfunction readGlobs(source: string, key: string, value: unknown): string[] {\n if (value === undefined) return [];\n if (!Array.isArray(value)) fail(source, `\"${key}\" must be an array of globs`);\n return value.map((entry, index) => {\n if (typeof entry !== 'string') fail(source, `\"${key}[${index}]\" must be a string`);\n const normalized = normalizePattern(entry);\n if ('error' in normalized) fail(source, `\"${key}\": ${normalized.error}`);\n return normalized.pattern;\n });\n}\n\nfunction parseLevel(source: string, raw: unknown, allowedKeys: Set<string>, baseDir: string | null): RawLevel {\n if (!isRecord(raw)) fail(source, 'expected an object');\n for (const key of Object.keys(raw)) {\n if (!allowedKeys.has(key)) fail(source, `unknown key \"${key}\"`);\n }\n if (raw.extend !== undefined && (typeof raw.extend !== 'string' || !raw.extend)) {\n fail(source, '\"extend\" must be a non-empty string');\n }\n const trust = readEntries(source, 'trust', raw.trust);\n const distrust = readEntries(source, 'distrust', raw.distrust);\n const both = trust.filter((origin) => distrust.includes(origin));\n if (both.length > 0) fail(source, `\"${both[0]}\" is both trusted and distrusted`);\n return {\n source,\n baseDir,\n extend: raw.extend as string | undefined,\n trust,\n distrust,\n passthrough: readGlobs(source, 'passthrough', raw.passthrough),\n ignore: readGlobs(source, 'ignore', raw.ignore),\n };\n}\n\nfunction readFileLevel(file: string): RawLevel {\n if (!existsSync(file)) throw new TrustConfigError(`trust config not found: ${file}`);\n let raw: unknown;\n try {\n raw = JSON.parse(readFileSync(file, 'utf8'));\n } catch (error) {\n fail(file, `invalid JSON (${error instanceof Error ? error.message : String(error)})`);\n }\n return parseLevel(file, raw, FILE_KEYS, realpathOrSelf(dirname(file)));\n}\n\nfunction readPresetLevel(name: string): RawLevel {\n const preset: PresetDefinition | undefined = PRESETS[name];\n if (!preset) throw new TrustConfigError(`unknown preset \"${name}\"`);\n return parseLevel(`preset:${name}`, preset, PRESET_KEYS, null);\n}\n\nfunction nextSource(level: RawLevel): string | null {\n const extend = level.extend;\n if (!extend) return null;\n if (extend.startsWith('.') || isAbsolute(extend)) {\n if (level.baseDir === null) fail(level.source, `presets may only extend presets, not \"${extend}\"`);\n return resolve(level.baseDir, extend);\n }\n if (!PRESETS[extend]) fail(level.source, `unknown preset \"${extend}\"`);\n return `preset:${extend}`;\n}\n\nfunction readChain(configFile: string): RawLevel[] {\n const chain: RawLevel[] = [];\n const visited: string[] = [];\n let source: string | null = resolve(configFile);\n while (source) {\n if (visited.includes(source)) {\n throw new TrustConfigError(`trust config cycle: ${[...visited, source].join(' -> ')}`);\n }\n visited.push(source);\n const level = source.startsWith('preset:') ? readPresetLevel(source.slice('preset:'.length)) : readFileLevel(source);\n chain.push(level);\n source = nextSource(level);\n }\n return chain;\n}\n\nfunction zoneGroups(chain: RawLevel[], key: 'passthrough' | 'ignore', validate: boolean): ZoneGroup[] {\n const groups: ZoneGroup[] = [];\n for (const level of chain) {\n const patterns = level[key];\n if (patterns.length === 0 || level.baseDir === null) continue;\n if (validate) {\n for (const pattern of patterns) {\n if (!patternMatchesAnyFile(level.baseDir, pattern)) {\n fail(level.source, `${key} glob \"${pattern}\" matches no files under ${level.baseDir}`);\n }\n }\n }\n groups.push({ source: level.source, baseDir: level.baseDir, patterns });\n }\n return groups;\n}\n\n/** Loads and validates a trust config file and its `extend` chain. Throws TrustConfigError. */\nexport function loadTrustConfig(configFile: string, options: LoadTrustConfigOptions = {}): TrustConfig {\n const file = resolve(configFile);\n const chain = readChain(file);\n const validate = options.validateGlobs ?? true;\n return {\n file,\n rootDir: realpathOrSelf(dirname(file)),\n levels: chain.map(({ source, trust, distrust }) => ({ source, trust, distrust })),\n passthrough: zoneGroups(chain, 'passthrough', validate),\n ignore: zoneGroups(chain, 'ignore', validate),\n };\n}\n\nconst cache = new Map<string, { mtimeMs: number; config: TrustConfig }>();\n\n/** Cached by path + mtime of the leaf file, so long-lived ESLint servers pick up edits. */\nexport function loadTrustConfigCached(configFile: string): TrustConfig {\n const file = resolve(configFile);\n const mtimeMs = existsSync(file) ? statSync(file).mtimeMs : -1;\n const hit = cache.get(file);\n if (hit && hit.mtimeMs === mtimeMs) return hit.config;\n const config = loadTrustConfig(file);\n cache.set(file, { mtimeMs, config });\n return config;\n}\n\n/** Union of every trust entry in the chain (for tooling and tests). */\nexport function effectiveTrustList(config: TrustConfig): string[] {\n return [...new Set(config.levels.flatMap((level) => level.trust))];\n}\n","// Where does a callee come from? An \"origin\" is the string trust entries match against.\n//\n// JS built-in (TypeScript lib) js:JSON.parse, js:Array.map, js:Reflect.get, js:URL\n// Node built-in module node:fs.readFileSync, node:fs/promises.readFile, node:child_process.spawn\n// Node global (@types/node) node:global.setTimeout, node:global.Buffer.from, node:global.process.cwd\n// other declare module \"x\" x.member (ambient modules outside @types/node keep their name)\n// npm package zod.object, better-sqlite3.Database.prepare, @scope/pkg.fn\n// first-party, passthrough zone local:server/repositories/x.ts#XRepository.find\n// first-party, ignore zone local:server/testing/fixture.ts#makeThing\n// first-party, checked zone (no origin: trusted, it is checked itself)\n//\n// The `node:` prefix keeps Node's own modules apart from npm packages of the same name (`path`,\n// `events`, `util`, `buffer`, … all exist on npm). Member paths are the named containers from the\n// module down to the declaration, so trusting `js:JSON` covers `js:JSON.parse` while\n// `js:JSON.stringify` alone does not. Linked packages (npm link, file:) resolve to paths outside\n// node_modules; they are recognised by their nearest package.json being outside the project root.\nimport { existsSync, readFileSync } from 'node:fs';\nimport { dirname, join } from 'node:path';\nimport type * as TS from 'typescript';\nimport type { TypeScript } from './typescript.js';\nimport { realpathOrSelf, toPosix, type Zone, type Zones } from './zones.js';\n\nexport type OriginInfo =\n // `base` is the package/module/namespace part of `origin`, before any member path (`js:`,\n // `node:fs/promises`, `node:global`, `lodash.merge`). Trust entries may extend the base only with\n // `/` (subpath), so `lodash` never covers the package `lodash.merge`.\n | { readonly kind: 'external'; readonly origin: string; readonly base: string; readonly fileName: string }\n | { readonly kind: 'local'; readonly zone: Exclude<Zone, 'external'>; readonly origin: string; readonly fileName: string };\n\nconst NODE_MODULES = '/node_modules/';\nconst TS_LIB_FILE = /\\/typescript\\/lib\\/lib\\.[^/]*\\.d\\.ts$/;\nexport const TRUST_PACKAGE = '@noego/trust';\nconst JS_BASE = 'js:';\nconst NODE_PREFIX = 'node:';\nconst NODE_GLOBAL_BASE = 'node:global';\n/** packageFromNodeModulesPath maps `@types/node` to this name. */\nconst NODE_TYPES_PACKAGE = 'node';\n/**\n * @types/node declares several globals through interfaces (`var process: NodeJS.Process`); name them\n * by the global you write, not the interface: `NodeJS.Process.cwd` → `process.cwd`.\n */\nconst NODE_GLOBAL_INTERFACES: Readonly<Record<string, string>> = {\n Process: 'process',\n Require: 'require',\n Module: 'module',\n Console: 'console',\n Global: 'global',\n};\n\nfunction nodeGlobalPath(members: readonly string[]): string[] {\n const path = members[0] === 'NodeJS' ? members.slice(1) : [...members];\n if (path.length > 0 && NODE_GLOBAL_INTERFACES[path[0]]) path[0] = NODE_GLOBAL_INTERFACES[path[0]];\n return path;\n}\n\nconst manifestNameCache = new Map<string, string | null>();\n\nfunction readManifestName(directory: string): string | null {\n const file = join(directory, 'package.json');\n if (!existsSync(file)) return null;\n try {\n const manifest: unknown = JSON.parse(readFileSync(file, 'utf8'));\n if (manifest && typeof manifest === 'object' && 'name' in manifest && typeof manifest.name === 'string') {\n return manifest.name;\n }\n } catch {\n return null;\n }\n return null;\n}\n\n/** Name in the nearest package.json that has one, walking up from the file. */\nexport function nearestPackageName(fileName: string): string | null {\n const visited: string[] = [];\n let directory = dirname(fileName);\n let result: string | null = null;\n for (;;) {\n const cached = manifestNameCache.get(directory);\n if (cached !== undefined) {\n result = cached;\n break;\n }\n visited.push(directory);\n const name = readManifestName(directory);\n if (name) {\n result = name;\n break;\n }\n const parent = dirname(directory);\n if (parent === directory) break;\n directory = parent;\n }\n for (const entry of visited) manifestNameCache.set(entry, result);\n return result;\n}\n\nfunction packageOrigin(name: string): string {\n if (!name.startsWith('@types/')) return name;\n const bare = name.slice('@types/'.length);\n return bare.includes('__') ? `@${bare.replace('__', '/')}` : bare;\n}\n\nfunction packageFromNodeModulesPath(fileName: string): string | null {\n const index = fileName.lastIndexOf(NODE_MODULES);\n if (index < 0) return null;\n const parts = fileName.slice(index + NODE_MODULES.length).split('/');\n return packageOrigin(parts[0].startsWith('@') ? `${parts[0]}/${parts[1]}` : parts[0]);\n}\n\n/** True when the file belongs to the @noego/trust package (installed, linked, or its own source). */\nexport function isTrustPackageFile(fileName: string): boolean {\n return packageFromNodeModulesPath(toPosix(fileName)) === TRUST_PACKAGE || nearestPackageName(fileName) === TRUST_PACKAGE;\n}\n\nexport class OriginResolver {\n constructor(\n private readonly ts: TypeScript,\n private readonly zones: Zones,\n ) {}\n\n originOf(declaration: TS.Node): OriginInfo {\n const fileName = toPosix(declaration.getSourceFile().fileName);\n const members = this.memberPath(declaration);\n const external = (base: string, path: readonly string[] = members): OriginInfo => ({\n kind: 'external',\n // A namespace base (`js:`) takes its first member directly: `js:JSON.parse`, not `js:.JSON.parse`.\n origin: path.length > 0 ? `${base}${base.endsWith(':') ? '' : '.'}${path.join('.')}` : base,\n base,\n fileName,\n });\n if (TS_LIB_FILE.test(fileName)) return external(JS_BASE);\n const fromNodeModules = packageFromNodeModulesPath(fileName);\n const fromNodeTypes = fromNodeModules === NODE_TYPES_PACKAGE;\n const moduleName = this.ambientModuleName(declaration);\n if (moduleName) return external(fromNodeTypes ? `${NODE_PREFIX}${moduleName}` : moduleName);\n if (fromNodeTypes) return external(NODE_GLOBAL_BASE, nodeGlobalPath(members));\n if (fromNodeModules) return external(fromNodeModules);\n const zone = this.zones.zoneOf(fileName);\n if (zone === 'external') {\n const name = nearestPackageName(realpathOrSelf(fileName));\n return external(name ? packageOrigin(name) : `external:${fileName}`);\n }\n const path = this.zones.relativePath(fileName);\n const origin = members.length > 0 ? `local:${path}#${members.join('.')}` : `local:${path}`;\n return { kind: 'local', zone, origin, fileName };\n }\n\n /** Named containers from the module down to (and including) the declaration. */\n memberPath(declaration: TS.Node): string[] {\n const ts = this.ts;\n const names: string[] = [];\n for (let node: TS.Node | undefined = declaration; node && !ts.isSourceFile(node); node = node.parent) {\n if (ts.isModuleDeclaration(node)) {\n if (ts.isStringLiteral(node.name)) break;\n if (node.flags & ts.NodeFlags.GlobalAugmentation) continue;\n }\n const name = this.containerName(node);\n if (name) names.push(name);\n }\n return names.reverse();\n }\n\n private containerName(node: TS.Node): string | null {\n const ts = this.ts;\n const named =\n ts.isInterfaceDeclaration(node) ||\n ts.isClassDeclaration(node) ||\n ts.isClassExpression(node) ||\n ts.isFunctionDeclaration(node) ||\n ts.isModuleDeclaration(node) ||\n ts.isVariableDeclaration(node) ||\n ts.isMethodSignature(node) ||\n ts.isMethodDeclaration(node) ||\n ts.isPropertySignature(node) ||\n ts.isPropertyDeclaration(node) ||\n ts.isPropertyAssignment(node) ||\n ts.isGetAccessorDeclaration(node) ||\n ts.isEnumDeclaration(node);\n if (!named) return null;\n const name = (node as TS.NamedDeclaration).name;\n if (!name) return null;\n if (ts.isIdentifier(name) || ts.isStringLiteral(name) || ts.isPrivateIdentifier(name)) {\n return ts.isInterfaceDeclaration(node) ? name.text.replace(/Constructor$/, '') : name.text;\n }\n return null;\n }\n\n private ambientModuleName(declaration: TS.Node): string | null {\n const ts = this.ts;\n for (let node: TS.Node | undefined = declaration; node; node = node.parent) {\n // `declare module \"module\" { global { … } }` declares globals, not exports of \"module\":\n // fall back to the declaring package (`node.NodeJS.Require.resolve`).\n if (ts.isModuleDeclaration(node) && node.flags & ts.NodeFlags.GlobalAugmentation) return null;\n if (ts.isModuleDeclaration(node) && ts.isStringLiteral(node.name)) return node.name.text.replace(/^node:/, '');\n }\n return null;\n }\n}\n","// Decides whether one call/new expression is trusted. Shared by the lint rule and `trust explain`.\nimport type * as TS from 'typescript';\nimport type { TrustConfig, TrustLevel } from './config.js';\nimport { isTrustPackageFile, OriginResolver, type OriginInfo } from './origin.js';\nimport type { TypeScript } from './typescript.js';\nimport { Zones } from './zones.js';\n\nexport interface MatchedEntry {\n readonly source: string;\n readonly entry: string;\n}\n\nexport type Verdict =\n | { readonly kind: 'unresolved' }\n | { readonly kind: 'first-party'; readonly origin: OriginInfo }\n | { readonly kind: 'returns-result'; readonly origin: OriginInfo }\n | { readonly kind: 'trusted'; readonly origin: OriginInfo; readonly by: MatchedEntry }\n | { readonly kind: 'untrusted'; readonly origin: OriginInfo; readonly distrustedBy?: MatchedEntry }\n | { readonly kind: 'calls-ignored'; readonly origin: OriginInfo };\n\n/**\n * `entry` covers `origin` itself, its subpaths (`fs` → `fs/promises`) and members (`builtin:JSON` →\n * `builtin:JSON.parse`). When the origin's `base` (package/module part) is known, an entry that stops\n * inside the base may only continue with `/`, so `lodash` does not cover the package `lodash.merge`.\n */\nexport function entryMatches(entry: string, origin: string, base?: string): boolean {\n if (origin === entry) return true;\n if (!origin.startsWith(entry)) return false;\n const next = origin[entry.length];\n if (base !== undefined && entry.length < base.length) return next === '/';\n return next === '/' || next === '.' || next === '#';\n}\n\n/** The most specific (longest) entry covering `origin`. */\nfunction bestMatch(entries: readonly string[], origin: string, base?: string): string | undefined {\n let best: string | undefined;\n for (const entry of entries) {\n if (entryMatches(entry, origin, base) && (best === undefined || entry.length > best.length)) best = entry;\n }\n return best;\n}\n\nexport class TrustPolicy {\n readonly zones: Zones;\n readonly origins: OriginResolver;\n private readonly levels: readonly TrustLevel[];\n\n constructor(\n private readonly ts: TypeScript,\n private readonly checker: TS.TypeChecker,\n config: TrustConfig,\n extraTrust: readonly string[] = [],\n ) {\n this.zones = new Zones(config.rootDir, config.passthrough, config.ignore);\n this.origins = new OriginResolver(ts, this.zones);\n this.levels = extraTrust.length > 0 ? [{ source: 'rule options', trust: extraTrust, distrust: [] }, ...config.levels] : config.levels;\n }\n\n /**\n * Walks leaf → root; the first level with a matching entry decides. Within a level the most specific\n * entry wins (`distrust @noego/wood` + `trust @noego/wood.TraceProvider` trusts only the tracer);\n * on equal specificity distrust wins.\n */\n lookup(origin: string, base?: string): { trusted: true; by: MatchedEntry } | { trusted: false; distrustedBy?: MatchedEntry } {\n for (const level of this.levels) {\n const distrusted = bestMatch(level.distrust, origin, base);\n const trusted = bestMatch(level.trust, origin, base);\n if (trusted && (!distrusted || trusted.length > distrusted.length)) {\n return { trusted: true, by: { source: level.source, entry: trusted } };\n }\n if (distrusted) return { trusted: false, distrustedBy: { source: level.source, entry: distrusted } };\n }\n return { trusted: false };\n }\n\n classify(node: TS.CallExpression | TS.NewExpression): Verdict {\n const resolved = this.calleeDeclaration(node);\n if (!resolved) return { kind: 'unresolved' };\n const origin = this.origins.originOf(resolved.declaration);\n if (origin.kind === 'local' && origin.zone === 'checked') return { kind: 'first-party', origin };\n if (origin.kind === 'local' && origin.zone === 'ignore') return { kind: 'calls-ignored', origin };\n const decision = this.lookup(origin.origin, origin.kind === 'external' ? origin.base : undefined);\n if (!decision.trusted && decision.distrustedBy) return { kind: 'untrusted', origin, distrustedBy: decision.distrustedBy };\n if (resolved.signature && this.returnsResult(resolved.signature)) return { kind: 'returns-result', origin };\n if (decision.trusted) return { kind: 'trusted', origin, by: decision.by };\n return { kind: 'untrusted', origin };\n }\n\n calleeDeclaration(node: TS.CallExpression | TS.NewExpression): { declaration: TS.Node; signature?: TS.Signature } | null {\n const ts = this.ts;\n const signature = this.checker.getResolvedSignature(node);\n const fromSignature = signature?.declaration && !ts.isJSDocSignature(signature.declaration) ? signature.declaration : undefined;\n // An unnamed call/construct signature (`const statSync: StatSyncFn`, `declare var URL: { new(): URL }`)\n // names its interface, not the callee; prefer the callee's own declaration (`fs.statSync`).\n const anonymous =\n !fromSignature || ts.isCallSignatureDeclaration(fromSignature) || ts.isConstructSignatureDeclaration(fromSignature) || ts.isFunctionTypeNode(fromSignature);\n if (fromSignature && !anonymous) return { declaration: fromSignature, signature };\n let symbol = this.checker.getSymbolAtLocation(node.expression);\n if (symbol && symbol.flags & ts.SymbolFlags.Alias) symbol = this.checker.getAliasedSymbol(symbol);\n const fromSymbol = symbol?.declarations?.[0];\n // Only rename within the declaring file: a first-party parameter typed by a package's function\n // interface keeps the package origin.\n const sameFile = fromSymbol && fromSignature && fromSymbol.getSourceFile() === fromSignature.getSourceFile();\n const declaration = !fromSignature || sameFile ? fromSymbol : fromSignature;\n return declaration ? { declaration, signature } : null;\n }\n\n /** Declared return type is Result / Promise<Result> from @noego/trust (every union member is Ok or Err). */\n returnsResult(signature: TS.Signature): boolean {\n const returnType = this.checker.getReturnTypeOfSignature(signature);\n const awaited = this.checker.getAwaitedType(returnType) ?? returnType;\n return this.isResultType(awaited);\n }\n\n isResultType(type: TS.Type): boolean {\n const members = type.isUnion() ? type.types : [type];\n return members.length > 0 && members.every((member) => this.resultVariant(member) !== null);\n }\n\n /** True when every member of the type is an `Err` from @noego/trust. */\n isErrType(type: TS.Type): boolean {\n const members = type.isUnion() ? type.types : [type];\n return members.length > 0 && members.every((member) => this.resultVariant(member) === 'err');\n }\n\n /** 'ok' | 'err' when the type is @noego/trust's Ok/Err (by the declaration of its `ok` property). */\n resultVariant(type: TS.Type): 'ok' | 'err' | null {\n const property = type.getProperty('ok');\n const declaration = property?.valueDeclaration ?? property?.declarations?.[0];\n if (!property || !declaration || !isTrustPackageFile(declaration.getSourceFile().fileName)) return null;\n const discriminant = this.checker.typeToString(this.checker.getTypeOfSymbol(property));\n if (discriminant === 'true') return 'ok';\n if (discriminant === 'false') return 'err';\n return null;\n }\n\n /** Name of the @noego/trust function a call resolves to (`err`, `tryResult`, …), else null. */\n trustFunctionName(node: TS.CallExpression): string | null {\n const resolved = this.calleeDeclaration(node);\n if (!resolved || !isTrustPackageFile(resolved.declaration.getSourceFile().fileName)) return null;\n const name = (resolved.declaration as TS.NamedDeclaration).name;\n return name && this.ts.isIdentifier(name) ? name.text : null;\n }\n}\n","// Shared per-file setup for both rules: trust config, file zone, typed guard context.\nimport { resolve } from 'node:path';\nimport type { Rule } from 'eslint';\nimport type * as TS from 'typescript';\nimport { loadTrustConfigCached, normalizeOrigin, type TrustConfig } from './config.js';\nimport { NAME_BASED_GUARD_CONTEXT, type AstNode, type GuardContext } from './guard.js';\nimport { TrustPolicy } from './policy.js';\nimport { loadTypeScript } from './typescript.js';\nimport { realpathOrSelf, Zones, type Zone } from './zones.js';\n\nexport interface TrustRuleOptions {\n /** trust.config.json path, relative to the ESLint cwd. */\n readonly configFile?: string;\n /** Extra trusted origins (applied before the config chain). */\n readonly trust?: readonly string[];\n}\n\nexport const OPTIONS_SCHEMA = [\n {\n type: 'object',\n properties: {\n configFile: { type: 'string' },\n trust: { type: 'array', items: { type: 'string' } },\n },\n additionalProperties: false,\n },\n] as const;\n\ninterface ParserServices {\n readonly program?: TS.Program | null;\n readonly esTreeNodeToTSNodeMap?: { get(node: unknown): TS.Node };\n}\n\nexport interface RuleSetup {\n readonly zone: Zone;\n readonly policy: TrustPolicy | null;\n readonly guardContext: GuardContext;\n /** Maps an ESTree node to its TypeScript node (typed linting only). */\n readonly tsNode: ((node: AstNode) => TS.Node) | null;\n readonly checker: TS.TypeChecker | null;\n}\n\nconst emptyConfigs = new Map<string, TrustConfig>();\n\nfunction emptyConfig(cwd: string): TrustConfig {\n let config = emptyConfigs.get(cwd);\n if (!config) {\n config = { file: '', rootDir: realpathOrSelf(cwd), levels: [], passthrough: [], ignore: [] };\n emptyConfigs.set(cwd, config);\n }\n return config;\n}\n\nconst policies = new WeakMap<TS.TypeChecker, Map<string, { config: TrustConfig; policy: TrustPolicy }>>();\n\n/** One policy per checker + config + extra trust, so zone/origin caches survive across files. */\nfunction policyFor(cwd: string, checker: TS.TypeChecker, config: TrustConfig, extraTrust: string[]): TrustPolicy {\n let byKey = policies.get(checker);\n if (!byKey) {\n byKey = new Map();\n policies.set(checker, byKey);\n }\n const key = `${config.file}\\u0000${extraTrust.join('\\u0000')}`;\n const hit = byKey.get(key);\n if (hit && hit.config === config) return hit.policy;\n const policy = new TrustPolicy(loadTypeScript(cwd), checker, config, extraTrust);\n byKey.set(key, { config, policy });\n return policy;\n}\n\nexport function setupRule(context: Rule.RuleContext): RuleSetup {\n const options = (context.options[0] ?? {}) as TrustRuleOptions;\n const config = options.configFile ? loadTrustConfigCached(resolve(context.cwd, options.configFile)) : emptyConfig(context.cwd);\n const services = context.sourceCode.parserServices as ParserServices | undefined;\n const program = services?.program ?? null;\n const map = services?.esTreeNodeToTSNodeMap;\n if (!program || !map) {\n const zones = new Zones(config.rootDir, config.passthrough, config.ignore);\n return { zone: zones.zoneOf(context.filename), policy: null, guardContext: NAME_BASED_GUARD_CONTEXT, tsNode: null, checker: null };\n }\n const checker = program.getTypeChecker();\n const policy = policyFor(context.cwd, checker, config, (options.trust ?? []).map(normalizeOrigin));\n const tsNode = (node: AstNode) => map.get(node);\n const guardContext: GuardContext = {\n isResultErr: (expression) => policy.isErrType(checker.getTypeAtLocation(tsNode(expression))),\n isErrCall: (expression) =>\n expression.type === 'CallExpression' && policy.trustFunctionName(tsNode(expression) as TS.CallExpression) === 'err',\n trustTryKind: (call) => {\n const name = policy.trustFunctionName(tsNode(call) as TS.CallExpression);\n if (name === 'tryResult') return 'sync';\n if (name === 'tryResultAsync') return 'async';\n return null;\n },\n };\n return { zone: policy.zones.zoneOf(context.filename), policy, guardContext, tsNode, checker };\n}\n","// Resolve the consumer's `typescript` (the one typescript-eslint built the Program with), so\n// SyntaxKind values and node guards match the checker we are handed. Falls back to our own copy.\nimport { createRequire } from 'node:module';\nimport { join } from 'node:path';\nimport type * as TS from 'typescript';\n\nexport type TypeScript = typeof TS;\n\nconst cache = new Map<string, TypeScript>();\n\nexport function loadTypeScript(cwd: string): TypeScript {\n const cached = cache.get(cwd);\n if (cached) return cached;\n let ts: TypeScript;\n try {\n ts = createRequire(join(cwd, '__noego_trust__.cjs'))('typescript') as TypeScript;\n } catch {\n ts = createRequire(import.meta.url)('typescript') as TypeScript;\n }\n cache.set(cwd, ts);\n return ts;\n}\n","// Every call or `new` whose callee is untrusted must be guarded: inside a `try` (same function)\n// whose `catch` returns Result.err(...) on every path, or inside a Result.try / Result.tryAsync\n// callback. Trust comes from trust.config.json (see ../config.ts), from first-party checked code,\n// or from a declared return type of Result / Promise<Result> from @noego/trust.\n// Requires typed linting (parserOptions.projectService or project).\nimport type { Rule } from 'eslint';\nimport type * as TS from 'typescript';\nimport { CATCH_MESSAGES, guardOf, type AstNode, type CatchProblem, type Guard } from '../guard.js';\nimport { OPTIONS_SCHEMA, setupRule } from '../rule-setup.js';\n\nconst PROMISE_COMBINATORS = new Set(['all', 'allSettled', 'race', 'any']);\n\nfunction withOrigin(template: string): string {\n return template.replace('{{target}}', 'the call into \"{{origin}}\"');\n}\n\nexport const UNTRUSTED_CALL_MESSAGES = {\n unguarded:\n 'Call into untrusted \"{{origin}}\" must be inside a `try` (same function) whose `catch` returns Result.err(...), or inside Result.try/tryAsync. If \"{{origin}}\" cannot fail, trust it in trust.config.json.',\n notAwaited:\n 'Async call into untrusted \"{{origin}}\" must be awaited inside the guard, or its rejection escapes the catch.',\n callsIgnored:\n 'Call into \"{{origin}}\" is trusted only because its file is ignored. List that file under \"passthrough\" instead of \"ignore\" so calls into it must be handled.',\n rethrow: withOrigin(CATCH_MESSAGES.rethrow),\n notResultErr: withOrigin(CATCH_MESSAGES.notResultErr),\n rawCatchValue: withOrigin(CATCH_MESSAGES.rawCatchValue),\n notAllPaths: withOrigin(CATCH_MESSAGES.notAllPaths),\n} as const satisfies Record<string, string> & Record<CatchProblem, string>;\n\n/** Outermost expression of a `.then()/.catch()` chain started by `node`. */\nfunction chainTop(node: AstNode): AstNode {\n let current = node;\n for (;;) {\n const member = current.parent;\n const call = member?.parent;\n if (member?.type === 'MemberExpression' && member.object === current && call?.type === 'CallExpression' && call.callee === member) {\n current = call;\n } else {\n return current;\n }\n }\n}\n\nfunction isPromiseCombinator(call: AstNode | undefined): boolean {\n if (call?.type !== 'CallExpression') return false;\n const callee = call.callee as AstNode;\n if (callee.type !== 'MemberExpression') return false;\n const object = callee.object as AstNode;\n const property = callee.property as AstNode;\n return object.type === 'Identifier' && object.name === 'Promise' && property.type === 'Identifier' && PROMISE_COMBINATORS.has(property.name as string);\n}\n\n/** The promise produced by `expression` settles inside the guard (awaited, or returned to Result.tryAsync). */\nfunction isConsumed(expression: AstNode, guard: Guard): boolean {\n const top = chainTop(expression);\n const parent = top.parent;\n if (!parent) return false;\n if (parent.type === 'AwaitExpression') return true;\n if (parent.type === 'ArrayExpression' && isPromiseCombinator(parent.parent)) return isConsumed(parent.parent as AstNode, guard);\n if (guard.status === 'guarded' && guard.via === 'async-callback') {\n if (parent.type === 'ReturnStatement') return true;\n if (parent.type === 'ArrowFunctionExpression' && parent.body === top) return true;\n }\n return false;\n}\n\nconst rule: Rule.RuleModule = {\n meta: {\n type: 'problem',\n docs: { description: 'Require calls into untrusted code to be handled locally and returned as Result.err.' },\n schema: OPTIONS_SCHEMA as unknown as Rule.RuleMetaData['schema'],\n messages: UNTRUSTED_CALL_MESSAGES,\n },\n create(context) {\n const setup = setupRule(context);\n if (!setup.policy || !setup.tsNode || !setup.checker) {\n throw new Error('untrusted-call-must-return-result requires typed linting (parserOptions.projectService or project).');\n }\n if (setup.zone !== 'checked') return {};\n const { policy, tsNode, checker, guardContext } = setup;\n\n function check(esNode: Rule.Node): void {\n const node = esNode as unknown as AstNode;\n const target = tsNode(node) as TS.CallExpression | TS.NewExpression;\n const verdict = policy.classify(target);\n if (verdict.kind === 'calls-ignored') {\n context.report({ node: esNode, messageId: 'callsIgnored', data: { origin: verdict.origin.origin } });\n return;\n }\n if (verdict.kind !== 'untrusted') return;\n const origin = verdict.origin.origin;\n const guard = guardOf(node, guardContext);\n if (guard.status === 'unguarded') {\n context.report({ node: esNode, messageId: 'unguarded', data: { origin } });\n } else if (guard.status === 'badCatch') {\n context.report({ node: esNode, messageId: guard.problem, data: { origin } });\n } else if (checker.getTypeAtLocation(target).getProperty('then') && !isConsumed(node, guard)) {\n context.report({ node: esNode, messageId: 'notAwaited', data: { origin } });\n }\n }\n\n return { CallExpression: check, NewExpression: check };\n },\n};\n\nexport default rule;\n","// Baseline of existing violations, keyed by file + rule + origin with a count.\n// A check fails only when some key's current count exceeds its baselined count, so:\n// - existing violations do not block CI;\n// - a new unguarded call (or a new call in a file that already had one) fails;\n// - removing an origin from the trust list makes all of its calls new violations.\nimport type { ESLint, Linter } from 'eslint';\nimport { UNTRUSTED_CALL_MESSAGES } from './rules/untrusted-call-must-return-result.js';\nimport { relativeInside, realpathOrSelf, toPosix } from './zones.js';\n\nexport const UNTRUSTED_CALL_RULE = 'untrusted-call-must-return-result';\nexport const THROW_RULE = 'throw-must-return-result';\nconst THROW_ORIGIN = 'throw';\n\nexport interface Finding {\n readonly file: string;\n readonly rule: string;\n readonly origin: string;\n readonly line: number;\n readonly column: number;\n readonly message: string;\n}\n\n/** file → rule → origin → count */\nexport type BaselineCounts = Record<string, Record<string, Record<string, number>>>;\n\nexport interface BaselineDelta {\n readonly file: string;\n readonly rule: string;\n readonly origin: string;\n readonly allowed: number;\n readonly found: number;\n readonly findings: readonly Finding[];\n}\n\nfunction escapeRegExp(text: string): string {\n return text.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n}\n\nfunction templateRegExp(template: string): RegExp {\n let groupUsed = false;\n const source = template\n .split('{{origin}}')\n .map(escapeRegExp)\n .reduce((acc, part) => {\n if (acc === null) return part;\n const placeholder = groupUsed ? '.+?' : '(.+?)';\n groupUsed = true;\n return `${acc}${placeholder}${part}`;\n }, null as string | null);\n return new RegExp(`^${source}$`);\n}\n\nconst UNTRUSTED_PATTERNS = new Map(Object.entries(UNTRUSTED_CALL_MESSAGES).map(([id, text]) => [id, templateRegExp(text)]));\n\n/**\n * typescript-eslint promise rules counted in the baseline too: an un-awaited or misused promise\n * escapes every try/catch, so it is the async form of an unguarded call. Keyed by the full rule id;\n * their \"origin\" is the rule's messageId.\n */\nexport const BASELINED_PROMISE_RULES: ReadonlySet<string> = new Set([\n '@typescript-eslint/no-floating-promises',\n '@typescript-eslint/no-misused-promises',\n]);\n\n/** The origin a baselined rule message is about (\"throw\" for the throw rule, messageId for promise rules). */\nexport function originFromMessage(rule: string, messageId: string | undefined, message: string): string {\n if (rule === THROW_RULE) return THROW_ORIGIN;\n if (BASELINED_PROMISE_RULES.has(rule)) return messageId ?? 'promise';\n const pattern = messageId ? UNTRUSTED_PATTERNS.get(messageId) : undefined;\n return pattern?.exec(message)?.[1] ?? `unknown:${messageId ?? 'message'}`;\n}\n\nexport function ruleNameOf(ruleId: string | null | undefined): string | null {\n if (!ruleId) return null;\n if (BASELINED_PROMISE_RULES.has(ruleId)) return ruleId;\n const name = ruleId.slice(ruleId.lastIndexOf('/') + 1);\n return name === UNTRUSTED_CALL_RULE || name === THROW_RULE ? name : null;\n}\n\n/** Trust-rule findings from ESLint results, with paths relative to `rootDir`. */\nexport function findingsFromResults(results: readonly ESLint.LintResult[], rootDir: string): Finding[] {\n const root = realpathOrSelf(rootDir);\n const findings: Finding[] = [];\n for (const result of results) {\n const real = realpathOrSelf(result.filePath);\n const file = relativeInside(root, real) ?? toPosix(real);\n for (const message of result.messages as Linter.LintMessage[]) {\n const rule = ruleNameOf(message.ruleId);\n if (!rule) continue;\n findings.push({\n file,\n rule,\n origin: originFromMessage(rule, message.messageId, message.message),\n line: message.line,\n column: message.column,\n message: message.message,\n });\n }\n }\n return findings;\n}\n\n/** Fatal parse/config errors (no ruleId) — a baseline built over these would be wrong. */\nexport function fatalMessages(results: readonly ESLint.LintResult[]): string[] {\n return results.flatMap((result) =>\n (result.messages as Linter.LintMessage[])\n .filter((message) => message.fatal)\n .map((message) => `${result.filePath}:${message.line}:${message.column} ${message.message}`),\n );\n}\n\nexport function countFindings(findings: readonly Finding[]): BaselineCounts {\n const counts: BaselineCounts = {};\n for (const finding of findings) {\n const byRule = (counts[finding.file] ??= {});\n const byOrigin = (byRule[finding.rule] ??= {});\n byOrigin[finding.origin] = (byOrigin[finding.origin] ?? 0) + 1;\n }\n return counts;\n}\n\nexport function compareToBaseline(\n findings: readonly Finding[],\n baseline: BaselineCounts,\n): { readonly added: BaselineDelta[]; readonly stale: BaselineDelta[] } {\n const groups = new Map<string, Finding[]>();\n for (const finding of findings) {\n const key = JSON.stringify([finding.file, finding.rule, finding.origin]);\n const list = groups.get(key) ?? [];\n list.push(finding);\n groups.set(key, list);\n }\n const added: BaselineDelta[] = [];\n for (const list of groups.values()) {\n const { file, rule, origin } = list[0];\n const allowed = baseline[file]?.[rule]?.[origin] ?? 0;\n if (list.length > allowed) added.push({ file, rule, origin, allowed, found: list.length, findings: list });\n }\n const stale: BaselineDelta[] = [];\n for (const [file, byRule] of Object.entries(baseline)) {\n for (const [rule, byOrigin] of Object.entries(byRule)) {\n for (const [origin, allowed] of Object.entries(byOrigin)) {\n const found = groups.get(JSON.stringify([file, rule, origin]))?.length ?? 0;\n if (found < allowed) stale.push({ file, rule, origin, allowed, found, findings: [] });\n }\n }\n }\n return { added, stale };\n}\n\nfunction sortObject<T>(record: Record<string, T>, map: (value: T) => unknown): Record<string, unknown> {\n return Object.fromEntries(\n Object.keys(record)\n .sort()\n .map((key) => [key, map(record[key])]),\n );\n}\n\nexport function serializeBaseline(counts: BaselineCounts): string {\n const violations = sortObject(counts, (byRule) => sortObject(byRule, (byOrigin) => sortObject(byOrigin, (count) => count)));\n const document = {\n $comment:\n 'Generated by `trust baseline --update`. Existing @noego/trust violations, counted per file + rule + origin. ' +\n 'CI fails when a count grows. Shrink it by fixing calls and re-running --update; never hand-raise a count.',\n version: 1,\n violations,\n };\n return `${JSON.stringify(document, null, 2)}\\n`;\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\nexport function parseBaseline(text: string, source: string): BaselineCounts {\n const document: unknown = JSON.parse(text);\n if (!isRecord(document) || document.version !== 1 || !isRecord(document.violations)) {\n throw new Error(`${source}: expected { \"version\": 1, \"violations\": { … } }`);\n }\n const counts: BaselineCounts = {};\n for (const [file, byRule] of Object.entries(document.violations)) {\n if (!isRecord(byRule)) throw new Error(`${source}: violations[\"${file}\"] must be an object`);\n for (const [rule, byOrigin] of Object.entries(byRule)) {\n if (!isRecord(byOrigin)) throw new Error(`${source}: violations[\"${file}\"][\"${rule}\"] must be an object`);\n for (const [origin, count] of Object.entries(byOrigin)) {\n if (typeof count !== 'number' || !Number.isInteger(count) || count < 0) {\n throw new Error(`${source}: count for ${file} ${rule} ${origin} must be a non-negative integer`);\n }\n ((counts[file] ??= {})[rule] ??= {})[origin] = count;\n }\n }\n }\n return counts;\n}\n"],"mappings":";AA2BO,IAAM,iBAAiB,oBAAI,IAAI,CAAC,uBAAuB,sBAAsB,yBAAyB,CAAC;AAC9G,IAAM,iBAAiB,oBAAI,IAAI,CAAC,gBAAgB,kBAAkB,kBAAkB,kBAAkB,oBAAoB,iBAAiB,CAAC;AAErI,IAAM,iBAA+C;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MAAM,QAAQ,KAAK;AAC5E;AAEO,SAAS,cAAc,MAAc,QAAgC;AAC1E,QAAM,WAAoB,KAAK,MAAM,IAAI;AACzC,MAAI,CAACA,UAAS,QAAQ,KAAK,SAAS,YAAY,KAAK,CAACA,UAAS,SAAS,UAAU,GAAG;AACnF,UAAM,IAAI,MAAM,GAAG,MAAM,uDAAkD;AAAA,EAC7E;AACA,QAAM,SAAyB,CAAC;AAChC,aAAW,CAAC,MAAM,MAAM,KAAK,OAAO,QAAQ,SAAS,UAAU,GAAG;AAChE,QAAI,CAACA,UAAS,MAAM,EAAG,OAAM,IAAI,MAAM,GAAG,MAAM,iBAAiB,IAAI,sBAAsB;AAC3F,eAAW,CAACD,OAAM,QAAQ,KAAK,OAAO,QAAQ,MAAM,GAAG;AACrD,UAAI,CAACC,UAAS,QAAQ,EAAG,OAAM,IAAI,MAAM,GAAG,MAAM,iBAAiB,IAAI,OAAOD,KAAI,sBAAsB;AACxG,iBAAW,CAAC,QAAQ,KAAK,KAAK,OAAO,QAAQ,QAAQ,GAAG;AACtD,YAAI,OAAO,UAAU,YAAY,CAAC,OAAO,UAAU,KAAK,KAAK,QAAQ,GAAG;AACtE,gBAAM,IAAI,MAAM,GAAG,MAAM,eAAe,IAAI,IAAIA,KAAI,IAAI,MAAM,iCAAiC;AAAA,QACjG;AACA,UAAE,OAAO,IAAI,MAAM,CAAC,GAAGA,KAAI,MAAM,CAAC,GAAG,MAAM,IAAI;AAAA,MACjD;AAAA,IACF;AAAA,EACF;AACA,SAAO;AACT;","names":["isAbsolute","isAbsolute","existsSync","readFileSync","dirname","join","join","existsSync","readFileSync","dirname","path","resolve","join","cache","resolve","rule","isRecord"]}
|