@quantakrypto/core 0.1.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 +337 -0
- package/dist/baseline.d.ts +37 -0
- package/dist/baseline.d.ts.map +1 -0
- package/dist/baseline.js +99 -0
- package/dist/baseline.js.map +1 -0
- package/dist/cbom.d.ts +25 -0
- package/dist/cbom.d.ts.map +1 -0
- package/dist/cbom.js +131 -0
- package/dist/cbom.js.map +1 -0
- package/dist/changed.d.ts +13 -0
- package/dist/changed.d.ts.map +1 -0
- package/dist/changed.js +67 -0
- package/dist/changed.js.map +1 -0
- package/dist/config.d.ts +55 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +232 -0
- package/dist/config.js.map +1 -0
- package/dist/cwe.d.ts +16 -0
- package/dist/cwe.d.ts.map +1 -0
- package/dist/cwe.js +16 -0
- package/dist/cwe.js.map +1 -0
- package/dist/dependencies.d.ts +25 -0
- package/dist/dependencies.d.ts.map +1 -0
- package/dist/dependencies.js +276 -0
- package/dist/dependencies.js.map +1 -0
- package/dist/detect-utils.d.ts +63 -0
- package/dist/detect-utils.d.ts.map +1 -0
- package/dist/detect-utils.js +113 -0
- package/dist/detect-utils.js.map +1 -0
- package/dist/detectors/pem.d.ts +9 -0
- package/dist/detectors/pem.d.ts.map +1 -0
- package/dist/detectors/pem.js +137 -0
- package/dist/detectors/pem.js.map +1 -0
- package/dist/detectors/source.d.ts +25 -0
- package/dist/detectors/source.d.ts.map +1 -0
- package/dist/detectors/source.js +575 -0
- package/dist/detectors/source.js.map +1 -0
- package/dist/index.d.ts +31 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +39 -0
- package/dist/index.js.map +1 -0
- package/dist/inventory.d.ts +15 -0
- package/dist/inventory.d.ts.map +1 -0
- package/dist/inventory.js +74 -0
- package/dist/inventory.js.map +1 -0
- package/dist/parallel.d.ts +34 -0
- package/dist/parallel.d.ts.map +1 -0
- package/dist/parallel.js +237 -0
- package/dist/parallel.js.map +1 -0
- package/dist/registry.d.ts +42 -0
- package/dist/registry.d.ts.map +1 -0
- package/dist/registry.js +51 -0
- package/dist/registry.js.map +1 -0
- package/dist/remediation.d.ts +42 -0
- package/dist/remediation.d.ts.map +1 -0
- package/dist/remediation.js +131 -0
- package/dist/remediation.js.map +1 -0
- package/dist/report.d.ts +24 -0
- package/dist/report.d.ts.map +1 -0
- package/dist/report.js +286 -0
- package/dist/report.js.map +1 -0
- package/dist/scan-worker.d.ts +2 -0
- package/dist/scan-worker.d.ts.map +1 -0
- package/dist/scan-worker.js +63 -0
- package/dist/scan-worker.js.map +1 -0
- package/dist/scan.d.ts +27 -0
- package/dist/scan.d.ts.map +1 -0
- package/dist/scan.js +168 -0
- package/dist/scan.js.map +1 -0
- package/dist/types.d.ts +190 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +9 -0
- package/dist/types.js.map +1 -0
- package/dist/version.d.ts +7 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +7 -0
- package/dist/version.js.map +1 -0
- package/dist/walk.d.ts +37 -0
- package/dist/walk.d.ts.map +1 -0
- package/dist/walk.js +260 -0
- package/dist/walk.js.map +1 -0
- package/package.json +40 -0
- package/src/baseline.ts +111 -0
- package/src/cbom.ts +166 -0
- package/src/changed.ts +76 -0
- package/src/config.ts +295 -0
- package/src/cwe.ts +20 -0
- package/src/dependencies.ts +299 -0
- package/src/detect-utils.ts +157 -0
- package/src/detectors/pem.ts +162 -0
- package/src/detectors/source.ts +733 -0
- package/src/index.ts +79 -0
- package/src/inventory.ts +94 -0
- package/src/parallel.ts +288 -0
- package/src/registry.ts +71 -0
- package/src/remediation.ts +173 -0
- package/src/report.ts +340 -0
- package/src/scan-worker.ts +80 -0
- package/src/scan.ts +187 -0
- package/src/types.ts +224 -0
- package/src/version.ts +6 -0
- package/src/walk.ts +289 -0
package/dist/scan.js
ADDED
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Scan orchestrator. Walks the target (or an explicit file list), runs the
|
|
3
|
+
* applicable detectors over each file, parses dependency manifests, aggregates
|
|
4
|
+
* everything into an inventory, and returns a {@link ScanResult} with timing and
|
|
5
|
+
* the tool version.
|
|
6
|
+
*
|
|
7
|
+
* Detector scope (source vs config) is driven by each {@link Detector}'s
|
|
8
|
+
* declared `scope` (defaulting to "source"), not by ruleId prefixes. The
|
|
9
|
+
* detector set comes from {@link defaultRegistry} unless overridden via
|
|
10
|
+
* `options.detectors`.
|
|
11
|
+
*/
|
|
12
|
+
import { readFile, stat } from "node:fs/promises";
|
|
13
|
+
import * as path from "node:path";
|
|
14
|
+
import { walkFiles, toPosix, isBinaryPath, looksMinified } from "./walk.js";
|
|
15
|
+
import { sourceDetectors } from "./detectors/source.js";
|
|
16
|
+
import { pemDetector } from "./detectors/pem.js";
|
|
17
|
+
import { defaultRegistry, detectorScope } from "./registry.js";
|
|
18
|
+
import { isManifestFile, scanManifest } from "./dependencies.js";
|
|
19
|
+
import { buildInventory } from "./inventory.js";
|
|
20
|
+
import { VERSION } from "./version.js";
|
|
21
|
+
/**
|
|
22
|
+
* The full set of built-in detectors exposed on the public API. The PEM
|
|
23
|
+
* detector applies to every text file; the source detectors apply only to
|
|
24
|
+
* JS/TS. The manifest scanner is handled separately (it parses JSON rather than
|
|
25
|
+
* running a Detector).
|
|
26
|
+
*/
|
|
27
|
+
export const detectors = [...sourceDetectors, pemDetector];
|
|
28
|
+
/** Stable comparator: by file, then line, then ruleId. Exported for reuse. */
|
|
29
|
+
export function compareFindings(a, b) {
|
|
30
|
+
if (a.location.file !== b.location.file)
|
|
31
|
+
return a.location.file < b.location.file ? -1 : 1;
|
|
32
|
+
if (a.location.line !== b.location.line)
|
|
33
|
+
return a.location.line - b.location.line;
|
|
34
|
+
return a.ruleId < b.ruleId ? -1 : a.ruleId > b.ruleId ? 1 : 0;
|
|
35
|
+
}
|
|
36
|
+
/** Resolve the active detector list for a scan (override or the default registry). */
|
|
37
|
+
function resolveDetectors(options) {
|
|
38
|
+
return options.detectors ?? defaultRegistry.all();
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Run all applicable detectors + the manifest scanner over a single file's
|
|
42
|
+
* contents, honouring the source / config / dependencies toggles. Pure: no I/O.
|
|
43
|
+
* Exported so the parallel worker and unit tests can drive it directly.
|
|
44
|
+
*/
|
|
45
|
+
export function detectFile(file, content, dets, toggles) {
|
|
46
|
+
const out = [];
|
|
47
|
+
for (const det of dets) {
|
|
48
|
+
if (!det.appliesTo(file))
|
|
49
|
+
continue;
|
|
50
|
+
const isConfig = detectorScope(det) === "config";
|
|
51
|
+
if (isConfig ? !toggles.config : !toggles.source)
|
|
52
|
+
continue;
|
|
53
|
+
out.push(...det.detect({ file, content }));
|
|
54
|
+
}
|
|
55
|
+
if (toggles.deps && isManifestFile(file)) {
|
|
56
|
+
out.push(...scanManifest(file, content));
|
|
57
|
+
}
|
|
58
|
+
return out;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Recursively scan a directory (or single file, or explicit file list) for
|
|
62
|
+
* classical asymmetric crypto. Honours the source / dependencies / config
|
|
63
|
+
* toggles (all default true) and reports progress through `options.onFile`.
|
|
64
|
+
*/
|
|
65
|
+
export async function scan(options) {
|
|
66
|
+
const startedAt = new Date();
|
|
67
|
+
const doSource = options.source !== false;
|
|
68
|
+
const doDeps = options.dependencies !== false;
|
|
69
|
+
const doConfig = options.config !== false;
|
|
70
|
+
const scanMinified = options.scanMinified === true;
|
|
71
|
+
const dets = resolveDetectors(options);
|
|
72
|
+
// Resolve whether the root is a file so we can rebuild absolute paths to read.
|
|
73
|
+
const rootStat = await stat(options.root);
|
|
74
|
+
const rootIsFile = rootStat.isFile();
|
|
75
|
+
const baseDir = rootIsFile ? path.dirname(options.root) : options.root;
|
|
76
|
+
const singleFileName = rootIsFile ? path.basename(options.root) : null;
|
|
77
|
+
const findings = [];
|
|
78
|
+
let filesScanned = 0;
|
|
79
|
+
// Source of relative paths: an explicit file list (incremental) or the walker.
|
|
80
|
+
const relPaths = options.files
|
|
81
|
+
? filterExplicitFiles(options.files, options)
|
|
82
|
+
: walkFiles(options.root, {
|
|
83
|
+
include: options.include,
|
|
84
|
+
exclude: options.exclude,
|
|
85
|
+
noDefaultIgnores: options.noDefaultIgnores,
|
|
86
|
+
maxFileSize: options.maxFileSize,
|
|
87
|
+
});
|
|
88
|
+
for await (const rel of relPaths) {
|
|
89
|
+
// In single-file mode, walkFiles yields the basename; map back to the file.
|
|
90
|
+
const absPath = singleFileName ? options.root : path.join(baseDir, ...rel.split("/"));
|
|
91
|
+
const reportedPath = singleFileName ? toPosix(rel) : rel;
|
|
92
|
+
options.onFile?.(reportedPath);
|
|
93
|
+
let content;
|
|
94
|
+
try {
|
|
95
|
+
content = await readFile(absPath, "utf8");
|
|
96
|
+
}
|
|
97
|
+
catch {
|
|
98
|
+
continue; // unreadable / vanished file — skip.
|
|
99
|
+
}
|
|
100
|
+
// Skip machine-minified / generated content (unless explicitly enabled).
|
|
101
|
+
// Manifests are always scanned (their findings are dependency findings).
|
|
102
|
+
if (!scanMinified && !isManifestFile(reportedPath) && looksMinified(content)) {
|
|
103
|
+
continue;
|
|
104
|
+
}
|
|
105
|
+
filesScanned += 1;
|
|
106
|
+
findings.push(...detectFile(reportedPath, content, dets, {
|
|
107
|
+
source: doSource,
|
|
108
|
+
config: doConfig,
|
|
109
|
+
deps: doDeps,
|
|
110
|
+
}));
|
|
111
|
+
}
|
|
112
|
+
// Stable ordering: by file, then line, then ruleId.
|
|
113
|
+
findings.sort(compareFindings);
|
|
114
|
+
const inventory = buildInventory(findings);
|
|
115
|
+
const finishedAt = new Date();
|
|
116
|
+
return {
|
|
117
|
+
root: options.root,
|
|
118
|
+
findings,
|
|
119
|
+
filesScanned,
|
|
120
|
+
inventory,
|
|
121
|
+
startedAt: startedAt.toISOString(),
|
|
122
|
+
finishedAt: finishedAt.toISOString(),
|
|
123
|
+
toolVersion: VERSION,
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Filter an explicit relative file list down to the paths that pass the binary
|
|
128
|
+
* filter and the include/exclude patterns, yielding them in sorted order for
|
|
129
|
+
* deterministic output. Size limits are enforced later (we still read manifests
|
|
130
|
+
* over the cap). Non-existent files are simply skipped at read time.
|
|
131
|
+
*/
|
|
132
|
+
async function* filterExplicitFiles(files, options) {
|
|
133
|
+
const include = options.include ?? [];
|
|
134
|
+
const exclude = options.exclude ?? [];
|
|
135
|
+
const seen = new Set();
|
|
136
|
+
const list = [...files]
|
|
137
|
+
.map((f) => toPosix(f))
|
|
138
|
+
.filter((f) => {
|
|
139
|
+
if (seen.has(f))
|
|
140
|
+
return false;
|
|
141
|
+
seen.add(f);
|
|
142
|
+
return true;
|
|
143
|
+
})
|
|
144
|
+
.sort((a, b) => (a < b ? -1 : a > b ? 1 : 0));
|
|
145
|
+
for (const rel of list) {
|
|
146
|
+
if (isBinaryPath(rel))
|
|
147
|
+
continue;
|
|
148
|
+
if (include.length > 0 && !matchesAny(rel, include))
|
|
149
|
+
continue;
|
|
150
|
+
if (matchesAny(rel, exclude))
|
|
151
|
+
continue;
|
|
152
|
+
yield rel;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
/** Local substring/prefix matcher (mirrors the walker's pattern semantics). */
|
|
156
|
+
function matchesAny(rel, patterns) {
|
|
157
|
+
for (const pattern of patterns) {
|
|
158
|
+
if (!pattern)
|
|
159
|
+
continue;
|
|
160
|
+
const p = toPosix(pattern).replace(/\/+$/, "");
|
|
161
|
+
if (rel.includes(p))
|
|
162
|
+
return true;
|
|
163
|
+
if (rel === p || rel.startsWith(`${p}/`))
|
|
164
|
+
return true;
|
|
165
|
+
}
|
|
166
|
+
return false;
|
|
167
|
+
}
|
|
168
|
+
//# sourceMappingURL=scan.js.map
|
package/dist/scan.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scan.js","sourceRoot":"","sources":["../src/scan.ts"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QAAQ,CAAC,CAAC,CAAC;YAAE,OAAO,IAAI,CAAC;QACjC,IAAI,GAAG,KAAK,CAAC,IAAI,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,GAAG,CAAC;YAAE,OAAO,IAAI,CAAC;IACxD,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @quantakrypto/core — shared types (the locked public contract).
|
|
3
|
+
*
|
|
4
|
+
* These types are the stable interface between every tool in the monorepo
|
|
5
|
+
* (qScan, the MCP server, the GitHub Action). Treat additions as backwards
|
|
6
|
+
* compatible; treat renames/removals as breaking.
|
|
7
|
+
*/
|
|
8
|
+
/** How serious a finding is, ordered most → least severe. */
|
|
9
|
+
export type Severity = "critical" | "high" | "medium" | "low" | "info";
|
|
10
|
+
/** How sure the detector is that the finding is a real use of the algorithm. */
|
|
11
|
+
export type Confidence = "high" | "medium" | "low";
|
|
12
|
+
/** What kind of cryptographic concern a finding represents. */
|
|
13
|
+
export type FindingCategory = "kem" | "key-exchange" | "signature" | "tls" | "certificate" | "dependency" | "hash" | "rng";
|
|
14
|
+
/** Classical asymmetric algorithm families that are not quantum-safe. */
|
|
15
|
+
export type AlgorithmFamily = "RSA" | "ECDH" | "ECDSA" | "EdDSA" | "DH" | "DSA" | "X25519" | "X448" | "ECIES" | "unknown";
|
|
16
|
+
/** A precise location inside a scanned file. */
|
|
17
|
+
export interface SourceLocation {
|
|
18
|
+
/** Path relative to the scan root, using POSIX separators. */
|
|
19
|
+
file: string;
|
|
20
|
+
/** 1-based line number. */
|
|
21
|
+
line: number;
|
|
22
|
+
/** 1-based column number, if known. */
|
|
23
|
+
column?: number;
|
|
24
|
+
/** 1-based end line, for multi-line matches. */
|
|
25
|
+
endLine?: number;
|
|
26
|
+
/** The matched source text (trimmed, single line). */
|
|
27
|
+
snippet?: string;
|
|
28
|
+
}
|
|
29
|
+
/** A single detected concern. */
|
|
30
|
+
export interface Finding {
|
|
31
|
+
/** Stable rule identifier, e.g. "rsa-keygen", "ecdh-usage", "tls-legacy-version", "dep-vulnerable". */
|
|
32
|
+
ruleId: string;
|
|
33
|
+
title: string;
|
|
34
|
+
category: FindingCategory;
|
|
35
|
+
severity: Severity;
|
|
36
|
+
confidence: Confidence;
|
|
37
|
+
/** The classical algorithm involved, when applicable. */
|
|
38
|
+
algorithm?: AlgorithmFamily;
|
|
39
|
+
/** True when this is exposed to "harvest now, decrypt later". */
|
|
40
|
+
hndl: boolean;
|
|
41
|
+
/** One-line human explanation of the concern. */
|
|
42
|
+
message: string;
|
|
43
|
+
/** Suggested post-quantum remediation (e.g. ML-KEM, hybrid X25519MLKEM768). */
|
|
44
|
+
remediation?: string;
|
|
45
|
+
/** Associated CWE identifier, e.g. "CWE-327" (broken crypto), "CWE-326" (weak strength). */
|
|
46
|
+
cwe?: string;
|
|
47
|
+
location: SourceLocation;
|
|
48
|
+
}
|
|
49
|
+
/** A known quantum-vulnerable dependency entry. */
|
|
50
|
+
export interface VulnerableDependency {
|
|
51
|
+
/** Package name. */
|
|
52
|
+
name: string;
|
|
53
|
+
ecosystem: "npm";
|
|
54
|
+
/** Why it's flagged (what classical crypto it provides). */
|
|
55
|
+
reason: string;
|
|
56
|
+
/** Algorithm families the package primarily exposes. */
|
|
57
|
+
algorithms: AlgorithmFamily[];
|
|
58
|
+
severity: Severity;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Which logical scope a detector belongs to. Drives the source/config scope
|
|
62
|
+
* toggles in {@link ScanOptions} (replacing the old ruleId-prefix inference).
|
|
63
|
+
*/
|
|
64
|
+
export type DetectorScope = "source" | "config";
|
|
65
|
+
/**
|
|
66
|
+
* The programming language / surface a detector targets. `"any"` means the
|
|
67
|
+
* detector is language-agnostic (e.g. PEM material, config files).
|
|
68
|
+
*/
|
|
69
|
+
export type DetectorLanguage = "js" | "python" | "go" | "java" | "any";
|
|
70
|
+
/** A pluggable source detector. Detectors are pure and stateless. */
|
|
71
|
+
export interface Detector {
|
|
72
|
+
/** Unique id, used as the Finding.ruleId prefix space. */
|
|
73
|
+
id: string;
|
|
74
|
+
/** Human description of what the detector looks for. */
|
|
75
|
+
description: string;
|
|
76
|
+
/**
|
|
77
|
+
* Logical scope of this detector's findings. Used by `scan()` to honour the
|
|
78
|
+
* `config` / `source` toggles. Defaults to `"source"` when omitted (for
|
|
79
|
+
* backward compatibility with externally-defined detectors).
|
|
80
|
+
*/
|
|
81
|
+
scope?: DetectorScope;
|
|
82
|
+
/**
|
|
83
|
+
* Language this detector targets, for documentation / registry filtering.
|
|
84
|
+
* Defaults to `"js"` when omitted.
|
|
85
|
+
*/
|
|
86
|
+
language?: DetectorLanguage;
|
|
87
|
+
/** Whether this detector should run against the given file path. */
|
|
88
|
+
appliesTo(filePath: string): boolean;
|
|
89
|
+
/** Inspect a single file's contents and return zero or more findings. */
|
|
90
|
+
detect(input: DetectorInput): Finding[];
|
|
91
|
+
}
|
|
92
|
+
export interface DetectorInput {
|
|
93
|
+
/** Path relative to the scan root (POSIX). */
|
|
94
|
+
file: string;
|
|
95
|
+
/** Full file contents. */
|
|
96
|
+
content: string;
|
|
97
|
+
}
|
|
98
|
+
/** Options controlling a scan. */
|
|
99
|
+
export interface ScanOptions {
|
|
100
|
+
/** Absolute or relative directory (or single file) to scan. */
|
|
101
|
+
root: string;
|
|
102
|
+
/**
|
|
103
|
+
* Restrict the walk to paths matching one of these include patterns
|
|
104
|
+
* (substring or relative-path-prefix match). When omitted, all non-excluded
|
|
105
|
+
* files are scanned. Wired into the walker.
|
|
106
|
+
*/
|
|
107
|
+
include?: string[];
|
|
108
|
+
/** Extra exclude patterns (in addition to the built-in defaults). */
|
|
109
|
+
exclude?: string[];
|
|
110
|
+
/** Disable the built-in ignore list (node_modules, .git, dist, …). */
|
|
111
|
+
noDefaultIgnores?: boolean;
|
|
112
|
+
/** Scan source files for inline crypto usage. Default: true. */
|
|
113
|
+
source?: boolean;
|
|
114
|
+
/** Scan dependency manifests/lockfiles for vulnerable libraries. Default: true. */
|
|
115
|
+
dependencies?: boolean;
|
|
116
|
+
/** Scan config files (TLS, certificates). Default: true. */
|
|
117
|
+
config?: boolean;
|
|
118
|
+
/** Max file size to read, in bytes. Default: 2 MiB. */
|
|
119
|
+
maxFileSize?: number;
|
|
120
|
+
/**
|
|
121
|
+
* Scan minified / generated / bundled files (large single-line content)
|
|
122
|
+
* instead of skipping them. Default: false (skip them for speed).
|
|
123
|
+
*/
|
|
124
|
+
scanMinified?: boolean;
|
|
125
|
+
/**
|
|
126
|
+
* Explicit relative file list (POSIX, relative to `root`) to scan instead of
|
|
127
|
+
* walking the tree. Used for incremental / changed-files scans. Each path is
|
|
128
|
+
* still subject to the binary / size filters. When set, the directory walk is
|
|
129
|
+
* bypassed entirely.
|
|
130
|
+
*/
|
|
131
|
+
files?: string[];
|
|
132
|
+
/**
|
|
133
|
+
* Override / extend the built-in detector set. When omitted, the default
|
|
134
|
+
* registry's detectors are used.
|
|
135
|
+
*/
|
|
136
|
+
detectors?: Detector[];
|
|
137
|
+
/** Optional progress callback. */
|
|
138
|
+
onFile?: (file: string) => void;
|
|
139
|
+
}
|
|
140
|
+
/** Extra options for {@link scanParallel}, layered onto {@link ScanOptions}. */
|
|
141
|
+
export interface ParallelScanOptions extends ScanOptions {
|
|
142
|
+
/**
|
|
143
|
+
* Number of worker threads. Default: `os.availableParallelism()`. A value of
|
|
144
|
+
* 0 or 1 forces the in-process serial path.
|
|
145
|
+
*/
|
|
146
|
+
concurrency?: number;
|
|
147
|
+
/**
|
|
148
|
+
* Combined-size floor (bytes) below which the scan always runs in-process.
|
|
149
|
+
* Default: 2 MiB. Also stays serial below `parallelFileThreshold` files.
|
|
150
|
+
*/
|
|
151
|
+
parallelThresholdBytes?: number;
|
|
152
|
+
/** File-count floor below which the scan always runs in-process. Default: 200. */
|
|
153
|
+
parallelFileThreshold?: number;
|
|
154
|
+
/** Target bytes per worker chunk. Default: 4 MiB. */
|
|
155
|
+
chunkBytes?: number;
|
|
156
|
+
}
|
|
157
|
+
/** Aggregated counts produced from a scan's findings. */
|
|
158
|
+
export interface CryptoInventory {
|
|
159
|
+
byAlgorithm: Partial<Record<AlgorithmFamily, number>>;
|
|
160
|
+
byCategory: Partial<Record<FindingCategory, number>>;
|
|
161
|
+
bySeverity: Record<Severity, number>;
|
|
162
|
+
/** Number of findings exposed to harvest-now-decrypt-later. */
|
|
163
|
+
hndlCount: number;
|
|
164
|
+
/** 0–100 readiness score (100 = no classical asymmetric crypto found). */
|
|
165
|
+
readinessScore: number;
|
|
166
|
+
}
|
|
167
|
+
/** The full result of a scan. */
|
|
168
|
+
export interface ScanResult {
|
|
169
|
+
/** The scan root (as provided). */
|
|
170
|
+
root: string;
|
|
171
|
+
findings: Finding[];
|
|
172
|
+
filesScanned: number;
|
|
173
|
+
inventory: CryptoInventory;
|
|
174
|
+
/** ISO timestamps. */
|
|
175
|
+
startedAt: string;
|
|
176
|
+
finishedAt: string;
|
|
177
|
+
/** Tool version that produced the result. */
|
|
178
|
+
toolVersion: string;
|
|
179
|
+
}
|
|
180
|
+
/** Output formats qScan / reporters can emit. */
|
|
181
|
+
export type ReportFormat = "human" | "json" | "sarif";
|
|
182
|
+
/** A remediation recommendation for a classical algorithm. */
|
|
183
|
+
export interface Remediation {
|
|
184
|
+
algorithm: AlgorithmFamily;
|
|
185
|
+
/** Short recommended replacement, e.g. "ML-KEM-768 (hybrid X25519MLKEM768)". */
|
|
186
|
+
recommendation: string;
|
|
187
|
+
/** Longer rationale. */
|
|
188
|
+
detail: string;
|
|
189
|
+
}
|
|
190
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +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,G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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/types.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @quantakrypto/core — shared types (the locked public contract).
|
|
3
|
+
*
|
|
4
|
+
* These types are the stable interface between every tool in the monorepo
|
|
5
|
+
* (qScan, the MCP server, the GitHub Action). Treat additions as backwards
|
|
6
|
+
* compatible; treat renames/removals as breaking.
|
|
7
|
+
*/
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The tool version surfaced in reports. Kept in its own module so reporters and
|
|
3
|
+
* the scan orchestrator can import it without creating a cycle through index.ts.
|
|
4
|
+
* Keep in sync with packages/core/package.json.
|
|
5
|
+
*/
|
|
6
|
+
export declare const VERSION = "0.1.0";
|
|
7
|
+
//# sourceMappingURL=version.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,eAAO,MAAM,OAAO,UAAU,CAAC"}
|
package/dist/version.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The tool version surfaced in reports. Kept in its own module so reporters and
|
|
3
|
+
* the scan orchestrator can import it without creating a cycle through index.ts.
|
|
4
|
+
* Keep in sync with packages/core/package.json.
|
|
5
|
+
*/
|
|
6
|
+
export const VERSION = "0.1.0";
|
|
7
|
+
//# sourceMappingURL=version.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,OAAO,CAAC"}
|
package/dist/walk.d.ts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/** Directories ignored by default (can be disabled with noDefaultIgnores). */
|
|
2
|
+
export declare const DEFAULT_IGNORES: readonly string[];
|
|
3
|
+
/** Default maximum file size to read: 2 MiB. */
|
|
4
|
+
export declare const DEFAULT_MAX_FILE_SIZE: number;
|
|
5
|
+
/** Options accepted by {@link walkFiles}. */
|
|
6
|
+
export interface WalkOptions {
|
|
7
|
+
/**
|
|
8
|
+
* Restrict to paths matching one of these include patterns (substring or
|
|
9
|
+
* relative-path-prefix match). When omitted/empty, all files pass.
|
|
10
|
+
*/
|
|
11
|
+
include?: string[];
|
|
12
|
+
/** Extra exclude patterns (substring or relative-path-prefix match). */
|
|
13
|
+
exclude?: string[];
|
|
14
|
+
/** Disable the built-in directory ignore list. */
|
|
15
|
+
noDefaultIgnores?: boolean;
|
|
16
|
+
/** Max file size in bytes; larger files are skipped. */
|
|
17
|
+
maxFileSize?: number;
|
|
18
|
+
}
|
|
19
|
+
/** Normalise a path to forward-slash POSIX separators. */
|
|
20
|
+
export declare function toPosix(p: string): string;
|
|
21
|
+
/** True if the file's extension marks it as binary / non-text. */
|
|
22
|
+
export declare function isBinaryPath(rel: string): boolean;
|
|
23
|
+
/** True if the path looks like generated / bundled output (by name). */
|
|
24
|
+
export declare function isGeneratedPath(rel: string): boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Heuristic content check for machine-minified / generated files with no
|
|
27
|
+
* telltale extension: a very long average line length, or any single line over
|
|
28
|
+
* ~50 KB, in the first ~64 KB sampled. Used at read time, not in the walker.
|
|
29
|
+
*/
|
|
30
|
+
export declare function looksMinified(content: string): boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Recursively yield scannable file paths (relative to `root`, POSIX) under a
|
|
33
|
+
* directory. If `root` points at a single file, yields just that file's
|
|
34
|
+
* basename (subject to the size / binary filters).
|
|
35
|
+
*/
|
|
36
|
+
export declare function walkFiles(root: string, options?: WalkOptions): AsyncGenerator<string>;
|
|
37
|
+
//# sourceMappingURL=walk.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"walk.d.ts","sourceRoot":"","sources":["../src/walk.ts"],"names":[],"mappings":"AAUA,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;AA6BD,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"}
|