@quantakrypto/core 0.2.2 → 0.4.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/dist/agent-types.d.ts +48 -0
- package/dist/agent-types.d.ts.map +1 -0
- package/dist/agent-types.js +2 -0
- package/dist/agent-types.js.map +1 -0
- package/dist/cache.d.ts +27 -0
- package/dist/cache.d.ts.map +1 -0
- package/dist/cache.js +93 -0
- package/dist/cache.js.map +1 -0
- package/dist/cbom.d.ts.map +1 -1
- package/dist/cbom.js +26 -1
- package/dist/cbom.js.map +1 -1
- package/dist/changed.d.ts.map +1 -1
- package/dist/changed.js +14 -2
- package/dist/changed.js.map +1 -1
- package/dist/codemods/config-toggle.d.ts +3 -0
- package/dist/codemods/config-toggle.d.ts.map +1 -0
- package/dist/codemods/config-toggle.js +26 -0
- package/dist/codemods/config-toggle.js.map +1 -0
- package/dist/codemods/registry.d.ts +26 -0
- package/dist/codemods/registry.d.ts.map +1 -0
- package/dist/codemods/registry.js +8 -0
- package/dist/codemods/registry.js.map +1 -0
- package/dist/comments.d.ts +45 -0
- package/dist/comments.d.ts.map +1 -0
- package/dist/comments.js +164 -0
- package/dist/comments.js.map +1 -0
- package/dist/config.d.ts +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +7 -0
- package/dist/config.js.map +1 -1
- package/dist/dependencies.d.ts +31 -13
- package/dist/dependencies.d.ts.map +1 -1
- package/dist/dependencies.js +460 -40
- package/dist/dependencies.js.map +1 -1
- package/dist/detect-utils.d.ts +70 -2
- package/dist/detect-utils.d.ts.map +1 -1
- package/dist/detect-utils.js +139 -17
- package/dist/detect-utils.js.map +1 -1
- package/dist/detectors/c.d.ts +20 -0
- package/dist/detectors/c.d.ts.map +1 -0
- package/dist/detectors/c.js +104 -0
- package/dist/detectors/c.js.map +1 -0
- package/dist/detectors/csharp.d.ts +15 -0
- package/dist/detectors/csharp.d.ts.map +1 -0
- package/dist/detectors/csharp.js +76 -0
- package/dist/detectors/csharp.js.map +1 -0
- package/dist/detectors/go.d.ts +25 -0
- package/dist/detectors/go.d.ts.map +1 -0
- package/dist/detectors/go.js +132 -0
- package/dist/detectors/go.js.map +1 -0
- package/dist/detectors/java.d.ts +25 -0
- package/dist/detectors/java.d.ts.map +1 -0
- package/dist/detectors/java.js +200 -0
- package/dist/detectors/java.js.map +1 -0
- package/dist/detectors/pem.d.ts +4 -0
- package/dist/detectors/pem.d.ts.map +1 -1
- package/dist/detectors/pem.js +113 -91
- package/dist/detectors/pem.js.map +1 -1
- package/dist/detectors/python.d.ts +26 -0
- package/dist/detectors/python.d.ts.map +1 -0
- package/dist/detectors/python.js +171 -0
- package/dist/detectors/python.js.map +1 -0
- package/dist/detectors/ruby.d.ts +15 -0
- package/dist/detectors/ruby.d.ts.map +1 -0
- package/dist/detectors/ruby.js +75 -0
- package/dist/detectors/ruby.js.map +1 -0
- package/dist/detectors/rust.d.ts +13 -0
- package/dist/detectors/rust.d.ts.map +1 -0
- package/dist/detectors/rust.js +94 -0
- package/dist/detectors/rust.js.map +1 -0
- package/dist/detectors/source.d.ts +9 -2
- package/dist/detectors/source.d.ts.map +1 -1
- package/dist/detectors/source.js +435 -286
- package/dist/detectors/source.js.map +1 -1
- package/dist/index.d.ts +19 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +16 -2
- package/dist/index.js.map +1 -1
- package/dist/parallel.d.ts +4 -0
- package/dist/parallel.d.ts.map +1 -1
- package/dist/parallel.js +61 -8
- package/dist/parallel.js.map +1 -1
- package/dist/patch-policy.d.ts +22 -0
- package/dist/patch-policy.d.ts.map +1 -0
- package/dist/patch-policy.js +21 -0
- package/dist/patch-policy.js.map +1 -0
- package/dist/redact.d.ts +19 -0
- package/dist/redact.d.ts.map +1 -0
- package/dist/redact.js +77 -0
- package/dist/redact.js.map +1 -0
- package/dist/registry.d.ts +29 -4
- package/dist/registry.d.ts.map +1 -1
- package/dist/registry.js +62 -4
- package/dist/registry.js.map +1 -1
- package/dist/remediate-pipeline.d.ts +41 -0
- package/dist/remediate-pipeline.d.ts.map +1 -0
- package/dist/remediate-pipeline.js +38 -0
- package/dist/remediate-pipeline.js.map +1 -0
- package/dist/remediate-request.d.ts +21 -0
- package/dist/remediate-request.d.ts.map +1 -0
- package/dist/remediate-request.js +28 -0
- package/dist/remediate-request.js.map +1 -0
- package/dist/remediation.d.ts +10 -0
- package/dist/remediation.d.ts.map +1 -1
- package/dist/remediation.js +21 -8
- package/dist/remediation.js.map +1 -1
- package/dist/report.d.ts +9 -1
- package/dist/report.d.ts.map +1 -1
- package/dist/report.js +72 -24
- package/dist/report.js.map +1 -1
- package/dist/scan-worker.js +7 -3
- package/dist/scan-worker.js.map +1 -1
- package/dist/scan.d.ts +6 -5
- package/dist/scan.d.ts.map +1 -1
- package/dist/scan.js +59 -30
- package/dist/scan.js.map +1 -1
- package/dist/triage.d.ts +27 -0
- package/dist/triage.d.ts.map +1 -0
- package/dist/triage.js +33 -0
- package/dist/triage.js.map +1 -0
- package/dist/types.d.ts +106 -3
- package/dist/types.d.ts.map +1 -1
- package/dist/verify.d.ts +30 -0
- package/dist/verify.d.ts.map +1 -0
- package/dist/verify.js +65 -0
- package/dist/verify.js.map +1 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/walk.d.ts +7 -0
- package/dist/walk.d.ts.map +1 -1
- package/dist/walk.js +85 -11
- package/dist/walk.js.map +1 -1
- package/dist/worktree.d.ts +6 -0
- package/dist/worktree.d.ts.map +1 -0
- package/dist/worktree.js +43 -0
- package/dist/worktree.js.map +1 -0
- package/package.json +1 -1
- package/src/agent-types.ts +52 -0
- package/src/cache.ts +120 -0
- package/src/cbom.ts +27 -1
- package/src/changed.ts +13 -4
- package/src/codemods/config-toggle.ts +35 -0
- package/src/codemods/registry.ts +31 -0
- package/src/comments.ts +180 -0
- package/src/config.ts +8 -0
- package/src/dependencies.ts +483 -51
- package/src/detect-utils.ts +180 -16
- package/src/detectors/c.ts +132 -0
- package/src/detectors/csharp.ts +98 -0
- package/src/detectors/go.ts +167 -0
- package/src/detectors/java.ts +235 -0
- package/src/detectors/pem.ts +124 -105
- package/src/detectors/python.ts +212 -0
- package/src/detectors/ruby.ts +97 -0
- package/src/detectors/rust.ts +112 -0
- package/src/detectors/source.ts +535 -364
- package/src/index.ts +47 -2
- package/src/parallel.ts +72 -7
- package/src/patch-policy.ts +42 -0
- package/src/redact.ts +92 -0
- package/src/registry.ts +71 -5
- package/src/remediate-pipeline.ts +81 -0
- package/src/remediate-request.ts +52 -0
- package/src/remediation.ts +27 -11
- package/src/report.ts +106 -24
- package/src/scan-worker.ts +18 -7
- package/src/scan.ts +74 -29
- package/src/triage.ts +58 -0
- package/src/types.ts +120 -3
- package/src/verify.ts +82 -0
- package/src/version.ts +1 -1
- package/src/walk.ts +81 -12
- package/src/worktree.ts +45 -0
package/dist/scan.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import type { Detector, Finding, ScanOptions, ScanResult } from "./types.js";
|
|
2
2
|
/**
|
|
3
|
-
* The full set of built-in detectors exposed on the public API.
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
3
|
+
* The full set of built-in detectors exposed on the public API. Re-exported
|
|
4
|
+
* from {@link builtinDetectors} in `registry.ts` — the single source of truth
|
|
5
|
+
* the {@link defaultRegistry} is also built from — so the public array and the
|
|
6
|
+
* registry can never drift apart. The manifest scanner is handled separately
|
|
7
|
+
* (it parses JSON rather than running a Detector).
|
|
7
8
|
*/
|
|
8
9
|
export declare const detectors: Detector[];
|
|
9
10
|
/** Stable comparator: by file, then line, then ruleId. Exported for reuse. */
|
|
@@ -17,7 +18,7 @@ export declare function detectFile(file: string, content: string, dets: readonly
|
|
|
17
18
|
source: boolean;
|
|
18
19
|
config: boolean;
|
|
19
20
|
deps: boolean;
|
|
20
|
-
}): Finding[];
|
|
21
|
+
}, disabledRules?: readonly string[]): Finding[];
|
|
21
22
|
/**
|
|
22
23
|
* Recursively scan a directory (or single file, or explicit file list) for
|
|
23
24
|
* classical asymmetric crypto. Honours the source / dependencies / config
|
package/dist/scan.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scan.d.ts","sourceRoot":"","sources":["../src/scan.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"scan.d.ts","sourceRoot":"","sources":["../src/scan.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAY7E;;;;;;GAMG;AACH,eAAO,MAAM,SAAS,EAAE,QAAQ,EAAqB,CAAC;AAEtD,8EAA8E;AAC9E,wBAAgB,eAAe,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,GAAG,MAAM,CAI9D;AAOD;;;;GAIG;AACH,wBAAgB,UAAU,CACxB,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,SAAS,QAAQ,EAAE,EACzB,OAAO,EAAE;IAAE,MAAM,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,OAAO,CAAC;IAAC,IAAI,EAAE,OAAO,CAAA;CAAE,EAC5D,aAAa,CAAC,EAAE,SAAS,MAAM,EAAE,GAChC,OAAO,EAAE,CA6BX;AAED;;;;GAIG;AACH,wBAAsB,IAAI,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC,CAmIpE;AAED;;;;;;;;;GASG;AACH,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,SAAS,MAAM,EAAE,EACxB,OAAO,EAAE,IAAI,CAAC,WAAW,EAAE,SAAS,GAAG,SAAS,CAAC,GAChD,MAAM,EAAE,CAmBV"}
|
package/dist/scan.js
CHANGED
|
@@ -11,21 +11,23 @@
|
|
|
11
11
|
*/
|
|
12
12
|
import { readFile, stat } from "node:fs/promises";
|
|
13
13
|
import * as path from "node:path";
|
|
14
|
-
import { walkFiles, toPosix, isBinaryPath, looksMinified } from "./walk.js";
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
14
|
+
import { walkFiles, toPosix, isBinaryPath, looksMinified, matchesAny } from "./walk.js";
|
|
15
|
+
import { isAnalyzableSource } from "./detect-utils.js";
|
|
16
|
+
import { stripCommentFindings, stripIgnoredFindings } from "./comments.js";
|
|
17
|
+
import { hashContent, loadCache, rulesetFingerprint, saveCache } from "./cache.js";
|
|
18
|
+
import { builtinDetectors, defaultRegistry, detectorScope } from "./registry.js";
|
|
18
19
|
import { isManifestFile, scanManifest } from "./dependencies.js";
|
|
19
20
|
import { buildInventory } from "./inventory.js";
|
|
20
21
|
import { AbortError, BudgetExceededError } from "./errors.js";
|
|
21
22
|
import { VERSION } from "./version.js";
|
|
22
23
|
/**
|
|
23
|
-
* The full set of built-in detectors exposed on the public API.
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
24
|
+
* The full set of built-in detectors exposed on the public API. Re-exported
|
|
25
|
+
* from {@link builtinDetectors} in `registry.ts` — the single source of truth
|
|
26
|
+
* the {@link defaultRegistry} is also built from — so the public array and the
|
|
27
|
+
* registry can never drift apart. The manifest scanner is handled separately
|
|
28
|
+
* (it parses JSON rather than running a Detector).
|
|
27
29
|
*/
|
|
28
|
-
export const detectors =
|
|
30
|
+
export const detectors = builtinDetectors;
|
|
29
31
|
/** Stable comparator: by file, then line, then ruleId. Exported for reuse. */
|
|
30
32
|
export function compareFindings(a, b) {
|
|
31
33
|
if (a.location.file !== b.location.file)
|
|
@@ -43,8 +45,8 @@ function resolveDetectors(options) {
|
|
|
43
45
|
* contents, honouring the source / config / dependencies toggles. Pure: no I/O.
|
|
44
46
|
* Exported so the parallel worker and unit tests can drive it directly.
|
|
45
47
|
*/
|
|
46
|
-
export function detectFile(file, content, dets, toggles) {
|
|
47
|
-
|
|
48
|
+
export function detectFile(file, content, dets, toggles, disabledRules) {
|
|
49
|
+
let out = [];
|
|
48
50
|
for (const det of dets) {
|
|
49
51
|
if (!det.appliesTo(file))
|
|
50
52
|
continue;
|
|
@@ -53,9 +55,21 @@ export function detectFile(file, content, dets, toggles) {
|
|
|
53
55
|
continue;
|
|
54
56
|
out.push(...det.detect({ file, content }));
|
|
55
57
|
}
|
|
58
|
+
// Drop lexical false positives that land inside comments (`// migrated off
|
|
59
|
+
// createECDH()`), then honour inline `// qscan-ignore-line` /
|
|
60
|
+
// `qscan-ignore-next-line` directives. Both run before the dependency scan
|
|
61
|
+
// appends its findings (manifests carry neither).
|
|
62
|
+
out = stripCommentFindings(out, content, file);
|
|
63
|
+
out = stripIgnoredFindings(out, content);
|
|
56
64
|
if (toggles.deps && isManifestFile(file)) {
|
|
57
65
|
out.push(...scanManifest(file, content));
|
|
58
66
|
}
|
|
67
|
+
// Per-rule suppression: drop findings whose ruleId was disabled. Applied here
|
|
68
|
+
// so both the serial scan and the worker path honour it identically.
|
|
69
|
+
if (disabledRules && disabledRules.length > 0) {
|
|
70
|
+
const disabled = new Set(disabledRules);
|
|
71
|
+
return out.filter((f) => !disabled.has(f.ruleId));
|
|
72
|
+
}
|
|
59
73
|
return out;
|
|
60
74
|
}
|
|
61
75
|
/**
|
|
@@ -77,7 +91,15 @@ export async function scan(options) {
|
|
|
77
91
|
const singleFileName = rootIsFile ? path.basename(options.root) : null;
|
|
78
92
|
const findings = [];
|
|
79
93
|
let filesScanned = 0;
|
|
94
|
+
let analyzedFiles = 0;
|
|
80
95
|
let bytesScanned = 0;
|
|
96
|
+
let unreadable = 0;
|
|
97
|
+
let skippedMinified = 0;
|
|
98
|
+
// Optional content-hash scan cache: unchanged files reuse prior findings.
|
|
99
|
+
const cacheFile = options.cacheFile;
|
|
100
|
+
const ruleset = cacheFile ? rulesetFingerprint(dets, options.disabledRules) : "";
|
|
101
|
+
const cache = cacheFile ? await loadCache(cacheFile, ruleset) : null;
|
|
102
|
+
const nextEntries = cacheFile ? new Map() : null;
|
|
81
103
|
// Work-budget / cancellation controls (all optional, unlimited when omitted).
|
|
82
104
|
const signal = options.signal;
|
|
83
105
|
const maxFiles = options.maxFiles;
|
|
@@ -108,11 +130,13 @@ export async function scan(options) {
|
|
|
108
130
|
content = await readFile(absPath, "utf8");
|
|
109
131
|
}
|
|
110
132
|
catch {
|
|
111
|
-
|
|
133
|
+
unreadable += 1; // permissions / vanished / decode failure — tracked, not silent.
|
|
134
|
+
continue;
|
|
112
135
|
}
|
|
113
136
|
// Skip machine-minified / generated content (unless explicitly enabled).
|
|
114
137
|
// Manifests are always scanned (their findings are dependency findings).
|
|
115
138
|
if (!scanMinified && !isManifestFile(reportedPath) && looksMinified(content)) {
|
|
139
|
+
skippedMinified += 1;
|
|
116
140
|
continue;
|
|
117
141
|
}
|
|
118
142
|
// Cumulative-byte budget: enforced once this file's bytes are accounted for.
|
|
@@ -121,12 +145,28 @@ export async function scan(options) {
|
|
|
121
145
|
throw new BudgetExceededError(`maxBytes budget exceeded (limit: ${maxBytes}).`);
|
|
122
146
|
}
|
|
123
147
|
filesScanned += 1;
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
148
|
+
if (isAnalyzableSource(reportedPath))
|
|
149
|
+
analyzedFiles += 1;
|
|
150
|
+
// Cache: reuse prior findings when the content hash matches; otherwise scan
|
|
151
|
+
// and record. `nextEntries` becomes the new cache (dropping vanished files).
|
|
152
|
+
let fileFindings;
|
|
153
|
+
if (cache && nextEntries) {
|
|
154
|
+
const hash = hashContent(content);
|
|
155
|
+
const hit = cache.get(reportedPath);
|
|
156
|
+
fileFindings =
|
|
157
|
+
hit && hit.hash === hash
|
|
158
|
+
? hit.findings
|
|
159
|
+
: detectFile(reportedPath, content, dets, { source: doSource, config: doConfig, deps: doDeps }, options.disabledRules);
|
|
160
|
+
nextEntries.set(reportedPath, { hash, findings: fileFindings });
|
|
161
|
+
}
|
|
162
|
+
else {
|
|
163
|
+
fileFindings = detectFile(reportedPath, content, dets, { source: doSource, config: doConfig, deps: doDeps }, options.disabledRules);
|
|
164
|
+
}
|
|
165
|
+
findings.push(...fileFindings);
|
|
129
166
|
}
|
|
167
|
+
// Persist the cache (best effort) before ordering/returning.
|
|
168
|
+
if (cacheFile && nextEntries)
|
|
169
|
+
await saveCache(cacheFile, ruleset, nextEntries);
|
|
130
170
|
// Stable ordering: by file, then line, then ruleId.
|
|
131
171
|
findings.sort(compareFindings);
|
|
132
172
|
const inventory = buildInventory(findings);
|
|
@@ -135,6 +175,8 @@ export async function scan(options) {
|
|
|
135
175
|
root: options.root,
|
|
136
176
|
findings,
|
|
137
177
|
filesScanned,
|
|
178
|
+
analyzedFiles,
|
|
179
|
+
diagnostics: { unreadable, skippedMinified },
|
|
138
180
|
inventory,
|
|
139
181
|
startedAt: startedAt.toISOString(),
|
|
140
182
|
finishedAt: finishedAt.toISOString(),
|
|
@@ -179,17 +221,4 @@ async function* filterExplicitFiles(files, options) {
|
|
|
179
221
|
for (const rel of filterExplicitFileList(files, options))
|
|
180
222
|
yield rel;
|
|
181
223
|
}
|
|
182
|
-
/** Local substring/prefix matcher (mirrors the walker's pattern semantics). */
|
|
183
|
-
function matchesAny(rel, patterns) {
|
|
184
|
-
for (const pattern of patterns) {
|
|
185
|
-
if (!pattern)
|
|
186
|
-
continue;
|
|
187
|
-
const p = toPosix(pattern).replace(/\/+$/, "");
|
|
188
|
-
if (rel.includes(p))
|
|
189
|
-
return true;
|
|
190
|
-
if (rel === p || rel.startsWith(`${p}/`))
|
|
191
|
-
return true;
|
|
192
|
-
}
|
|
193
|
-
return false;
|
|
194
|
-
}
|
|
195
224
|
//# sourceMappingURL=scan.js.map
|
package/dist/scan.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scan.js","sourceRoot":"","sources":["../src/scan.ts"],"names":[],"mappings":"AAAA;;;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AC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAEhD,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE;QACzB,IAAI,YAAY,CAAC,GAAG,CAAC;YAAE,OAAO,KAAK,CAAC;QACpC,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,EAAE,OAAO,CAAC;YAAE,OAAO,KAAK,CAAC;QAClE,IAAI,UAAU,CAAC,GAAG,EAAE,OAAO,CAAC;YAAE,OAAO,KAAK,CAAC;QAC3C,OAAO,IAAI,CAAC;IACd,CAAC,CAAC,CAAC;AACL,CAAC;AAED,kFAAkF;AAClF,KAAK,SAAS,CAAC,CAAC,mBAAmB,CAAC,KAAe,EAAE,OAAoB;IACvE,KAAK,MAAM,GAAG,IAAI,sBAAsB,CAAC,KAAK,EAAE,OAAO,CAAC;QAAE,MAAM,GAAG,CAAC;AACtE,CAAC"}
|
package/dist/triage.d.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Triage rubric, verdict schema, and request-bundle builder — all offline and
|
|
3
|
+
* deterministic. Both planes share them: `@quantakrypto/agent` (networked)
|
|
4
|
+
* prompts a model with the rubric, while the MCP `triage_findings` tool emits a
|
|
5
|
+
* request bundle for the HOST agent to reason over. Keeping them here means the
|
|
6
|
+
* MCP server never imports the networked package and both sides use one rubric.
|
|
7
|
+
*/
|
|
8
|
+
import type { Finding } from "./types.js";
|
|
9
|
+
import type { ContextLevel, RedactedContext } from "./agent-types.js";
|
|
10
|
+
/** The system rubric that defines what an exposure verdict means. */
|
|
11
|
+
export declare const TRIAGE_RUBRIC: string;
|
|
12
|
+
/** JSON Schema every triage verdict must satisfy. */
|
|
13
|
+
export declare const TRIAGE_VERDICT_SCHEMA: Record<string, unknown>;
|
|
14
|
+
/** A triage request bundle: the rubric, the verdict schema, and redacted contexts. */
|
|
15
|
+
export interface TriageRequest {
|
|
16
|
+
rubric: string;
|
|
17
|
+
schema: Record<string, unknown>;
|
|
18
|
+
contexts: RedactedContext[];
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Build a triage request bundle for a set of findings. Offline: for non-metadata
|
|
22
|
+
* levels, pass `readContent` to supply each finding's file text; without it,
|
|
23
|
+
* contexts are built at `metadata` level (no source), which is the safe default
|
|
24
|
+
* for the MCP plane where the host agent already has the code open.
|
|
25
|
+
*/
|
|
26
|
+
export declare function buildTriageRequest(findings: readonly Finding[], level?: ContextLevel, readContent?: (finding: Finding) => string): TriageRequest;
|
|
27
|
+
//# sourceMappingURL=triage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"triage.d.ts","sourceRoot":"","sources":["../src/triage.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAGtE,qEAAqE;AACrE,eAAO,MAAM,aAAa,QAS6C,CAAC;AAExE,qDAAqD;AACrD,eAAO,MAAM,qBAAqB,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAQzD,CAAC;AAEF,sFAAsF;AACtF,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,QAAQ,EAAE,eAAe,EAAE,CAAC;CAC7B;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,SAAS,OAAO,EAAE,EAC5B,KAAK,GAAE,YAAyB,EAChC,WAAW,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,MAAM,GACzC,aAAa,CAMf"}
|
package/dist/triage.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { buildContext } from "./redact.js";
|
|
2
|
+
/** The system rubric that defines what an exposure verdict means. */
|
|
3
|
+
export const TRIAGE_RUBRIC = "You are a post-quantum cryptography triage assistant. You are given ONE finding " +
|
|
4
|
+
"of classical (quantum-vulnerable) cryptography detected in a codebase, with " +
|
|
5
|
+
"limited, possibly-redacted context. Assess its REAL-WORLD exposure and urgency. " +
|
|
6
|
+
"exposureScore (0-100): how exploitable/exposed this usage is — a long-lived " +
|
|
7
|
+
"confidentiality key over the network (harvest-now-decrypt-later) scores high; a " +
|
|
8
|
+
"short-lived local signature scores lower. priority: 'now' for HNDL/high-exposure, " +
|
|
9
|
+
"'soon' for important-but-not-urgent, 'later' for low-exposure. You NEVER decide " +
|
|
10
|
+
"whether the finding is valid and you NEVER suppress it — you only rank exposure. " +
|
|
11
|
+
"Base your rationale only on the given context; do not invent facts.";
|
|
12
|
+
/** JSON Schema every triage verdict must satisfy. */
|
|
13
|
+
export const TRIAGE_VERDICT_SCHEMA = {
|
|
14
|
+
type: "object",
|
|
15
|
+
required: ["exposureScore", "priority", "rationale"],
|
|
16
|
+
properties: {
|
|
17
|
+
exposureScore: { type: "number", minimum: 0, maximum: 100 },
|
|
18
|
+
priority: { enum: ["now", "soon", "later"] },
|
|
19
|
+
rationale: { type: "string" },
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Build a triage request bundle for a set of findings. Offline: for non-metadata
|
|
24
|
+
* levels, pass `readContent` to supply each finding's file text; without it,
|
|
25
|
+
* contexts are built at `metadata` level (no source), which is the safe default
|
|
26
|
+
* for the MCP plane where the host agent already has the code open.
|
|
27
|
+
*/
|
|
28
|
+
export function buildTriageRequest(findings, level = "metadata", readContent) {
|
|
29
|
+
const effectiveLevel = readContent ? level : "metadata";
|
|
30
|
+
const contexts = findings.map((f) => buildContext(f, effectiveLevel, readContent ? readContent(f) : ""));
|
|
31
|
+
return { rubric: TRIAGE_RUBRIC, schema: TRIAGE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AM,EAAE,qBAAqB,EAAE,QAAQ,EAAE,CAAC;AAC5E,CAAC"}
|
package/dist/types.d.ts
CHANGED
|
@@ -26,6 +26,19 @@ export interface SourceLocation {
|
|
|
26
26
|
/** The matched source text (trimmed, single line). */
|
|
27
27
|
snippet?: string;
|
|
28
28
|
}
|
|
29
|
+
/** Relative urgency an LLM triage pass assigns to a finding. */
|
|
30
|
+
export type TriagePriority = "now" | "soon" | "later";
|
|
31
|
+
/**
|
|
32
|
+
* Optional LLM triage annotation attached to a finding by `qscan --triage`.
|
|
33
|
+
* Purely additive: it re-ranks and explains, it never suppresses a finding and
|
|
34
|
+
* never influences the exit code (which is computed from `severity` alone).
|
|
35
|
+
*/
|
|
36
|
+
export interface TriageAnnotation {
|
|
37
|
+
/** 0–100 real-world exposure/exploitability estimate. */
|
|
38
|
+
exposureScore: number;
|
|
39
|
+
priority: TriagePriority;
|
|
40
|
+
rationale: string;
|
|
41
|
+
}
|
|
29
42
|
/** A single detected concern. */
|
|
30
43
|
export interface Finding {
|
|
31
44
|
/** Stable rule identifier, e.g. "rsa-keygen", "ecdh-usage", "tls-legacy-version", "dep-vulnerable". */
|
|
@@ -50,13 +63,17 @@ export interface Finding {
|
|
|
50
63
|
* snippet for such findings, regardless of any redaction flag.
|
|
51
64
|
*/
|
|
52
65
|
sensitive?: boolean;
|
|
66
|
+
/** Optional LLM triage annotation (`qscan --triage`); never affects exit code. */
|
|
67
|
+
triage?: TriageAnnotation;
|
|
53
68
|
location: SourceLocation;
|
|
54
69
|
}
|
|
70
|
+
/** Package ecosystems the dependency scanner understands. */
|
|
71
|
+
export type DependencyEcosystem = "npm" | "pypi" | "cargo" | "go" | "maven" | "rubygems";
|
|
55
72
|
/** A known quantum-vulnerable dependency entry. */
|
|
56
73
|
export interface VulnerableDependency {
|
|
57
|
-
/** Package name. */
|
|
74
|
+
/** Package name (as written in the ecosystem's manifest). */
|
|
58
75
|
name: string;
|
|
59
|
-
ecosystem:
|
|
76
|
+
ecosystem: DependencyEcosystem;
|
|
60
77
|
/** Why it's flagged (what classical crypto it provides). */
|
|
61
78
|
reason: string;
|
|
62
79
|
/** Algorithm families the package primarily exposes. */
|
|
@@ -72,7 +89,46 @@ export type DetectorScope = "source" | "config";
|
|
|
72
89
|
* The programming language / surface a detector targets. `"any"` means the
|
|
73
90
|
* detector is language-agnostic (e.g. PEM material, config files).
|
|
74
91
|
*/
|
|
75
|
-
export type DetectorLanguage = "js" | "python" | "go" | "java" | "any";
|
|
92
|
+
export type DetectorLanguage = "js" | "python" | "go" | "java" | "csharp" | "rust" | "ruby" | "c" | "any";
|
|
93
|
+
/**
|
|
94
|
+
* Declarative metadata for a single rule a detector can emit. This is the
|
|
95
|
+
* catalog entry: the stable, queryable description of a rule keyed by the
|
|
96
|
+
* `ruleId` it stamps onto findings. It is the single source of truth for a
|
|
97
|
+
* rule's title / severity / category / remediation, consumed by the SARIF
|
|
98
|
+
* `rules[]` block, the MCP `explain_finding` resolver, and future per-rule
|
|
99
|
+
* enable/disable + language-pack work.
|
|
100
|
+
*
|
|
101
|
+
* For most rules the metadata is fixed and `detect()` builds findings straight
|
|
102
|
+
* from it (see `findingFromRule`). A few rules are inherently multi-variant
|
|
103
|
+
* (e.g. `node-crypto-keygen` spans RSA/EC/DSA/DH/Ed25519 at different
|
|
104
|
+
* severities); for those the metadata here is a REPRESENTATIVE umbrella and
|
|
105
|
+
* `detect()` refines the per-finding fields at match time. The catalog always
|
|
106
|
+
* enumerates every emittable ruleId regardless.
|
|
107
|
+
*/
|
|
108
|
+
export interface RuleMeta {
|
|
109
|
+
/** Stable rule id — matches {@link Finding.ruleId}. Unique across the catalog. */
|
|
110
|
+
id: string;
|
|
111
|
+
/** Canonical human title. */
|
|
112
|
+
title: string;
|
|
113
|
+
category: FindingCategory;
|
|
114
|
+
severity: Severity;
|
|
115
|
+
/** Default confidence for findings of this rule. */
|
|
116
|
+
confidence: Confidence;
|
|
117
|
+
/** Harvest-now-decrypt-later exposure. */
|
|
118
|
+
hndl: boolean;
|
|
119
|
+
/** Representative classical algorithm family; refined per-finding when it varies. */
|
|
120
|
+
algorithm?: AlgorithmFamily;
|
|
121
|
+
/** Associated CWE identifier (e.g. "CWE-327"). */
|
|
122
|
+
cwe?: string;
|
|
123
|
+
/** Suggested post-quantum remediation. When omitted, derived from {@link algorithm}. */
|
|
124
|
+
remediation?: string;
|
|
125
|
+
/** Canonical one-line human explanation; may be refined per-finding. */
|
|
126
|
+
message: string;
|
|
127
|
+
/** True when this rule's matched snippet IS sensitive key material. */
|
|
128
|
+
sensitive?: boolean;
|
|
129
|
+
/** Short description of what the rule detects (for catalog / MCP surfaces). */
|
|
130
|
+
description?: string;
|
|
131
|
+
}
|
|
76
132
|
/** A pluggable source detector. Detectors are pure and stateless. */
|
|
77
133
|
export interface Detector {
|
|
78
134
|
/** Unique id, used as the Finding.ruleId prefix space. */
|
|
@@ -90,6 +146,13 @@ export interface Detector {
|
|
|
90
146
|
* Defaults to `"js"` when omitted.
|
|
91
147
|
*/
|
|
92
148
|
language?: DetectorLanguage;
|
|
149
|
+
/**
|
|
150
|
+
* The rules this detector can emit, as declarative metadata. Together across
|
|
151
|
+
* all detectors these form the rule catalog ({@link DetectorRegistry.ruleCatalog}).
|
|
152
|
+
* Optional for backward compatibility with externally-defined detectors, but
|
|
153
|
+
* all built-in detectors declare it.
|
|
154
|
+
*/
|
|
155
|
+
rules?: RuleMeta[];
|
|
93
156
|
/** Whether this detector should run against the given file path. */
|
|
94
157
|
appliesTo(filePath: string): boolean;
|
|
95
158
|
/** Inspect a single file's contents and return zero or more findings. */
|
|
@@ -140,6 +203,21 @@ export interface ScanOptions {
|
|
|
140
203
|
* registry's detectors are used.
|
|
141
204
|
*/
|
|
142
205
|
detectors?: Detector[];
|
|
206
|
+
/**
|
|
207
|
+
* Rule ids to suppress. Any finding whose `ruleId` is listed here is dropped
|
|
208
|
+
* after detection. Serializable (a plain string array), so it is honoured on
|
|
209
|
+
* both the serial and the worker-thread (`scanParallel`) paths. See the rule
|
|
210
|
+
* catalog ({@link DetectorRegistry.ruleCatalog}) for the valid ids.
|
|
211
|
+
*/
|
|
212
|
+
disabledRules?: string[];
|
|
213
|
+
/**
|
|
214
|
+
* Path to an on-disk scan cache. When set, unchanged files (same content hash)
|
|
215
|
+
* reuse their previous findings instead of re-running detectors, and the cache
|
|
216
|
+
* is rewritten after the scan. Invalidated wholesale when the tool version,
|
|
217
|
+
* detector set, or `disabledRules` change. Optional; omitted = no caching.
|
|
218
|
+
* The cache forces the in-process (serial) path.
|
|
219
|
+
*/
|
|
220
|
+
cacheFile?: string;
|
|
143
221
|
/** Optional progress callback. */
|
|
144
222
|
onFile?: (file: string) => void;
|
|
145
223
|
/**
|
|
@@ -187,12 +265,37 @@ export interface CryptoInventory {
|
|
|
187
265
|
/** 0–100 readiness score (100 = no classical asymmetric crypto found). */
|
|
188
266
|
readinessScore: number;
|
|
189
267
|
}
|
|
268
|
+
/**
|
|
269
|
+
* Non-fatal things that happened during a scan that reduce coverage. Surfaced so
|
|
270
|
+
* a silent under-scan (e.g. half the tree was unreadable) can't masquerade as a
|
|
271
|
+
* clean "0 findings" result — reporters warn when any count is non-zero.
|
|
272
|
+
*/
|
|
273
|
+
export interface ScanDiagnostics {
|
|
274
|
+
/** Files that could not be read (permissions, vanished, decode failure) and were skipped. */
|
|
275
|
+
unreadable: number;
|
|
276
|
+
/** Files skipped because they look machine-minified / generated (scan with `scanMinified` to include). */
|
|
277
|
+
skippedMinified: number;
|
|
278
|
+
}
|
|
190
279
|
/** The full result of a scan. */
|
|
191
280
|
export interface ScanResult {
|
|
192
281
|
/** The scan root (as provided). */
|
|
193
282
|
root: string;
|
|
194
283
|
findings: Finding[];
|
|
195
284
|
filesScanned: number;
|
|
285
|
+
/**
|
|
286
|
+
* Coverage diagnostics: counts of files skipped as unreadable or minified.
|
|
287
|
+
* Optional for backward compatibility with hand-built results.
|
|
288
|
+
*/
|
|
289
|
+
diagnostics?: ScanDiagnostics;
|
|
290
|
+
/**
|
|
291
|
+
* Of `filesScanned`, how many were in a source language the scanner can
|
|
292
|
+
* actually analyze for inline crypto (JS/TS, Python, Go, Java). When this is 0 but
|
|
293
|
+
* `filesScanned` > 0, the readiness score reflects NO analyzable code — the
|
|
294
|
+
* crypto likely lives in an unsupported language (Go, Java, Rust, …) — and
|
|
295
|
+
* reporters surface that so a bare 100/100 can't read as "safe". Optional for
|
|
296
|
+
* backward compatibility with hand-built results.
|
|
297
|
+
*/
|
|
298
|
+
analyzedFiles?: number;
|
|
196
299
|
inventory: CryptoInventory;
|
|
197
300
|
/** ISO timestamps. */
|
|
198
301
|
startedAt: string;
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,6DAA6D;AAC7D,MAAM,MAAM,QAAQ,GAAG,UAAU,GAAG,MAAM,GAAG,QAAQ,GAAG,KAAK,GAAG,MAAM,CAAC;AAEvE,gFAAgF;AAChF,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,QAAQ,GAAG,KAAK,CAAC;AAEnD,+DAA+D;AAC/D,MAAM,MAAM,eAAe,GACvB,KAAK,GACL,cAAc,GACd,WAAW,GACX,KAAK,GACL,aAAa,GACb,YAAY,GACZ,MAAM,GACN,KAAK,CAAC;AAEV,yEAAyE;AACzE,MAAM,MAAM,eAAe,GACvB,KAAK,GACL,MAAM,GACN,OAAO,GACP,OAAO,GACP,IAAI,GACJ,KAAK,GACL,QAAQ,GACR,MAAM,GACN,OAAO,GACP,SAAS,CAAC;AAEd,gDAAgD;AAChD,MAAM,WAAW,cAAc;IAC7B,8DAA8D;IAC9D,IAAI,EAAE,MAAM,CAAC;IACb,2BAA2B;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,uCAAuC;IACvC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,gDAAgD;IAChD,OAAO,CAAC,EAAE,MAAM,CAAC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nB,6CAA6C;IAC7C,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,iDAAiD;AACjD,MAAM,MAAM,YAAY,GAAG,OAAO,GAAG,MAAM,GAAG,OAAO,CAAC;AAEtD,8DAA8D;AAC9D,MAAM,WAAW,WAAW;IAC1B,SAAS,EAAE,eAAe,CAAC;IAC3B,gFAAgF;IAChF,cAAc,EAAE,MAAM,CAAC;IACvB,wBAAwB;IACxB,MAAM,EAAE,MAAM,CAAC;CAChB"}
|
package/dist/verify.d.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Snippet-level fix verification: run the detectors over a piece of code (NOT
|
|
3
|
+
* the filesystem) and report any classical crypto that remains. This is the
|
|
4
|
+
* deterministic gate a fix must pass — the same logic the MCP `verify_fix` tool
|
|
5
|
+
* and the remediation pipeline both use, so they can never disagree on what
|
|
6
|
+
* "the finding is gone" means.
|
|
7
|
+
*/
|
|
8
|
+
import type { Finding } from "./types.js";
|
|
9
|
+
/**
|
|
10
|
+
* Map a language name (or a bare extension) to a source extension whose
|
|
11
|
+
* detectors we run. Returns null for languages the scanner does not analyze.
|
|
12
|
+
*/
|
|
13
|
+
export declare function languageToExtension(language: string): string | null;
|
|
14
|
+
/** Result of {@link verifyFix}: the findings that remain, and whether the
|
|
15
|
+
* language is one the scanner actually analyzes (so `findings: []` on an
|
|
16
|
+
* unsupported language is NOT a clean verification). */
|
|
17
|
+
export interface VerifyResult {
|
|
18
|
+
supported: boolean;
|
|
19
|
+
findings: Finding[];
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Run all detectors over `code`, selecting them by `filename` (extension) or
|
|
23
|
+
* `language`. Pure: no I/O. When neither identifies an analyzable language,
|
|
24
|
+
* `supported` is false and the empty findings list must not be read as "fixed".
|
|
25
|
+
*/
|
|
26
|
+
export declare function verifyFix(code: string, opts: {
|
|
27
|
+
filename?: string;
|
|
28
|
+
language?: string;
|
|
29
|
+
}): VerifyResult;
|
|
30
|
+
//# sourceMappingURL=verify.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"verify.d.ts","sourceRoot":"","sources":["../src/verify.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAG1C;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAkCnE;AAED;;wDAEwD;AACxD,MAAM,WAAW,YAAY;IAC3B,SAAS,EAAE,OAAO,CAAC;IACnB,QAAQ,EAAE,OAAO,EAAE,CAAC;CACrB;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CACvB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE;IAAE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,GAC7C,YAAY,CAed"}
|
package/dist/verify.js
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { detectFile, detectors } from "./scan.js";
|
|
2
|
+
/**
|
|
3
|
+
* Map a language name (or a bare extension) to a source extension whose
|
|
4
|
+
* detectors we run. Returns null for languages the scanner does not analyze.
|
|
5
|
+
*/
|
|
6
|
+
export function languageToExtension(language) {
|
|
7
|
+
const l = language.trim().toLowerCase().replace(/^\./, "");
|
|
8
|
+
const map = {
|
|
9
|
+
js: ".js",
|
|
10
|
+
javascript: ".js",
|
|
11
|
+
jsx: ".jsx",
|
|
12
|
+
ts: ".ts",
|
|
13
|
+
typescript: ".ts",
|
|
14
|
+
tsx: ".tsx",
|
|
15
|
+
mjs: ".mjs",
|
|
16
|
+
cjs: ".cjs",
|
|
17
|
+
py: ".py",
|
|
18
|
+
python: ".py",
|
|
19
|
+
go: ".go",
|
|
20
|
+
golang: ".go",
|
|
21
|
+
java: ".java",
|
|
22
|
+
kotlin: ".kt",
|
|
23
|
+
kt: ".kt",
|
|
24
|
+
cs: ".cs",
|
|
25
|
+
csharp: ".cs",
|
|
26
|
+
"c#": ".cs",
|
|
27
|
+
dotnet: ".cs",
|
|
28
|
+
rs: ".rs",
|
|
29
|
+
rust: ".rs",
|
|
30
|
+
rb: ".rb",
|
|
31
|
+
ruby: ".rb",
|
|
32
|
+
c: ".c",
|
|
33
|
+
"c++": ".cpp",
|
|
34
|
+
cpp: ".cpp",
|
|
35
|
+
cc: ".cc",
|
|
36
|
+
h: ".h",
|
|
37
|
+
hpp: ".hpp",
|
|
38
|
+
};
|
|
39
|
+
return map[l] ?? null;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Run all detectors over `code`, selecting them by `filename` (extension) or
|
|
43
|
+
* `language`. Pure: no I/O. When neither identifies an analyzable language,
|
|
44
|
+
* `supported` is false and the empty findings list must not be read as "fixed".
|
|
45
|
+
*/
|
|
46
|
+
export function verifyFix(code, opts) {
|
|
47
|
+
let name;
|
|
48
|
+
if (opts.filename && opts.filename.trim()) {
|
|
49
|
+
name = opts.filename.trim();
|
|
50
|
+
}
|
|
51
|
+
else if (opts.language && opts.language.trim()) {
|
|
52
|
+
const ext = languageToExtension(opts.language);
|
|
53
|
+
if (!ext)
|
|
54
|
+
return { supported: false, findings: [] };
|
|
55
|
+
name = `snippet${ext}`;
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
return { supported: false, findings: [] };
|
|
59
|
+
}
|
|
60
|
+
const dotExt = name.replace(/^.*(\.[^.]+)$/, "$1");
|
|
61
|
+
const supported = languageToExtension(dotExt) !== null;
|
|
62
|
+
const findings = detectFile(name, code, detectors, { source: true, config: true, deps: true });
|
|
63
|
+
return { supported, findings };
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=verify.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"verify.js","sourceRoot":"","sources":["../src/verify.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;A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CAAC,QAAQ,CAAC,IAAI,EAAE,EAAE,CAAC;QACjD,MAAM,GAAG,GAAG,mBAAmB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC/C,IAAI,CAAC,GAAG;YAAE,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC;QACpD,IAAI,GAAG,UAAU,GAAG,EAAE,CAAC;IACzB,CAAC;SAAM,CAAC;QACN,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC;IAC5C,CAAC;IACD,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,eAAe,EAAE,IAAI,CAAC,CAAC;IACnD,MAAM,SAAS,GAAG,mBAAmB,CAAC,MAAM,CAAC,KAAK,IAAI,CAAC;IACvD,MAAM,QAAQ,GAAG,UAAU,CAAC,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;IAC/F,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC;AACjC,CAAC"}
|
package/dist/version.d.ts
CHANGED
package/dist/version.js
CHANGED
package/dist/walk.d.ts
CHANGED
|
@@ -18,6 +18,13 @@ export interface WalkOptions {
|
|
|
18
18
|
}
|
|
19
19
|
/** Normalise a path to forward-slash POSIX separators. */
|
|
20
20
|
export declare function toPosix(p: string): string;
|
|
21
|
+
/**
|
|
22
|
+
* True if `rel` (a POSIX relative path) matches any pattern. A pattern with a
|
|
23
|
+
* glob metacharacter (`*`, `?`, `[`) is matched as an anchored glob; a plain
|
|
24
|
+
* pattern keeps the historical substring / path-prefix semantics (so `"src"`
|
|
25
|
+
* still matches `src/a.ts` and `"secrets"` matches anywhere).
|
|
26
|
+
*/
|
|
27
|
+
export declare function matchesAny(rel: string, patterns: readonly string[]): boolean;
|
|
21
28
|
/** True if the file's extension marks it as binary / non-text. */
|
|
22
29
|
export declare function isBinaryPath(rel: string): boolean;
|
|
23
30
|
/** True if the path looks like generated / bundled output (by name). */
|
package/dist/walk.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"walk.d.ts","sourceRoot":"","sources":["../src/walk.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"walk.d.ts","sourceRoot":"","sources":["../src/walk.ts"],"names":[],"mappings":"AAYA,8EAA8E;AAC9E,eAAO,MAAM,eAAe,EAAE,SAAS,MAAM,EAW5C,CAAC;AAEF,gDAAgD;AAChD,eAAO,MAAM,qBAAqB,QAAkB,CAAC;AAyErD,6CAA6C;AAC7C,MAAM,WAAW,WAAW;IAC1B;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,wEAAwE;IACxE,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,kDAAkD;IAClD,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,wDAAwD;IACxD,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,0DAA0D;AAC1D,wBAAgB,OAAO,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAEzC;AA6DD;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,MAAM,EAAE,GAAG,OAAO,CAc5E;AAgBD,kEAAkE;AAClE,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAMjD;AASD,wEAAwE;AACxE,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAEpD;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAmBtD;AAED;;;;GAIG;AACH,wBAAuB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,WAAgB,GAAG,cAAc,CAAC,MAAM,CAAC,CAsBhG"}
|