@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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"changed.d.ts","sourceRoot":"","sources":["../src/changed.ts"],"names":[],"mappings":"AAiCA;;;;;;;;;;GAUG;AACH,wBAAsB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CA+BlF"}
|
package/dist/changed.js
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Incremental-scan helper: list the files that changed in a git working tree,
|
|
3
|
+
* for feeding into {@link ScanOptions.files}. Tolerant of non-git directories —
|
|
4
|
+
* returns an empty list rather than throwing.
|
|
5
|
+
*/
|
|
6
|
+
import { execFile } from "node:child_process";
|
|
7
|
+
import { promisify } from "node:util";
|
|
8
|
+
const execFileAsync = promisify(execFile);
|
|
9
|
+
/** Run a git command in `cwd`, returning stdout or `null` on any failure. */
|
|
10
|
+
async function git(cwd, args) {
|
|
11
|
+
try {
|
|
12
|
+
const { stdout } = await execFileAsync("git", args, {
|
|
13
|
+
cwd,
|
|
14
|
+
maxBuffer: 64 * 1024 * 1024,
|
|
15
|
+
windowsHide: true,
|
|
16
|
+
});
|
|
17
|
+
return stdout;
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
/** Split git output into trimmed, non-empty, POSIX-relative path lines. */
|
|
24
|
+
function toLines(stdout) {
|
|
25
|
+
if (!stdout)
|
|
26
|
+
return [];
|
|
27
|
+
return stdout
|
|
28
|
+
.split("\n")
|
|
29
|
+
.map((l) => l.trim())
|
|
30
|
+
.filter((l) => l.length > 0);
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Return the list of changed files (relative POSIX paths) under `root`.
|
|
34
|
+
*
|
|
35
|
+
* - With `since` (a ref / range), returns `git diff --name-only --diff-filter=ACMR <since>`
|
|
36
|
+
* plus currently-modified-but-uncommitted files, deduped.
|
|
37
|
+
* - Without `since`, returns uncommitted changes (`git diff` working+staged) plus
|
|
38
|
+
* untracked files (`git ls-files --others --exclude-standard`).
|
|
39
|
+
* - When `root` is not a git repository (or git is unavailable), returns `[]`.
|
|
40
|
+
*
|
|
41
|
+
* Deleted files are excluded (ACMR filter / existence is the caller's concern).
|
|
42
|
+
*/
|
|
43
|
+
export async function changedFiles(root, since) {
|
|
44
|
+
// Confirm this is a git work tree first; bail out tolerantly if not.
|
|
45
|
+
const inside = await git(root, ["rev-parse", "--is-inside-work-tree"]);
|
|
46
|
+
if (inside === null || inside.trim() !== "true")
|
|
47
|
+
return [];
|
|
48
|
+
const out = new Set();
|
|
49
|
+
if (since) {
|
|
50
|
+
for (const f of toLines(await git(root, ["diff", "--name-only", "--diff-filter=ACMR", since]))) {
|
|
51
|
+
out.add(f);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
// Always include local uncommitted edits (staged + unstaged), filtered to ACMR.
|
|
55
|
+
for (const f of toLines(await git(root, ["diff", "--name-only", "--diff-filter=ACMR"]))) {
|
|
56
|
+
out.add(f);
|
|
57
|
+
}
|
|
58
|
+
for (const f of toLines(await git(root, ["diff", "--name-only", "--diff-filter=ACMR", "--cached"]))) {
|
|
59
|
+
out.add(f);
|
|
60
|
+
}
|
|
61
|
+
// Untracked (but not ignored) files.
|
|
62
|
+
for (const f of toLines(await git(root, ["ls-files", "--others", "--exclude-standard"]))) {
|
|
63
|
+
out.add(f);
|
|
64
|
+
}
|
|
65
|
+
return [...out].sort((a, b) => (a < b ? -1 : a > b ? 1 : 0));
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=changed.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"changed.js","sourceRoot":"","sources":["../src/changed.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC,MAAM,aAAa,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC;AAE1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C,CAAC,CAAC;QACb,CAAC;IACH,CAAC;IAED,gFAAgF;IAChF,KAAK,MAAM,CAAC,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC,MAAM,EAAE,aAAa,EAAE,oBAAoB,CAAC,CAAC,CAAC,EAAE,CAAC;QACxF,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IACb,CAAC;IACD,KAAK,MAAM,CAAC,IAAI,OAAO,CACrB,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC,MAAM,EAAE,aAAa,EAAE,oBAAoB,EAAE,UAAU,CAAC,CAAC,CAC3E,EAAE,CAAC;QACF,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IACb,CAAC;IAED,qCAAqC;IACrC,KAAK,MAAM,CAAC,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC,UAAU,EAAE,UAAU,EAAE,oBAAoB,CAAC,CAAC,CAAC,EAAE,CAAC;QACzF,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IACb,CAAC;IAED,OAAO,CAAC,GAAG,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAC/D,CAAC"}
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { ScanOptions, Severity } from "./types.js";
|
|
2
|
+
/** Canonical config file name discovered at a scan root. */
|
|
3
|
+
export declare const CONFIG_FILENAME = "quantakrypto.config.json";
|
|
4
|
+
/**
|
|
5
|
+
* The slice of options a `quantakrypto.config.json` can set. A subset of
|
|
6
|
+
* {@link ScanOptions} (the file-selection + scope keys) extended with the two
|
|
7
|
+
* policy keys qScan owns: `severityThreshold` and `baseline`.
|
|
8
|
+
*
|
|
9
|
+
* `root`, `files`, `detectors` (the programmatic detector array), and `onFile`
|
|
10
|
+
* are intentionally NOT configurable from a file — they are call-site concerns.
|
|
11
|
+
*/
|
|
12
|
+
export interface QuantakryptoFileConfig extends Partial<Pick<ScanOptions, "include" | "exclude" | "noDefaultIgnores" | "maxFileSize" | "scanMinified" | "source" | "dependencies" | "config">> {
|
|
13
|
+
/** Gate severity (drives the exit code). Maps to qScan's `severityThreshold`. */
|
|
14
|
+
severityThreshold?: Severity;
|
|
15
|
+
/** Path to a baseline file, relative to the config file's directory. */
|
|
16
|
+
baseline?: string;
|
|
17
|
+
}
|
|
18
|
+
/** Result of {@link loadConfig}: the resolved config plus where it came from. */
|
|
19
|
+
export interface LoadConfigResult {
|
|
20
|
+
/** Validated, mapped config. Empty object when no file was found. */
|
|
21
|
+
config: QuantakryptoFileConfig;
|
|
22
|
+
/** Absolute path of the file that was loaded, when one was. */
|
|
23
|
+
path?: string;
|
|
24
|
+
/**
|
|
25
|
+
* Non-fatal warnings (unknown keys, unknown future `version`). The caller may
|
|
26
|
+
* surface these; they never abort the load.
|
|
27
|
+
*/
|
|
28
|
+
warnings: string[];
|
|
29
|
+
}
|
|
30
|
+
/** Thrown when a known key has a malformed *value* (a usage error: exit 2). */
|
|
31
|
+
export declare class ConfigError extends Error {
|
|
32
|
+
readonly name = "ConfigError";
|
|
33
|
+
/** The config file path the error relates to, when known. */
|
|
34
|
+
readonly path: string | undefined;
|
|
35
|
+
constructor(message: string, configPath?: string);
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Load a `quantakrypto.config.json` for a scan.
|
|
39
|
+
*
|
|
40
|
+
* By default reads `<root>/quantakrypto.config.json`. Pass an explicit file path as
|
|
41
|
+
* `root` (or via the caller's `--config` flag) to read a named file instead —
|
|
42
|
+
* if the path's basename is `quantakrypto.config.json` it is read directly; otherwise
|
|
43
|
+
* the path is treated as a directory and the file is looked up inside it. When
|
|
44
|
+
* an explicit path is given but missing, that is an error; an *absent*
|
|
45
|
+
* auto-discovered file is tolerated (returns an empty config).
|
|
46
|
+
*
|
|
47
|
+
* @param root Directory to look in, OR an explicit config file path.
|
|
48
|
+
* @param opts.explicit When true, a missing file is an error (the user named it).
|
|
49
|
+
* @throws {ConfigError} On malformed JSON, a bad value for a known key, or a
|
|
50
|
+
* missing explicitly-named file.
|
|
51
|
+
*/
|
|
52
|
+
export declare function loadConfig(root: string, opts?: {
|
|
53
|
+
explicit?: boolean;
|
|
54
|
+
}): Promise<LoadConfigResult>;
|
|
55
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAExD,4DAA4D;AAC5D,eAAO,MAAM,eAAe,6BAA6B,CAAC;AAgB1D;;;;;;;GAOG;AACH,MAAM,WAAW,sBAAuB,SAAQ,OAAO,CACrD,IAAI,CACF,WAAW,EACT,SAAS,GACT,SAAS,GACT,kBAAkB,GAClB,aAAa,GACb,cAAc,GACd,QAAQ,GACR,cAAc,GACd,QAAQ,CACX,CACF;IACC,iFAAiF;IACjF,iBAAiB,CAAC,EAAE,QAAQ,CAAC;IAC7B,wEAAwE;IACxE,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,iFAAiF;AACjF,MAAM,WAAW,gBAAgB;IAC/B,qEAAqE;IACrE,MAAM,EAAE,sBAAsB,CAAC;IAC/B,+DAA+D;IAC/D,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB;AAED,+EAA+E;AAC/E,qBAAa,WAAY,SAAQ,KAAK;IACpC,SAAkB,IAAI,iBAAiB;IACvC,6DAA6D;IAC7D,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;gBACtB,OAAO,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM;CAIjD;AA8JD;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,UAAU,CAC9B,IAAI,EAAE,MAAM,EACZ,IAAI,GAAE;IAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;CAAO,GAChC,OAAO,CAAC,gBAAgB,CAAC,CAgC3B"}
|
package/dist/config.js
ADDED
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `quantakrypto.config.json` loader (ROADMAP P2-9, see docs/CONFIG.md).
|
|
3
|
+
*
|
|
4
|
+
* Reads an optional project configuration file, validates the *types* of known
|
|
5
|
+
* keys, ignores unknown keys (forward compatibility), and maps it onto a
|
|
6
|
+
* `Partial<ScanOptions>` plus the two policy keys qScan consumes
|
|
7
|
+
* (`severityThreshold`, `baseline`). It performs NO scanning and has no
|
|
8
|
+
* side-effects beyond a single `readFile`.
|
|
9
|
+
*
|
|
10
|
+
* Precedence (resolved by the consumer, not here): flags > config > defaults.
|
|
11
|
+
*
|
|
12
|
+
* The parsed object is treated as **untrusted input** in the same spirit as a
|
|
13
|
+
* scanned manifest (THREAT-MODEL Q-09): we only membership-test known keys and
|
|
14
|
+
* never deep-merge the parsed object into anything.
|
|
15
|
+
*/
|
|
16
|
+
import { readFile } from "node:fs/promises";
|
|
17
|
+
import * as path from "node:path";
|
|
18
|
+
/** Canonical config file name discovered at a scan root. */
|
|
19
|
+
export const CONFIG_FILENAME = "quantakrypto.config.json";
|
|
20
|
+
/** Severity levels accepted by `severityThreshold`, for validation. */
|
|
21
|
+
const SEVERITIES = ["critical", "high", "medium", "low", "info"];
|
|
22
|
+
/** Detector-family toggle names recognised in the `detectors` object. */
|
|
23
|
+
const DETECTOR_FAMILIES = [
|
|
24
|
+
"node-crypto",
|
|
25
|
+
"webcrypto",
|
|
26
|
+
"crypto-libs",
|
|
27
|
+
"jwt-jose",
|
|
28
|
+
"tls-config",
|
|
29
|
+
"pem-material",
|
|
30
|
+
"dependencies",
|
|
31
|
+
];
|
|
32
|
+
/** Thrown when a known key has a malformed *value* (a usage error: exit 2). */
|
|
33
|
+
export class ConfigError extends Error {
|
|
34
|
+
name = "ConfigError";
|
|
35
|
+
/** The config file path the error relates to, when known. */
|
|
36
|
+
path;
|
|
37
|
+
constructor(message, configPath) {
|
|
38
|
+
super(message);
|
|
39
|
+
this.path = configPath;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
function isObject(v) {
|
|
43
|
+
return typeof v === "object" && v !== null && !Array.isArray(v);
|
|
44
|
+
}
|
|
45
|
+
/** Validate an optional boolean field; returns it or undefined, or throws. */
|
|
46
|
+
function asBool(obj, key, file) {
|
|
47
|
+
if (!(key in obj))
|
|
48
|
+
return undefined;
|
|
49
|
+
const v = obj[key];
|
|
50
|
+
if (typeof v !== "boolean") {
|
|
51
|
+
throw new ConfigError(`"${key}" must be a boolean (got ${typeof v})`, file);
|
|
52
|
+
}
|
|
53
|
+
return v;
|
|
54
|
+
}
|
|
55
|
+
/** Validate an optional non-negative-integer field. */
|
|
56
|
+
function asInt(obj, key, file) {
|
|
57
|
+
if (!(key in obj))
|
|
58
|
+
return undefined;
|
|
59
|
+
const v = obj[key];
|
|
60
|
+
if (typeof v !== "number" || !Number.isInteger(v) || v < 0) {
|
|
61
|
+
throw new ConfigError(`"${key}" must be a non-negative integer`, file);
|
|
62
|
+
}
|
|
63
|
+
return v;
|
|
64
|
+
}
|
|
65
|
+
/** Validate an optional string[] field (every element must be a string). */
|
|
66
|
+
function asStringArray(obj, key, file) {
|
|
67
|
+
if (!(key in obj))
|
|
68
|
+
return undefined;
|
|
69
|
+
const v = obj[key];
|
|
70
|
+
if (!Array.isArray(v) || !v.every((x) => typeof x === "string")) {
|
|
71
|
+
throw new ConfigError(`"${key}" must be an array of strings`, file);
|
|
72
|
+
}
|
|
73
|
+
return [...v];
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Map the validated raw JSON object onto a {@link QuantakryptoFileConfig}. Throws
|
|
77
|
+
* {@link ConfigError} on a malformed *value* for any known key; collects
|
|
78
|
+
* warnings for unknown keys and unrecognised `version`.
|
|
79
|
+
*/
|
|
80
|
+
function mapConfig(raw, file, warnings) {
|
|
81
|
+
// Known top-level keys. Anything else is a warning, not an error.
|
|
82
|
+
const KNOWN = new Set([
|
|
83
|
+
"$schema",
|
|
84
|
+
"version",
|
|
85
|
+
"include",
|
|
86
|
+
"exclude",
|
|
87
|
+
"noDefaultIgnores",
|
|
88
|
+
"maxFileSize",
|
|
89
|
+
"scanMinified",
|
|
90
|
+
"detectors",
|
|
91
|
+
"languages",
|
|
92
|
+
"severityThreshold",
|
|
93
|
+
"baseline",
|
|
94
|
+
]);
|
|
95
|
+
for (const key of Object.keys(raw)) {
|
|
96
|
+
if (!KNOWN.has(key))
|
|
97
|
+
warnings.push(`unknown config key "${key}" ignored`);
|
|
98
|
+
}
|
|
99
|
+
// version: known forward-compat warning only.
|
|
100
|
+
if ("version" in raw) {
|
|
101
|
+
const version = raw["version"];
|
|
102
|
+
if (typeof version !== "number" || !Number.isInteger(version)) {
|
|
103
|
+
throw new ConfigError(`"version" must be an integer`, file);
|
|
104
|
+
}
|
|
105
|
+
if (version !== 1) {
|
|
106
|
+
warnings.push(`config "version" ${version} is newer than supported (1); best-effort`);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
const out = {};
|
|
110
|
+
const include = asStringArray(raw, "include", file);
|
|
111
|
+
if (include)
|
|
112
|
+
out.include = include;
|
|
113
|
+
const exclude = asStringArray(raw, "exclude", file);
|
|
114
|
+
if (exclude)
|
|
115
|
+
out.exclude = exclude;
|
|
116
|
+
const noDefaultIgnores = asBool(raw, "noDefaultIgnores", file);
|
|
117
|
+
if (noDefaultIgnores !== undefined)
|
|
118
|
+
out.noDefaultIgnores = noDefaultIgnores;
|
|
119
|
+
const scanMinified = asBool(raw, "scanMinified", file);
|
|
120
|
+
if (scanMinified !== undefined)
|
|
121
|
+
out.scanMinified = scanMinified;
|
|
122
|
+
const maxFileSize = asInt(raw, "maxFileSize", file);
|
|
123
|
+
if (maxFileSize !== undefined)
|
|
124
|
+
out.maxFileSize = maxFileSize;
|
|
125
|
+
// detectors.<family> bool map → source / dependencies / config scope toggles.
|
|
126
|
+
// A family turned off is equivalent to its `--no-*` flag (per docs/CONFIG.md
|
|
127
|
+
// §4.1). We collapse the per-family map onto the three scan-scope toggles:
|
|
128
|
+
// dependencies → ScanOptions.dependencies
|
|
129
|
+
// pem-material + tls-config → ScanOptions.config (config-scope detectors)
|
|
130
|
+
// the JS source families → ScanOptions.source (source-scope detectors)
|
|
131
|
+
// Only an explicit `false` flips a toggle off; absent/true leaves the default.
|
|
132
|
+
if ("detectors" in raw) {
|
|
133
|
+
const det = raw["detectors"];
|
|
134
|
+
if (!isObject(det)) {
|
|
135
|
+
throw new ConfigError(`"detectors" must be an object of family→boolean`, file);
|
|
136
|
+
}
|
|
137
|
+
for (const key of Object.keys(det)) {
|
|
138
|
+
if (!DETECTOR_FAMILIES.includes(key)) {
|
|
139
|
+
warnings.push(`unknown detector family "${key}" ignored`);
|
|
140
|
+
continue;
|
|
141
|
+
}
|
|
142
|
+
const v = det[key];
|
|
143
|
+
if (typeof v !== "boolean") {
|
|
144
|
+
throw new ConfigError(`"detectors.${key}" must be a boolean`, file);
|
|
145
|
+
}
|
|
146
|
+
if (v)
|
|
147
|
+
continue; // true = default; nothing to disable.
|
|
148
|
+
switch (key) {
|
|
149
|
+
case "dependencies":
|
|
150
|
+
out.dependencies = false;
|
|
151
|
+
break;
|
|
152
|
+
case "tls-config":
|
|
153
|
+
case "pem-material":
|
|
154
|
+
out.config = false;
|
|
155
|
+
break;
|
|
156
|
+
default:
|
|
157
|
+
// node-crypto / webcrypto / crypto-libs / jwt-jose are source-scope.
|
|
158
|
+
out.source = false;
|
|
159
|
+
break;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
// languages: forward-looking (inert until the plugin registry lands). Validate
|
|
164
|
+
// the type so the file format is stable, but do not map it anywhere.
|
|
165
|
+
const languages = asStringArray(raw, "languages", file);
|
|
166
|
+
if (languages)
|
|
167
|
+
warnings.push(`"languages" is accepted but inert until detector plugins land`);
|
|
168
|
+
// severityThreshold: enum.
|
|
169
|
+
if ("severityThreshold" in raw) {
|
|
170
|
+
const sev = raw["severityThreshold"];
|
|
171
|
+
if (typeof sev !== "string" || !SEVERITIES.includes(sev)) {
|
|
172
|
+
throw new ConfigError(`"severityThreshold" must be one of: ${SEVERITIES.join(", ")}`, file);
|
|
173
|
+
}
|
|
174
|
+
out.severityThreshold = sev;
|
|
175
|
+
}
|
|
176
|
+
// baseline: path string, resolved relative to the config file's directory.
|
|
177
|
+
if ("baseline" in raw) {
|
|
178
|
+
const baseline = raw["baseline"];
|
|
179
|
+
if (typeof baseline !== "string" || baseline.length === 0) {
|
|
180
|
+
throw new ConfigError(`"baseline" must be a non-empty path string`, file);
|
|
181
|
+
}
|
|
182
|
+
out.baseline = path.isAbsolute(baseline) ? baseline : path.join(path.dirname(file), baseline);
|
|
183
|
+
}
|
|
184
|
+
return out;
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Load a `quantakrypto.config.json` for a scan.
|
|
188
|
+
*
|
|
189
|
+
* By default reads `<root>/quantakrypto.config.json`. Pass an explicit file path as
|
|
190
|
+
* `root` (or via the caller's `--config` flag) to read a named file instead —
|
|
191
|
+
* if the path's basename is `quantakrypto.config.json` it is read directly; otherwise
|
|
192
|
+
* the path is treated as a directory and the file is looked up inside it. When
|
|
193
|
+
* an explicit path is given but missing, that is an error; an *absent*
|
|
194
|
+
* auto-discovered file is tolerated (returns an empty config).
|
|
195
|
+
*
|
|
196
|
+
* @param root Directory to look in, OR an explicit config file path.
|
|
197
|
+
* @param opts.explicit When true, a missing file is an error (the user named it).
|
|
198
|
+
* @throws {ConfigError} On malformed JSON, a bad value for a known key, or a
|
|
199
|
+
* missing explicitly-named file.
|
|
200
|
+
*/
|
|
201
|
+
export async function loadConfig(root, opts = {}) {
|
|
202
|
+
// Resolve the file path: an explicit *.json file is used verbatim; otherwise
|
|
203
|
+
// treat `root` as a directory and append the canonical name.
|
|
204
|
+
const base = path.basename(root);
|
|
205
|
+
const file = base === CONFIG_FILENAME || base.endsWith(".json")
|
|
206
|
+
? path.resolve(root)
|
|
207
|
+
: path.resolve(root, CONFIG_FILENAME);
|
|
208
|
+
let text;
|
|
209
|
+
try {
|
|
210
|
+
text = await readFile(file, "utf8");
|
|
211
|
+
}
|
|
212
|
+
catch {
|
|
213
|
+
if (opts.explicit) {
|
|
214
|
+
throw new ConfigError(`config file not found: ${file}`, file);
|
|
215
|
+
}
|
|
216
|
+
return { config: {}, warnings: [] }; // tolerant when auto-discovering.
|
|
217
|
+
}
|
|
218
|
+
let parsed;
|
|
219
|
+
try {
|
|
220
|
+
parsed = JSON.parse(text);
|
|
221
|
+
}
|
|
222
|
+
catch (err) {
|
|
223
|
+
throw new ConfigError(`invalid JSON in ${file}: ${err.message}`, file);
|
|
224
|
+
}
|
|
225
|
+
if (!isObject(parsed)) {
|
|
226
|
+
throw new ConfigError(`config must be a JSON object, got ${typeof parsed}`, file);
|
|
227
|
+
}
|
|
228
|
+
const warnings = [];
|
|
229
|
+
const config = mapConfig(parsed, file, warnings);
|
|
230
|
+
return { config, path: file, warnings };
|
|
231
|
+
}
|
|
232
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAIlC,4DAA4D;AAC5D,MAAM,CAAC,MAAM,eAAe,GAAG,0BAA0B,CAAC;AAE1D,uEAAuE;AACvE,MAAM,UAAU,GAAwB,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pB,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,eAAe,CAAC,CAAC;IAE1C,IAAI,IAAY,CAAC;IACjB,IAAI,CAAC;QACH,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IACtC,CAAC;IAAC,MAAM,CAAC;QACP,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YAClB,MAAM,IAAI,WAAW,CAAC,0BAA0B,IAAI,EAAE,EAAE,IAAI,CAAC,CAAC;QAChE,CAAC;QACD,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,CAAC,kCAAkC;IACzE,CAAC;IAED,IAAI,MAAe,CAAC;IACpB,IAAI,CAAC;QACH,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC5B,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,IAAI,WAAW,CAAC,mBAAmB,IAAI,KAAM,GAAa,CAAC,OAAO,EAAE,EAAE,IAAI,CAAC,CAAC;IACpF,CAAC;IACD,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;QACtB,MAAM,IAAI,WAAW,CAAC,qCAAqC,OAAO,MAAM,EAAE,EAAE,IAAI,CAAC,CAAC;IACpF,CAAC;IAED,MAAM,QAAQ,GAAa,EAAE,CAAC;IAC9B,MAAM,MAAM,GAAG,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAC;IACjD,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;AAC1C,CAAC"}
|
package/dist/cwe.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CWE (Common Weakness Enumeration) identifiers used to tag findings. These
|
|
3
|
+
* feed SARIF rule taxa / properties and the CBOM export, and let downstream
|
|
4
|
+
* compliance tooling map quantaKrypto findings to a standard weakness taxonomy.
|
|
5
|
+
*/
|
|
6
|
+
/** CWE-327: Use of a Broken or Risky Cryptographic Algorithm. */
|
|
7
|
+
export declare const CWE_BROKEN_CRYPTO = "CWE-327";
|
|
8
|
+
/** CWE-326: Inadequate Encryption Strength. */
|
|
9
|
+
export declare const CWE_WEAK_STRENGTH = "CWE-326";
|
|
10
|
+
/** CWE-295: Improper Certificate Validation. */
|
|
11
|
+
export declare const CWE_CERT_VALIDATION = "CWE-295";
|
|
12
|
+
/** CWE-798: Use of Hard-coded Credentials (embedded private keys). */
|
|
13
|
+
export declare const CWE_HARDCODED_KEY = "CWE-798";
|
|
14
|
+
/** CWE-1240: Use of a Cryptographic Primitive with a Risky Implementation. */
|
|
15
|
+
export declare const CWE_RISKY_PRIMITIVE = "CWE-1240";
|
|
16
|
+
//# sourceMappingURL=cwe.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cwe.d.ts","sourceRoot":"","sources":["../src/cwe.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,iEAAiE;AACjE,eAAO,MAAM,iBAAiB,YAAY,CAAC;AAE3C,+CAA+C;AAC/C,eAAO,MAAM,iBAAiB,YAAY,CAAC;AAE3C,gDAAgD;AAChD,eAAO,MAAM,mBAAmB,YAAY,CAAC;AAE7C,sEAAsE;AACtE,eAAO,MAAM,iBAAiB,YAAY,CAAC;AAE3C,8EAA8E;AAC9E,eAAO,MAAM,mBAAmB,aAAa,CAAC"}
|
package/dist/cwe.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CWE (Common Weakness Enumeration) identifiers used to tag findings. These
|
|
3
|
+
* feed SARIF rule taxa / properties and the CBOM export, and let downstream
|
|
4
|
+
* compliance tooling map quantaKrypto findings to a standard weakness taxonomy.
|
|
5
|
+
*/
|
|
6
|
+
/** CWE-327: Use of a Broken or Risky Cryptographic Algorithm. */
|
|
7
|
+
export const CWE_BROKEN_CRYPTO = "CWE-327";
|
|
8
|
+
/** CWE-326: Inadequate Encryption Strength. */
|
|
9
|
+
export const CWE_WEAK_STRENGTH = "CWE-326";
|
|
10
|
+
/** CWE-295: Improper Certificate Validation. */
|
|
11
|
+
export const CWE_CERT_VALIDATION = "CWE-295";
|
|
12
|
+
/** CWE-798: Use of Hard-coded Credentials (embedded private keys). */
|
|
13
|
+
export const CWE_HARDCODED_KEY = "CWE-798";
|
|
14
|
+
/** CWE-1240: Use of a Cryptographic Primitive with a Risky Implementation. */
|
|
15
|
+
export const CWE_RISKY_PRIMITIVE = "CWE-1240";
|
|
16
|
+
//# sourceMappingURL=cwe.js.map
|
package/dist/cwe.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cwe.js","sourceRoot":"","sources":["../src/cwe.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,iEAAiE;AACjE,MAAM,CAAC,MAAM,iBAAiB,GAAG,SAAS,CAAC;AAE3C,+CAA+C;AAC/C,MAAM,CAAC,MAAM,iBAAiB,GAAG,SAAS,CAAC;AAE3C,gDAAgD;AAChD,MAAM,CAAC,MAAM,mBAAmB,GAAG,SAAS,CAAC;AAE7C,sEAAsE;AACtE,MAAM,CAAC,MAAM,iBAAiB,GAAG,SAAS,CAAC;AAE3C,8EAA8E;AAC9E,MAAM,CAAC,MAAM,mBAAmB,GAAG,UAAU,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Curated database of npm packages that primarily expose classical asymmetric
|
|
3
|
+
* cryptography (and are therefore quantum-vulnerable), plus a manifest scanner
|
|
4
|
+
* that flags any of them found in package.json / package-lock.json.
|
|
5
|
+
*
|
|
6
|
+
* The list is intentionally focused on libraries whose *purpose* is classical
|
|
7
|
+
* public-key crypto. General-purpose packages that merely call out to Node's
|
|
8
|
+
* crypto are out of scope here (those are caught by the source detectors).
|
|
9
|
+
*/
|
|
10
|
+
import type { Finding, VulnerableDependency } from "./types.js";
|
|
11
|
+
/** Known quantum-vulnerable npm dependencies. */
|
|
12
|
+
export declare const vulnerableDependencies: VulnerableDependency[];
|
|
13
|
+
/** True if a file path looks like a manifest we can parse for dependencies. */
|
|
14
|
+
export declare function isManifestFile(file: string): boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Scan a single manifest file's contents for vulnerable dependencies.
|
|
17
|
+
*
|
|
18
|
+
* - `package.json`: dependencies / devDependencies / peerDependencies / optionalDependencies.
|
|
19
|
+
* - `package-lock.json` (v2/v3): the `packages` map keys (node_modules/<name>),
|
|
20
|
+
* plus legacy `dependencies` map for v1.
|
|
21
|
+
*
|
|
22
|
+
* Returns one finding per distinct vulnerable package name found in the file.
|
|
23
|
+
*/
|
|
24
|
+
export declare function scanManifest(file: string, content: string): Finding[];
|
|
25
|
+
//# sourceMappingURL=dependencies.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dependencies.d.ts","sourceRoot":"","sources":["../src/dependencies.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,EAAmB,OAAO,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAKjF,iDAAiD;AACjD,eAAO,MAAM,sBAAsB,EAAE,oBAAoB,EA6IxD,CAAC;AAwCF,+EAA+E;AAC/E,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAGpD;AA2CD;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,EAAE,CA8CrE"}
|