@cdxgen/cdxgen 13.0.0 → 13.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 +26 -13
- package/bin/audit.js +6 -0
- package/bin/cdxgen.js +140 -8
- package/bin/convert.js +7 -0
- package/bin/evinse.js +1 -1
- package/bin/hbom.js +13 -4
- package/bin/tracebom.js +9 -1
- package/data/component-tags.json +8 -1
- package/data/frameworks-list.json +86 -1
- package/data/remediations.json +1144 -0
- package/data/rules/asar-archives.yaml +1 -1
- package/data/rules/build-fidelity.yaml +782 -0
- package/data/rules/package-integrity.yaml +13 -13
- package/lib/audit/index.js +48 -4
- package/lib/audit/scoring.js +2 -8
- package/lib/cli/bomAssembly.js +83 -15
- package/lib/cli/cliOptions.js +124 -7
- package/lib/cli/index.js +76 -48
- package/lib/cli/jsBom.js +32 -3
- package/lib/cli/jvmBom.js +1494 -1315
- package/lib/cli/managedBom.js +97 -28
- package/lib/cli/nativeBom.js +189 -10
- package/lib/core/buildLedger.js +799 -0
- package/lib/core/deferredExit.js +141 -0
- package/lib/core/env.js +69 -1
- package/lib/core/fs.js +60 -0
- package/lib/core/logger.js +76 -25
- package/lib/core/severity.js +16 -0
- package/lib/core/syncFileWriter.js +106 -0
- package/lib/core/ui.js +46 -2
- package/lib/ecosystems/ecosystems.js +9 -0
- package/lib/ecosystems/gradleutils.js +355 -15
- package/lib/ecosystems/parsers-js.js +26 -0
- package/lib/ecosystems/parsers-jvm.js +9 -0
- package/lib/ecosystems/parsers-misc.js +16 -2
- package/lib/ecosystems/parsers-python.js +171 -35
- package/lib/ecosystems/parsers-rust.js +12 -2
- package/lib/ecosystems/pypiClassifiers.js +326 -0
- package/lib/ecosystems/pythonutils.js +49 -1
- package/lib/ecosystems/rubyutils.js +13 -0
- package/lib/ecosystems/utils.js +9 -1
- package/lib/evinser/evinser.js +30 -12
- package/lib/helpers/remote/dependency-track.js +81 -14
- package/lib/inventory/auditCategories.js +9 -0
- package/lib/inventory/depsUtils.js +72 -0
- package/lib/inventory/dosai.js +431 -22
- package/lib/inventory/envcontext.js +211 -19
- package/lib/inventory/fetchBatch.js +57 -0
- package/lib/inventory/jvmToolEnv.js +593 -0
- package/lib/inventory/osinfo.js +123 -16
- package/lib/inventory/table.js +9 -5
- package/lib/inventory/toolRequirements.js +903 -0
- package/lib/managers/binary.js +216 -40
- package/lib/managers/docker.js +26 -5
- package/lib/server/server.js +1 -1
- package/lib/stages/postgen/annotationBuilder.js +97 -0
- package/lib/stages/postgen/auditBom.js +76 -79
- package/lib/stages/postgen/introspection/annotate.js +320 -0
- package/lib/stages/postgen/introspection/commandFacts.js +293 -0
- package/lib/stages/postgen/introspection/emit.js +192 -0
- package/lib/stages/postgen/introspection/formulationEvidence.js +427 -0
- package/lib/stages/postgen/introspection/markers.js +227 -0
- package/lib/stages/postgen/introspection/reflect.js +1214 -0
- package/lib/stages/postgen/introspection/report.js +1208 -0
- package/lib/stages/postgen/introspection/score.js +1067 -0
- package/lib/stages/postgen/introspection/shapeCommand.js +304 -0
- package/lib/stages/postgen/parentEdge.js +156 -0
- package/lib/stages/postgen/postgen.js +115 -2
- package/lib/stages/postgen/ruleEngine.js +17 -0
- package/lib/stages/pregen/envAudit.js +42 -2
- package/lib/stages/pregen/pregen.js +1171 -6
- package/lib/validator/bomValidator.js +11 -2
- package/package.json +14 -14
- package/types/lib/audit/index.d.ts.map +1 -1
- package/types/lib/audit/scoring.d.ts +2 -8
- package/types/lib/audit/scoring.d.ts.map +1 -1
- package/types/lib/cli/bomAssembly.d.ts +14 -0
- package/types/lib/cli/bomAssembly.d.ts.map +1 -1
- package/types/lib/cli/cliOptions.d.ts +2 -1
- package/types/lib/cli/cliOptions.d.ts.map +1 -1
- package/types/lib/cli/index.d.ts +8 -0
- package/types/lib/cli/index.d.ts.map +1 -1
- package/types/lib/cli/jsBom.d.ts.map +1 -1
- package/types/lib/cli/jvmBom.d.ts.map +1 -1
- package/types/lib/cli/managedBom.d.ts.map +1 -1
- package/types/lib/cli/nativeBom.d.ts.map +1 -1
- package/types/lib/core/buildLedger.d.ts +272 -0
- package/types/lib/core/buildLedger.d.ts.map +1 -0
- package/types/lib/core/deferredExit.d.ts +84 -0
- package/types/lib/core/deferredExit.d.ts.map +1 -0
- package/types/lib/core/env.d.ts +22 -1
- package/types/lib/core/env.d.ts.map +1 -1
- package/types/lib/core/fs.d.ts +21 -0
- package/types/lib/core/fs.d.ts.map +1 -1
- package/types/lib/core/logger.d.ts +14 -1
- package/types/lib/core/logger.d.ts.map +1 -1
- package/types/lib/core/severity.d.ts +11 -0
- package/types/lib/core/severity.d.ts.map +1 -0
- package/types/lib/core/syncFileWriter.d.ts +33 -0
- package/types/lib/core/syncFileWriter.d.ts.map +1 -0
- package/types/lib/core/ui.d.ts +1 -1
- package/types/lib/core/ui.d.ts.map +1 -1
- package/types/lib/ecosystems/ecosystems.d.ts.map +1 -1
- package/types/lib/ecosystems/gradleutils.d.ts +33 -0
- package/types/lib/ecosystems/gradleutils.d.ts.map +1 -1
- package/types/lib/ecosystems/parsers-js.d.ts.map +1 -1
- package/types/lib/ecosystems/parsers-jvm.d.ts.map +1 -1
- package/types/lib/ecosystems/parsers-misc.d.ts.map +1 -1
- package/types/lib/ecosystems/parsers-python.d.ts.map +1 -1
- package/types/lib/ecosystems/parsers-rust.d.ts.map +1 -1
- package/types/lib/ecosystems/pypiClassifiers.d.ts +80 -0
- package/types/lib/ecosystems/pypiClassifiers.d.ts.map +1 -0
- package/types/lib/ecosystems/pythonutils.d.ts +20 -0
- package/types/lib/ecosystems/pythonutils.d.ts.map +1 -1
- package/types/lib/ecosystems/rubyutils.d.ts.map +1 -1
- package/types/lib/ecosystems/utils.d.ts +4 -4
- package/types/lib/ecosystems/utils.d.ts.map +1 -1
- package/types/lib/evinser/evinser.d.ts +5 -1
- package/types/lib/evinser/evinser.d.ts.map +1 -1
- package/types/lib/helpers/remote/dependency-track.d.ts +45 -4
- package/types/lib/helpers/remote/dependency-track.d.ts.map +1 -1
- package/types/lib/inventory/auditCategories.d.ts +8 -0
- package/types/lib/inventory/auditCategories.d.ts.map +1 -1
- package/types/lib/inventory/depsUtils.d.ts.map +1 -1
- package/types/lib/inventory/dosai.d.ts +20 -0
- package/types/lib/inventory/dosai.d.ts.map +1 -1
- package/types/lib/inventory/envcontext.d.ts.map +1 -1
- package/types/lib/inventory/fetchBatch.d.ts +9 -0
- package/types/lib/inventory/fetchBatch.d.ts.map +1 -1
- package/types/lib/inventory/jvmToolEnv.d.ts +189 -0
- package/types/lib/inventory/jvmToolEnv.d.ts.map +1 -0
- package/types/lib/inventory/osinfo.d.ts +83 -2
- package/types/lib/inventory/osinfo.d.ts.map +1 -1
- package/types/lib/inventory/table.d.ts +4 -1
- package/types/lib/inventory/table.d.ts.map +1 -1
- package/types/lib/inventory/toolRequirements.d.ts +216 -0
- package/types/lib/inventory/toolRequirements.d.ts.map +1 -0
- package/types/lib/managers/binary.d.ts +71 -0
- package/types/lib/managers/binary.d.ts.map +1 -1
- package/types/lib/managers/docker.d.ts.map +1 -1
- package/types/lib/stages/postgen/annotationBuilder.d.ts +53 -0
- package/types/lib/stages/postgen/annotationBuilder.d.ts.map +1 -0
- package/types/lib/stages/postgen/auditBom.d.ts.map +1 -1
- package/types/lib/stages/postgen/introspection/annotate.d.ts +81 -0
- package/types/lib/stages/postgen/introspection/annotate.d.ts.map +1 -0
- package/types/lib/stages/postgen/introspection/commandFacts.d.ts +32 -0
- package/types/lib/stages/postgen/introspection/commandFacts.d.ts.map +1 -0
- package/types/lib/stages/postgen/introspection/emit.d.ts +71 -0
- package/types/lib/stages/postgen/introspection/emit.d.ts.map +1 -0
- package/types/lib/stages/postgen/introspection/formulationEvidence.d.ts +154 -0
- package/types/lib/stages/postgen/introspection/formulationEvidence.d.ts.map +1 -0
- package/types/lib/stages/postgen/introspection/markers.d.ts +57 -0
- package/types/lib/stages/postgen/introspection/markers.d.ts.map +1 -0
- package/types/lib/stages/postgen/introspection/reflect.d.ts +77 -0
- package/types/lib/stages/postgen/introspection/reflect.d.ts.map +1 -0
- package/types/lib/stages/postgen/introspection/report.d.ts +85 -0
- package/types/lib/stages/postgen/introspection/report.d.ts.map +1 -0
- package/types/lib/stages/postgen/introspection/score.d.ts +149 -0
- package/types/lib/stages/postgen/introspection/score.d.ts.map +1 -0
- package/types/lib/stages/postgen/introspection/shapeCommand.d.ts +79 -0
- package/types/lib/stages/postgen/introspection/shapeCommand.d.ts.map +1 -0
- package/types/lib/stages/postgen/parentEdge.d.ts +35 -0
- package/types/lib/stages/postgen/parentEdge.d.ts.map +1 -0
- package/types/lib/stages/postgen/postgen.d.ts +2 -2
- package/types/lib/stages/postgen/postgen.d.ts.map +1 -1
- package/types/lib/stages/postgen/ruleEngine.d.ts.map +1 -1
- package/types/lib/stages/pregen/envAudit.d.ts.map +1 -1
- package/types/lib/stages/pregen/pregen.d.ts +131 -0
- package/types/lib/stages/pregen/pregen.d.ts.map +1 -1
- package/types/lib/validator/bomValidator.d.ts.map +1 -1
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reader over the BOM's formulation section, the third evidence source.
|
|
3
|
+
*
|
|
4
|
+
* Formulation is two things at once, and the distinction governs every
|
|
5
|
+
* confidence decision downstream. The run-derived half — `type: "platform"`
|
|
6
|
+
* components recording the toolchain the generating run probed, and the git
|
|
7
|
+
* provenance components — is what cdxgen itself did. The config-parsed half —
|
|
8
|
+
* the commands, environment variables and task types under
|
|
9
|
+
* `formulation[].workflows[]` — is what the repo's CI declares, and a
|
|
10
|
+
* declared command was never observed to run.
|
|
11
|
+
*
|
|
12
|
+
* This module is pure: the BOM and the caller's run facts are the only
|
|
13
|
+
* inputs, nothing is read from the filesystem, and environment variable
|
|
14
|
+
* *values* are never touched — names only, because the BOM stores them and
|
|
15
|
+
* copying them into a report would republish them.
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* Property carrying the id of the run that stamped a BOM's formulation, set
|
|
19
|
+
* on every formulation workflow by the introspection pass that reflected
|
|
20
|
+
* over the freshly generated document.
|
|
21
|
+
*
|
|
22
|
+
* @type {string}
|
|
23
|
+
*/
|
|
24
|
+
export declare const FORMULATION_RUN_ID_PROPERTY: string;
|
|
25
|
+
/** The formulation record was produced by the run being reflected. */
|
|
26
|
+
export declare const FORMULATION_ORIGIN_SAME_RUN = "same-run";
|
|
27
|
+
/** The formulation record came with a BOM this run did not generate. */
|
|
28
|
+
export declare const FORMULATION_ORIGIN_FOREIGN = "foreign";
|
|
29
|
+
/**
|
|
30
|
+
* The BOM carries no formulation record at all, which is neither of the
|
|
31
|
+
* above: there is no evidence to weigh, so every consumer must behave as it
|
|
32
|
+
* did before formulation became a source.
|
|
33
|
+
*/
|
|
34
|
+
export declare const FORMULATION_ORIGIN_ABSENT = "absent";
|
|
35
|
+
/**
|
|
36
|
+
* Platform component names, as the environment probes emit them, mapped to
|
|
37
|
+
* the canonical ecosystem whose row their facts can corroborate. Names not
|
|
38
|
+
* listed here have no fidelity row to join.
|
|
39
|
+
*
|
|
40
|
+
* @type {Readonly<Record<string, string>>}
|
|
41
|
+
*/
|
|
42
|
+
export declare const TOOL_NAME_ECOSYSTEMS: Readonly<Record<string, string>>;
|
|
43
|
+
/**
|
|
44
|
+
* Resolver executables whose presence in a declared command says a build or
|
|
45
|
+
* dependency resolution was attempted, mapped to the ecosystem they drive.
|
|
46
|
+
* Keys are executable basenames, lower-cased.
|
|
47
|
+
*
|
|
48
|
+
* @type {Readonly<Record<string, string>>}
|
|
49
|
+
*/
|
|
50
|
+
export declare const RESOLVER_EXECUTABLES: Readonly<Record<string, string>>;
|
|
51
|
+
/**
|
|
52
|
+
* Whether an `executed` value is a CI action reference such as
|
|
53
|
+
* `actions/checkout@<sha>` rather than a shell command. An action reference
|
|
54
|
+
* carries no whitespace, contains a path separator, and names a revision of
|
|
55
|
+
* the repository after the last separator; a relative-path executable such
|
|
56
|
+
* as `./mvnw` carries no revision and stays a command.
|
|
57
|
+
*
|
|
58
|
+
* @param {string|undefined} executed The executed value of a step command.
|
|
59
|
+
* @returns {boolean} True when the value names an action, not a command.
|
|
60
|
+
*/
|
|
61
|
+
export declare function isActionReference(executed: string | undefined): boolean;
|
|
62
|
+
/**
|
|
63
|
+
* The executable a command line starts with, as a bare name.
|
|
64
|
+
*
|
|
65
|
+
* @param {string|undefined} commandLine Command line.
|
|
66
|
+
* @returns {string} Basename of the first whitespace token, or "" when absent.
|
|
67
|
+
*/
|
|
68
|
+
export declare function executableOf(commandLine: string | undefined): string;
|
|
69
|
+
/**
|
|
70
|
+
* Read the provenance-aware formulation evidence out of a BOM.
|
|
71
|
+
*
|
|
72
|
+
* `origin` decides how the evidence may be used. `same-run` means the
|
|
73
|
+
* formulation describes this very run — its platform components are the same
|
|
74
|
+
* probes the ledger recorded as `tool.resolved`, so the evidence corroborates
|
|
75
|
+
* and must never add confidence. `foreign` means the BOM arrived without a
|
|
76
|
+
* ledger for its generation, and the formulation is the only surviving trace
|
|
77
|
+
* of what that build attempted. `absent` is neither: the BOM carries no
|
|
78
|
+
* formulation record, so there is nothing to weigh and every consumer keeps
|
|
79
|
+
* the behaviour it had before formulation became a source.
|
|
80
|
+
*
|
|
81
|
+
* Environment variable names are collected; values are never read.
|
|
82
|
+
*
|
|
83
|
+
* @param {Object} bomJson CycloneDX BOM.
|
|
84
|
+
* @param {Object} [context] Run facts the caller already knows.
|
|
85
|
+
* @param {string} [context.runId] This reflection's run id, matched against the formulation's marker.
|
|
86
|
+
* @param {number} [context.ledgerEventCount] Events the ledger holds for this BOM's generation.
|
|
87
|
+
* @returns {{
|
|
88
|
+
* origin: "same-run"|"foreign"|"absent",
|
|
89
|
+
* tools: {name: string|undefined, version: string|undefined, source: "probe"}[],
|
|
90
|
+
* declaredCommands: {executable: string, commandLine: string, workflow: string|undefined, task: string|undefined, step: string|undefined, source: "ci-config"}[],
|
|
91
|
+
* sourceTree: {commit: string|undefined, treeId: string|undefined, fileCount: number}|undefined,
|
|
92
|
+
* environmentKeys: string[]
|
|
93
|
+
* }} The formulation evidence.
|
|
94
|
+
*/
|
|
95
|
+
export declare function readFormulationEvidence(bomJson: Object, context?: {
|
|
96
|
+
runId?: string;
|
|
97
|
+
ledgerEventCount?: number;
|
|
98
|
+
}): {
|
|
99
|
+
origin: "same-run" | "foreign" | "absent";
|
|
100
|
+
tools: {
|
|
101
|
+
name: string | undefined;
|
|
102
|
+
version: string | undefined;
|
|
103
|
+
source: "probe";
|
|
104
|
+
}[];
|
|
105
|
+
declaredCommands: {
|
|
106
|
+
executable: string;
|
|
107
|
+
commandLine: string;
|
|
108
|
+
workflow: string | undefined;
|
|
109
|
+
task: string | undefined;
|
|
110
|
+
step: string | undefined;
|
|
111
|
+
source: "ci-config";
|
|
112
|
+
}[];
|
|
113
|
+
sourceTree: {
|
|
114
|
+
commit: string | undefined;
|
|
115
|
+
treeId: string | undefined;
|
|
116
|
+
fileCount: number;
|
|
117
|
+
} | undefined;
|
|
118
|
+
environmentKeys: string[];
|
|
119
|
+
};
|
|
120
|
+
/**
|
|
121
|
+
* The formulation platform entry for the runtime family this reflection runs
|
|
122
|
+
* on, when the record cannot describe the machine in use: either the
|
|
123
|
+
* recorded version of the family differs from the runtime actually running,
|
|
124
|
+
* or the record names other toolchains but no entry of this family at all. A
|
|
125
|
+
* difference proves the formulation's toolchain record describes a machine
|
|
126
|
+
* other than the one re-scanning the BOM; it says nothing about the other
|
|
127
|
+
* toolchains the record names, which no probe of this run observed.
|
|
128
|
+
*
|
|
129
|
+
* @param {Object} evidence Formulation evidence from readFormulationEvidence.
|
|
130
|
+
* @param {Object} runtime The reflection's runtime facts.
|
|
131
|
+
* @param {string} runtime.name Runtime name, such as "Node.js".
|
|
132
|
+
* @param {string} runtime.version Runtime version.
|
|
133
|
+
* @returns {{tool: string, recordedVersion: string|undefined, runtimeVersion: string}|undefined} The mismatching formulation entry, when one exists.
|
|
134
|
+
*/
|
|
135
|
+
export declare function findRuntimeToolMismatch(evidence: Object, runtime: {
|
|
136
|
+
name: string;
|
|
137
|
+
version: string;
|
|
138
|
+
}): {
|
|
139
|
+
tool: string;
|
|
140
|
+
recordedVersion: string | undefined;
|
|
141
|
+
runtimeVersion: string;
|
|
142
|
+
} | undefined;
|
|
143
|
+
/**
|
|
144
|
+
* The declared CI command a formulation records for one ecosystem, if any.
|
|
145
|
+
* Commands carry no ecosystem tag, so the executable answers: the first
|
|
146
|
+
* declared command whose executable drives that ecosystem's resolver wins,
|
|
147
|
+
* in the order the formulation records them.
|
|
148
|
+
*
|
|
149
|
+
* @param {Object} evidence Formulation evidence from readFormulationEvidence.
|
|
150
|
+
* @param {string} ecosystem Canonical ecosystem name.
|
|
151
|
+
* @returns {Object|undefined} The matching declared command entry.
|
|
152
|
+
*/
|
|
153
|
+
export declare function declaredCommandForEcosystem(evidence: Object, ecosystem: string): Object | undefined;
|
|
154
|
+
//# sourceMappingURL=formulationEvidence.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formulationEvidence.d.ts","sourceRoot":"","sources":["../../../../../lib/stages/postgen/introspection/formulationEvidence.js"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH;;;;;;GAMG;AACH,eAAO,MAAM,2BAA2B,EAF9B,MAE0D,CAAC;AAErE,sEAAsE;AACtE,eAAO,MAAM,2BAA2B,aAAa,CAAC;AAEtD,wEAAwE;AACxE,eAAO,MAAM,0BAA0B,YAAY,CAAC;AAEpD;;;;GAIG;AACH,eAAO,MAAM,yBAAyB,WAAW,CAAC;AAElD;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,EAFvB,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAYvC,CAAC;AAEH;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,EAFvB,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAkDvC,CAAC;AA6BH;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAH/B,MAAM,GAAC,SAGwB,GAF7B,OAAO,CAYnB;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,WAAW,EAH7B,MAAM,GAAC,SAGsB,GAF3B,MAAM,CAKlB;AA6ED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAZpC,MAYoC,EAAE,OAAO,AAXrD,CAGA,EAFA;IAAyB,KAAK,AAA9B,CACA,EADQ,MAAM,CACd;IAAyB,gBAAgB,AAAzC,CACA,EADQ,MAAM,CACd;CAQ0D,GARhD;IACR,MAAM,EAAE,UAAU,GAAC,SAAS,GAAC,QAAQ,CAAC;IACtC,KAAK,EAAE;QAAC,IAAI,EAAE,MAAM,GAAC,SAAS,CAAC;QAAC,OAAO,EAAE,MAAM,GAAC,SAAS,CAAC;QAAC,MAAM,EAAE,OAAO,CAAA;KAAC,EAAE,CAAC;IAC9E,gBAAgB,EAAE;QAAC,UAAU,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,GAAC,SAAS,CAAC;QAAC,IAAI,EAAE,MAAM,GAAC,SAAS,CAAC;QAAC,IAAI,EAAE,MAAM,GAAC,SAAS,CAAC;QAAC,MAAM,EAAE,WAAW,CAAA;KAAC,EAAE,CAAC;IAC/J,UAAU,EAAE;QAAC,MAAM,EAAE,MAAM,GAAC,SAAS,CAAC;QAAC,MAAM,EAAE,MAAM,GAAC,SAAS,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAC,GAAC,SAAS,CAAC;IAC9F,eAAe,EAAE,MAAM,EAAE,CAAA;CAC1B,CA2FH;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,uBAAuB,CAAC,QAAQ,EANrC,MAMqC,EAAE,OAAO,EAJtD;IAAwB,IAAI,EAApB,MAAM,CACd;IAAwB,OAAO,EAAvB,MAAM,CACd;CAEsD,GAF5C;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,eAAe,EAAE,MAAM,GAAC,SAAS,CAAC;IAAC,cAAc,EAAE,MAAM,CAAA;CAAC,GAAC,SAAS,CAyB/F;AAED;;;;;;;;;GASG;AACH,wBAAgB,2BAA2B,CAAC,QAAQ,EAJzC,MAIyC,EAAE,SAAS,EAHpD,MAGoD,GAFlD,MAAM,GAAC,SAAS,CAW5B"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ecosystem marker detection for the build-introspection reflection step.
|
|
3
|
+
*
|
|
4
|
+
* A marker is a manifest or lockfile whose presence on disk proves an
|
|
5
|
+
* ecosystem was part of the scanned project. Markers drive two verdicts:
|
|
6
|
+
* an ecosystem with markers but zero components in the BOM is `absent`, and
|
|
7
|
+
* an ecosystem that has markers but no cdxgen project type at all is a
|
|
8
|
+
* coverage gap (`unsupported`), which is cdxgen's backlog rather than the
|
|
9
|
+
* user's problem.
|
|
10
|
+
*
|
|
11
|
+
* Detection is deliberately bounded: the scanned directory itself plus one
|
|
12
|
+
* level of immediate subdirectories. postProcess runs after generation, so a
|
|
13
|
+
* second full tree walk would be a measurable cost on large repos; markers
|
|
14
|
+
* deeper than one directory level are simply not seen, which is acceptable
|
|
15
|
+
* because tier assignment never relies on markers alone when the BOM already
|
|
16
|
+
* carries the ecosystem's components.
|
|
17
|
+
*/
|
|
18
|
+
/**
|
|
19
|
+
* Marker table: ecosystem → manifest and lockfile names that indicate the
|
|
20
|
+
* ecosystem is part of the project. Entries are either exact file names or
|
|
21
|
+
* `{ suffix }` matchers for extension-driven ecosystems. Ecosystems cdxgen
|
|
22
|
+
* cannot parse (elm, crystal, nim, perl, r) are included so the reflection
|
|
23
|
+
* can report them as coverage gaps instead of silently ignoring them.
|
|
24
|
+
*
|
|
25
|
+
* @type {Readonly<Record<string, {names: string[], suffixes: string[]}>>}
|
|
26
|
+
*/
|
|
27
|
+
export declare const ECOSYSTEM_MARKERS: Readonly<Record<string, {
|
|
28
|
+
names: string[];
|
|
29
|
+
suffixes: string[];
|
|
30
|
+
}>>;
|
|
31
|
+
/** Marker file name → ecosystems claiming it, and marker suffix → claiming
|
|
32
|
+
* ecosystems, both built once from the table. The name index is exported so
|
|
33
|
+
* the reflection can recognize marker paths carried in ledger events without
|
|
34
|
+
* rescanning the filesystem. */
|
|
35
|
+
export declare const MARKERS_BY_NAME: Map<any, any>;
|
|
36
|
+
/**
|
|
37
|
+
* Detect ecosystem markers under a project directory without walking the full
|
|
38
|
+
* tree: the directory itself is inspected, then up to
|
|
39
|
+
* {@link MAX_SUBDIRS_SCANNED} immediate subdirectories in sorted order. Paths
|
|
40
|
+
* are built with `node:path`, so `markersOnDisk` carries platform-correct
|
|
41
|
+
* separators.
|
|
42
|
+
*
|
|
43
|
+
* @param {string} projectPath Directory that was scanned, when known.
|
|
44
|
+
* @param {Object} [hooks] Test hooks.
|
|
45
|
+
* @param {(dirPath: string) => {name: string, directory: boolean}[]} [hooks.listDir] Directory lister override.
|
|
46
|
+
* @returns {{markersByEcosystem: Map<string, string[]>, scannedDirectories: number}} Marker paths per ecosystem and the number of directories inspected.
|
|
47
|
+
*/
|
|
48
|
+
export declare function detectEcosystemMarkers(projectPath: string, hooks?: {
|
|
49
|
+
listDir?: (dirPath: string) => {
|
|
50
|
+
name: string;
|
|
51
|
+
directory: boolean;
|
|
52
|
+
}[];
|
|
53
|
+
}): {
|
|
54
|
+
markersByEcosystem: Map<string, string[]>;
|
|
55
|
+
scannedDirectories: number;
|
|
56
|
+
};
|
|
57
|
+
//# sourceMappingURL=markers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"markers.d.ts","sourceRoot":"","sources":["../../../../../lib/stages/postgen/introspection/markers.js"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAUH;;;;;;;;GAQG;AACH,eAAO,MAAM,iBAAiB,EAFpB,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE;IAAC,KAAK,EAAE,MAAM,EAAE,CAAC;IAAC,QAAQ,EAAE,MAAM,EAAE,CAAA;CAAC,CAAC,CAoFtE,CAAC;AAEH;;;gCAGgC;AAChC,eAAO,MAAM,eAAe,eAAY,CAAC;AAyDzC;;;;;;;;;;;GAWG;AACH,wBAAgB,sBAAsB,CAAC,WAAW,EALvC,MAKuC,EAAE,KAAK,AAJtD,CAEA,EADA;IAA0E,OAAO,AAAjF,CACA,EADQ,CAAC,OAAO,EAAE,MAAM,KAAK;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,OAAO,CAAA;KAAC,EAAE,CACjE;CAE2D,GAFjD;IAAC,kBAAkB,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IAAC,kBAAkB,EAAE,MAAM,CAAA;CAAC,CAoCnF"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reflection: join what cdxgen did (the build ledger) with what it produced
|
|
3
|
+
* (the BOM, through the build-fidelity rule pack) and commit to a per-
|
|
4
|
+
* ecosystem fidelity verdict.
|
|
5
|
+
*
|
|
6
|
+
* The two evidence sources are kept independent on purpose. A finding backed
|
|
7
|
+
* by both the ledger and a BOM-side rule is high confidence; either alone is
|
|
8
|
+
* lower confidence. A ledger event with no BOM-side corroboration is reported
|
|
9
|
+
* as an observation, never as a defect: an event says the run degraded
|
|
10
|
+
* somewhere, but only the BOM shows whether the output paid for it. The
|
|
11
|
+
* rule-only path is a first-class path — reflecting over a foreign BOM with
|
|
12
|
+
* no ledger at all still produces a complete verdict.
|
|
13
|
+
*
|
|
14
|
+
* Every ecosystem present in the scan is assigned exactly one tier from the
|
|
15
|
+
* ladder `resolved > lockfile > manifest > heuristic > absent`, or excluded
|
|
16
|
+
* from scoring entirely as `unsupported` when its markers name an ecosystem
|
|
17
|
+
* cdxgen has no project type for. Ties break toward the worse tier: a report
|
|
18
|
+
* that overstates fidelity stops the remediation loop early, while one that
|
|
19
|
+
* understates it merely costs an extra iteration.
|
|
20
|
+
*/
|
|
21
|
+
/**
|
|
22
|
+
* The fidelity tier ladder, from healthiest to worst.
|
|
23
|
+
*
|
|
24
|
+
* @type {string[]}
|
|
25
|
+
*/
|
|
26
|
+
export declare const FIDELITY_TIERS: string[];
|
|
27
|
+
/**
|
|
28
|
+
* Ecosystem states. `graded` rows carry a tier below their ceiling and are
|
|
29
|
+
* the remediation loop's business; `at-ceiling` rows already parse as
|
|
30
|
+
* completely as their ecosystem permits; `absent` rows produced zero
|
|
31
|
+
* components for a supported ecosystem and are real failures; `unsupported`
|
|
32
|
+
* rows are coverage gaps in cdxgen itself, excluded from the score.
|
|
33
|
+
*
|
|
34
|
+
* @type {string[]}
|
|
35
|
+
*/
|
|
36
|
+
export declare const ECOSYSTEM_STATES: string[];
|
|
37
|
+
/**
|
|
38
|
+
* Ecosystems whose best achievable tier is below `resolved`, because the
|
|
39
|
+
* ecosystem has no resolved graph for cdxgen to read. Any ecosystem not
|
|
40
|
+
* listed here defaults to a ceiling of `resolved`, so a newly supported
|
|
41
|
+
* ecosystem fails safe by demanding the most. Every entry below is backed by
|
|
42
|
+
* a measurement recorded in the deliverable handoff; none is added from
|
|
43
|
+
* reading a table.
|
|
44
|
+
*
|
|
45
|
+
* @type {Readonly<Record<string, string>>}
|
|
46
|
+
*/
|
|
47
|
+
export declare const ECOSYSTEM_CEILINGS: Readonly<Record<string, string>>;
|
|
48
|
+
/**
|
|
49
|
+
* True when introspection is enabled for a run: the CLI option is set or the
|
|
50
|
+
* documented environment opt-in is present. Everything in this module sits
|
|
51
|
+
* behind this check, so a disabled run pays one boolean test.
|
|
52
|
+
*
|
|
53
|
+
* @param {Object} options CLI options.
|
|
54
|
+
* @returns {boolean} True when the reflection should run.
|
|
55
|
+
*/
|
|
56
|
+
export { isIntrospectionEnabled } from "../../../core/buildLedger.js";
|
|
57
|
+
/**
|
|
58
|
+
* Review a completed run and produce a per-ecosystem fidelity assessment.
|
|
59
|
+
*
|
|
60
|
+
* @param {Object} bomJson Generated CycloneDX BOM.
|
|
61
|
+
* @param {Object} options CLI options.
|
|
62
|
+
* @param {Object} [context] Overrides for testing.
|
|
63
|
+
* @param {Object[]} [context.ledgerEvents] Events, defaulting to the sidecar or in-memory ledger.
|
|
64
|
+
* @param {string} [context.ledgerSource] Force the reported ledger source.
|
|
65
|
+
* @param {boolean} [context.ledgerComplete] Force the reported ledger completeness.
|
|
66
|
+
* @param {string} [context.projectPath] Directory scanned, for marker detection.
|
|
67
|
+
* @param {Object} [context.markerHooks] Directory-lister overrides for marker detection tests.
|
|
68
|
+
* @returns {Promise<Object>} The reflection document.
|
|
69
|
+
*/
|
|
70
|
+
export declare function reflectOnRun(bomJson: Object, options?: Object, context?: {
|
|
71
|
+
ledgerEvents?: Object[];
|
|
72
|
+
ledgerSource?: string;
|
|
73
|
+
ledgerComplete?: boolean;
|
|
74
|
+
projectPath?: string;
|
|
75
|
+
markerHooks?: Object;
|
|
76
|
+
}): Promise<Object>;
|
|
77
|
+
//# sourceMappingURL=reflect.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reflect.d.ts","sourceRoot":"","sources":["../../../../../lib/stages/postgen/introspection/reflect.js"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AA6BH;;;;GAIG;AACH,eAAO,MAAM,cAAc,EAFjB,MAAM,EAQf,CAAC;AAWF;;;;;;;;GAQG;AACH,eAAO,MAAM,gBAAgB,EAFnB,MAAM,EAOf,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,kBAAkB,EAFrB,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CA6BvC,CAAC;AAqIH;;;;;;;GAOG;AACH,OAAO,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AAusBtE;;;;;;;;;;;;GAYG;AACH,wBAAsB,YAAY,CAAC,OAAO,EAV/B,MAU+B,EAAE,OAAO,GATxC,MAS6C,EAAE,OAAO,AAR9D,CAMA,EALA;IAA2B,YAAY,AAAvC,CACA,EADQ,MAAM,EAAE,CAChB;IAAyB,YAAY,AAArC,CACA,EADQ,MAAM,CACd;IAA0B,cAAc,AAAxC,CACA,EADQ,OAAO,CACf;IAAyB,WAAW,AAApC,CACA,EADQ,MAAM,CACd;IAAyB,WAAW,AAApC,CACA,EADQ,MAAM,CACd;CAEmE,GAFzD,OAAO,CAAC,MAAM,CAAC,CAmO3B"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Renderers over a completed reflection document and its scoring document.
|
|
3
|
+
*
|
|
4
|
+
* Every function here is pure: the reflection and scoring documents are the
|
|
5
|
+
* only evidence inputs, nothing reads the filesystem, the ledger, or the BOM
|
|
6
|
+
* again, and nothing writes a file. The caller owns serialization and printing,
|
|
7
|
+
* which is what makes these renderable against a committed fixture without a
|
|
8
|
+
* temporary directory.
|
|
9
|
+
*
|
|
10
|
+
* The markdown report is written for a human reading it in a terminal pager, a
|
|
11
|
+
* CI log, or a pull-request comment: plain GitHub-flavoured markdown, no HTML,
|
|
12
|
+
* no emoji, and a verdict line that carries the right impression on its own.
|
|
13
|
+
* The JSON report is written for the remediation loop: a versioned contract
|
|
14
|
+
* with stable key order and no content that churns between identical runs, so
|
|
15
|
+
* an agent can diff consecutive reports to detect progress. Free text is
|
|
16
|
+
* redacted again here even though the ledger already sanitized it, because
|
|
17
|
+
* this report is the artifact most likely to be pasted into a chat window.
|
|
18
|
+
*/
|
|
19
|
+
/**
|
|
20
|
+
* Version of the JSON report contract. Additive fields bump the minor version;
|
|
21
|
+
* removals or semantic changes bump the major version.
|
|
22
|
+
*
|
|
23
|
+
* @type {string}
|
|
24
|
+
*/
|
|
25
|
+
export declare const INTROSPECTION_REPORT_SCHEMA_VERSION: string;
|
|
26
|
+
/**
|
|
27
|
+
* Derive the overall tier and confidence labels from the scored rows.
|
|
28
|
+
*
|
|
29
|
+
* The scoring document publishes a number only. Both labels the reports
|
|
30
|
+
* publish are the *worst* among the scored rows: one unhealthy ecosystem must
|
|
31
|
+
* not disappear behind a healthy average, and no report may claim more
|
|
32
|
+
* confidence than its least-corroborated row. A reflection with no scored
|
|
33
|
+
* rows carries no verdict at all, so both labels are null.
|
|
34
|
+
*
|
|
35
|
+
* @param {Object} scored Scoring document from scoreReflection.
|
|
36
|
+
* @returns {{tier: string|null, confidence: string|null}} Worst tier and confidence among the scored rows.
|
|
37
|
+
*/
|
|
38
|
+
export declare function overallAssessment(scored: Object): {
|
|
39
|
+
tier: string | null;
|
|
40
|
+
confidence: string | null;
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* Build the JSON report document, the remediation loop's contract.
|
|
44
|
+
*
|
|
45
|
+
* @param {Object} reflection Reflection document from reflectOnRun.
|
|
46
|
+
* @param {Object} scored Scoring document from scoreReflection.
|
|
47
|
+
* @param {Object} [options] CLI options that name the run's outputs.
|
|
48
|
+
* @param {string} [options.output] Path the BOM was written to.
|
|
49
|
+
* @param {number} [options.introspectFailBelow] CI gate threshold, when configured.
|
|
50
|
+
* @returns {Object} The report document; serializing it is the caller's job.
|
|
51
|
+
*/
|
|
52
|
+
export declare function buildIntrospectionJson(reflection: Object, scored: Object, options?: {
|
|
53
|
+
output?: string;
|
|
54
|
+
introspectFailBelow?: number;
|
|
55
|
+
}): Object;
|
|
56
|
+
/**
|
|
57
|
+
* Render the markdown report.
|
|
58
|
+
*
|
|
59
|
+
* @param {Object} reflection Reflection document from reflectOnRun.
|
|
60
|
+
* @param {Object} scored Scoring document from scoreReflection.
|
|
61
|
+
* @param {Object} [options] CLI options that name the run's outputs.
|
|
62
|
+
* @param {string} [options.output] Path the BOM was written to.
|
|
63
|
+
* @param {boolean} [options.installDeps] Whether the run installs dependencies.
|
|
64
|
+
* @returns {string} The complete markdown report.
|
|
65
|
+
*/
|
|
66
|
+
export declare function renderIntrospectionMarkdown(reflection: Object, scored: Object, options?: {
|
|
67
|
+
output?: string;
|
|
68
|
+
installDeps?: boolean;
|
|
69
|
+
}): string;
|
|
70
|
+
/**
|
|
71
|
+
* Render the console summary: a handful of diagnostic lines carrying the
|
|
72
|
+
* verdict, the remediation counts, and the paths the reports were written
|
|
73
|
+
* to. The full report never goes to the console.
|
|
74
|
+
*
|
|
75
|
+
* @param {Object} scored Scoring document from scoreReflection.
|
|
76
|
+
* @param {Object} [options] CLI options naming the report outputs.
|
|
77
|
+
* @param {string} [options.introspectReport] Path of the markdown report.
|
|
78
|
+
* @param {string} [options.introspectJson] Path of the JSON report.
|
|
79
|
+
* @returns {string} Newline-terminated lines for the diagnostic stream.
|
|
80
|
+
*/
|
|
81
|
+
export declare function renderIntrospectionConsole(scored: Object, options?: {
|
|
82
|
+
introspectReport?: string;
|
|
83
|
+
introspectJson?: string;
|
|
84
|
+
}): string;
|
|
85
|
+
//# sourceMappingURL=report.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"report.d.ts","sourceRoot":"","sources":["../../../../../lib/stages/postgen/introspection/report.js"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAMH;;;;;GAKG;AACH,eAAO,MAAM,mCAAmC,EAFtC,MAE8C,CAAC;AAwGzD;;;;;;;;;;;GAWG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAH7B,MAG6B,GAF3B;IAAC,IAAI,EAAE,MAAM,GAAC,IAAI,CAAC;IAAC,UAAU,EAAE,MAAM,GAAC,IAAI,CAAA;CAAC,CAuBxD;AA0XD;;;;;;;;;GASG;AACH,wBAAgB,sBAAsB,CAAC,UAAU,EAPtC,MAOsC,EAAE,MAAM,EAN9C,MAM8C,EAAE,OAAO,AAL/D,CAGA,EAFA;IAAyB,MAAM,AAA/B,CACA,EADQ,MAAM,CACd;IAAyB,mBAAmB,AAA5C,CACA,EADQ,MAAM,CACd;CAEoE,GAF1D,MAAM,CA4ElB;AAoXD;;;;;;;;;GASG;AACH,wBAAgB,2BAA2B,CAAC,UAAU,EAP3C,MAO2C,EAAE,MAAM,EANnD,MAMmD,EAAE,OAAO,AALpE,CAGA,EAFA;IAAyB,MAAM,AAA/B,CACA,EADQ,MAAM,CACd;IAA0B,WAAW,AAArC,CACA,EADQ,OAAO,CACf;CAEyE,GAF/D,MAAM,CA2JlB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,0BAA0B,CAAC,MAAM,EANtC,MAMsC,EAAE,OAAO,AALvD,CAGA,EAFA;IAAyB,gBAAgB,AAAzC,CACA,EADQ,MAAM,CACd;IAAyB,cAAc,AAAvC,CACA,EADQ,MAAM,CACd;CAE4D,GAFlD,MAAM,CAiClB"}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Scoring and remediation ranking over a completed reflection document.
|
|
3
|
+
*
|
|
4
|
+
* Every function here is pure: the reflection produced by `reflect.js` is the
|
|
5
|
+
* only evidence input, the remediation catalog is a static lookup passed in by
|
|
6
|
+
* the caller, and nothing reads the ledger, the BOM, or the filesystem. The
|
|
7
|
+
* same reflection therefore always yields the same score, on every runtime.
|
|
8
|
+
*
|
|
9
|
+
* The score is the gradient and the tier is the verdict: an ecosystem at its
|
|
10
|
+
* ceiling scores 100 and emits nothing (a manifest-tier helm chart is a
|
|
11
|
+
* success, not a nagging opportunity), an unsupported ecosystem is excluded
|
|
12
|
+
* from the mean entirely (a missing Elm parser is a coverage gap, not a
|
|
13
|
+
* project defect), and everything else starts from its tier base and loses
|
|
14
|
+
* points for each tool fact and corroborated degradation the reflection
|
|
15
|
+
* recorded. Deductions are floored at the tier base minus 15 so a single
|
|
16
|
+
* ecosystem can never fall out of its tier's band.
|
|
17
|
+
*/
|
|
18
|
+
/**
|
|
19
|
+
* Base score per fidelity tier, from healthiest to worst.
|
|
20
|
+
*
|
|
21
|
+
* @type {Readonly<Record<string, number>>}
|
|
22
|
+
*/
|
|
23
|
+
export declare const TIER_BASE_SCORES: Readonly<Record<string, number>>;
|
|
24
|
+
/**
|
|
25
|
+
* The fidelity ladder, healthiest first, shared by the rank arithmetic and the
|
|
26
|
+
* rule-derived target selection.
|
|
27
|
+
*
|
|
28
|
+
* @type {Readonly<string[]>}
|
|
29
|
+
*/
|
|
30
|
+
export declare const TIER_LADDER: Readonly<string[]>;
|
|
31
|
+
/**
|
|
32
|
+
* Closed vocabulary for catalog action kinds. `container` proposes running
|
|
33
|
+
* cdxgen inside the official image for toolchains that are impractical to
|
|
34
|
+
* provision on the host.
|
|
35
|
+
*
|
|
36
|
+
* @type {Readonly<string[]>}
|
|
37
|
+
*/
|
|
38
|
+
export declare const REMEDIATION_ACTION_KINDS: Readonly<string[]>;
|
|
39
|
+
/**
|
|
40
|
+
* Action kinds that need outbound network access, and are therefore blocked
|
|
41
|
+
* when the run was offline or under a command-execution policy.
|
|
42
|
+
*
|
|
43
|
+
* @type {ReadonlySet<string>}
|
|
44
|
+
*/
|
|
45
|
+
export declare const NETWORK_ACTION_KINDS: ReadonlySet<string>;
|
|
46
|
+
/**
|
|
47
|
+
* Provisioners a catalog action can depend on. An action whose `via` names one
|
|
48
|
+
* of these is blocked when the run recorded the provisioner as unavailable.
|
|
49
|
+
*
|
|
50
|
+
* @type {ReadonlySet<string>}
|
|
51
|
+
*/
|
|
52
|
+
export declare const PROVISIONER_TOOLS: ReadonlySet<string>;
|
|
53
|
+
/**
|
|
54
|
+
* Confidence that the row's verdict reflects reality, derived from the
|
|
55
|
+
* corroboration between the ledger and the rule pack. `high` needs both
|
|
56
|
+
* sources on the row, `low` covers an absent or incomplete ledger and
|
|
57
|
+
* disk-marker-only verdicts, and everything else is `medium`.
|
|
58
|
+
*
|
|
59
|
+
* A foreign BOM's formulation is the asymmetric case. It substitutes for the
|
|
60
|
+
* absent ledger events as primary evidence, which lifts the verdict off the
|
|
61
|
+
* marker-only floor; because the run was never observed, `medium` is a cap
|
|
62
|
+
* it can never exceed, and a formulation without a toolchain record leaves
|
|
63
|
+
* the row at `low`. On a same-run scan the formulation is the ledger's own
|
|
64
|
+
* evidence reported twice, so it moves nothing in either direction.
|
|
65
|
+
*
|
|
66
|
+
* @param {Object} row Ecosystem row.
|
|
67
|
+
* @param {Object} reflection Reflection document.
|
|
68
|
+
* @returns {"high"|"medium"|"low"} Confidence label.
|
|
69
|
+
*/
|
|
70
|
+
export declare function confidenceFor(row: Object, reflection: Object): "high" | "medium" | "low";
|
|
71
|
+
/**
|
|
72
|
+
* Total score deduction for a row: one amount per missing or mismatched tool,
|
|
73
|
+
* plus one impact-keyed amount per distinct corroborated remediation id. The
|
|
74
|
+
* catalog supplies the kind behind each id, so a `command.failed` event keeps
|
|
75
|
+
* its own extra deduction even though the reflection stores degradations by
|
|
76
|
+
* id.
|
|
77
|
+
*
|
|
78
|
+
* @param {Object} row Ecosystem row.
|
|
79
|
+
* @param {Object|null} catalog Remediation catalog keyed by id.
|
|
80
|
+
* @returns {{total: number, byRemediationId: Map<string, number>}} Total deduction and the per-remediation split.
|
|
81
|
+
*/
|
|
82
|
+
export declare function deductionsFor(row: Object, catalog: Object | null): {
|
|
83
|
+
total: number;
|
|
84
|
+
byRemediationId: Map<string, number>;
|
|
85
|
+
};
|
|
86
|
+
/**
|
|
87
|
+
* Score one ecosystem row. At-ceiling rows score 100 whatever their tier and
|
|
88
|
+
* unsupported rows score nothing at all — they sit outside the mean.
|
|
89
|
+
*
|
|
90
|
+
* @param {Object} row Ecosystem row.
|
|
91
|
+
* @param {Object|null} catalog Remediation catalog keyed by id.
|
|
92
|
+
* @returns {{score: number, base: number, deduction: number, weight: number}|null} Score facts, or null for unsupported rows.
|
|
93
|
+
*/
|
|
94
|
+
export declare function scoreEcosystemRow(row: Object, catalog: Object | null): {
|
|
95
|
+
score: number;
|
|
96
|
+
base: number;
|
|
97
|
+
deduction: number;
|
|
98
|
+
weight: number;
|
|
99
|
+
} | null;
|
|
100
|
+
export type ResolvedActionVersion = {
|
|
101
|
+
/**
|
|
102
|
+
* Declared version, when a source answered.
|
|
103
|
+
*/
|
|
104
|
+
version: string | undefined;
|
|
105
|
+
/**
|
|
106
|
+
* Cascade band that answered.
|
|
107
|
+
*/
|
|
108
|
+
versionFrom: "mismatch" | "pin" | "expected" | "unresolved";
|
|
109
|
+
/**
|
|
110
|
+
* Where the version came from.
|
|
111
|
+
*/
|
|
112
|
+
versionSource: string | undefined;
|
|
113
|
+
/**
|
|
114
|
+
* True when no source answered.
|
|
115
|
+
*/
|
|
116
|
+
versionSourceMissing: boolean | undefined;
|
|
117
|
+
};
|
|
118
|
+
/**
|
|
119
|
+
* Order remediations for the loop: the largest expected gain first, then the
|
|
120
|
+
* largest per-ecosystem recovery, then the most confident evidence, then the
|
|
121
|
+
* id — a total order, so the sequence is identical no matter how the input
|
|
122
|
+
* findings were ordered. The per-ecosystem recovery separates entries whose
|
|
123
|
+
* weighted gains round to the same hundredth.
|
|
124
|
+
*
|
|
125
|
+
* @param {Object[]} entries Remediation entries.
|
|
126
|
+
* @returns {Object[]} Ranked copy of the entries.
|
|
127
|
+
*/
|
|
128
|
+
export declare function rankRemediations(entries: Object[]): Object[];
|
|
129
|
+
/**
|
|
130
|
+
* Score a completed reflection and rank everything an agent could do next.
|
|
131
|
+
*
|
|
132
|
+
* @param {Object} reflection Reflection document from reflectOnRun.
|
|
133
|
+
* @param {Object|null} catalog Remediation catalog keyed by id (data/remediations.json).
|
|
134
|
+
* @param {Object} [runContext] Run facts the reflection cannot carry.
|
|
135
|
+
* @param {boolean} [runContext.secureMode] The run executed under secure mode or a command policy.
|
|
136
|
+
* @param {boolean} [runContext.inContainer] The run executed inside a container.
|
|
137
|
+
* @param {boolean} [runContext.offline] Overrides the offline fact derived from the ledger observations.
|
|
138
|
+
* @param {string[]} [runContext.unavailableProvisioners] Overrides the provisioners derived from the reflection.
|
|
139
|
+
* @param {Object} [runContext.commandFacts] Project facts the command variables (`{{mvn}}`, `{{gradle}}`, `{{pythonManager}}`, `{{npmClient}}`) resolve from; without them the variables fall back to the plain executables.
|
|
140
|
+
* @returns {Object} Scoring document with the overall score, per-ecosystem scores, coverage gaps and the ranked remediation list.
|
|
141
|
+
*/
|
|
142
|
+
export declare function scoreReflection(reflection: Object, catalog: Object | null, runContext?: {
|
|
143
|
+
secureMode?: boolean;
|
|
144
|
+
inContainer?: boolean;
|
|
145
|
+
offline?: boolean;
|
|
146
|
+
unavailableProvisioners?: string[];
|
|
147
|
+
commandFacts?: Object;
|
|
148
|
+
}): Object;
|
|
149
|
+
//# sourceMappingURL=score.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"score.d.ts","sourceRoot":"","sources":["../../../../../lib/stages/postgen/introspection/score.js"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAMH;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,EAFnB,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAQvC,CAAC;AAEH;;;;;GAKG;AACH,eAAO,MAAM,WAAW,EAFd,QAAQ,CAAC,MAAM,EAAE,CAQzB,CAAC;AAwBH;;;;;;GAMG;AACH,eAAO,MAAM,wBAAwB,EAF3B,QAAQ,CAAC,MAAM,EAAE,CASzB,CAAC;AAEH;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,EAFvB,WAAW,CAAC,MAAM,CAEkD,CAAC;AAE/E;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,EAFpB,WAAW,CAAC,MAAM,CAQ1B,CAAC;AAiEH;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAJtB,MAIsB,EAAE,UAAU,EAHlC,MAGkC,GAFhC,MAAM,GAAC,QAAQ,GAAC,KAAK,CAwCjC;AAgED;;;;;;;;;;GAUG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAJtB,MAIsB,EAAE,OAAO,EAH/B,MAAM,GAAC,IAGwB,GAF7B;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,eAAe,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAAC,CAsBjE;AAED;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAJ1B,MAI0B,EAAE,OAAO,EAHnC,MAAM,GAAC,IAG4B,GAFjC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAC,GAAC,IAAI,CAgBjF;AAkFE,YAAkB,qBAAqB,GACvC;;;;IAA6B,OAAO,EAAzB,MAAM,GAAC,SAAS,CAC3B;;;;IAAqD,WAAW,EAArD,UAAU,GAAC,KAAK,GAAC,UAAU,GAAC,YAAY,CACnD;;;;IAA6B,aAAa,EAA/B,MAAM,GAAC,SAAS,CAC3B;;;;IAA8B,oBAAoB,EAAvC,OAAO,GAAC,SAAS,CAC9B;CAAA,CAAA;AA+fD;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAH7B,MAAM,EAGuB,GAF3B,MAAM,EAAE,CAWpB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,eAAe,CAAC,UAAU,EAV/B,MAU+B,EAAE,OAAO,EATxC,MAAM,GAAC,IASiC,EAAE,UAAU,AAR5D,CAMA,EALA;IAA6B,UAAU,AAAvC,CACA,EADQ,OAAO,CACf;IAA6B,WAAW,AAAxC,CACA,EADQ,OAAO,CACf;IAA6B,OAAO,AAApC,CACA,EADQ,OAAO,CACf;IAA8B,uBAAuB,AAArD,CACA,EADQ,MAAM,EAAE,CAChB;IAA4B,YAAY,AAAxC,CACA,EADQ,MAAM,CACd;CAEiE,GAFvD,MAAM,CA0FlB"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Command shaping for remediation actions.
|
|
3
|
+
*
|
|
4
|
+
* The remediation catalog authors commands with template variables where the
|
|
5
|
+
* right value depends on the scanned project: which maven or gradle
|
|
6
|
+
* executable the repo wraps, which Python manager owns its lock files, which
|
|
7
|
+
* client npm itself should use. This module substitutes those variables from
|
|
8
|
+
* a facts object the caller gathered earlier, and names on every shaped
|
|
9
|
+
* command the detection it relied on, so a reviewer can tell a correct
|
|
10
|
+
* detection from a lucky default.
|
|
11
|
+
*
|
|
12
|
+
* Every function here is pure: the facts object is the only input beyond the
|
|
13
|
+
* template string, nothing reads the filesystem, and the same facts always
|
|
14
|
+
* yield the same command. The filesystem reads live in the collector
|
|
15
|
+
* (`commandFacts.js`).
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* Template variables this module substitutes, beside the `{{version}}` and
|
|
19
|
+
* `{{major}}` placeholders the version cascade fills.
|
|
20
|
+
*
|
|
21
|
+
* @type {Readonly<string[]>}
|
|
22
|
+
*/
|
|
23
|
+
export declare const SHAPE_VARIABLES: Readonly<string[]>;
|
|
24
|
+
/**
|
|
25
|
+
* Python managers a command can name, with the lock command each catalog
|
|
26
|
+
* entry pairs the variable with.
|
|
27
|
+
*
|
|
28
|
+
* @type {Readonly<string[]>}
|
|
29
|
+
*/
|
|
30
|
+
export declare const PYTHON_MANAGERS: Readonly<string[]>;
|
|
31
|
+
export type CommandFacts = {
|
|
32
|
+
/**
|
|
33
|
+
* Directory the facts were gathered from.
|
|
34
|
+
*/
|
|
35
|
+
projectRoot?: string;
|
|
36
|
+
/**
|
|
37
|
+
* Platform the command targets; defaults to posix.
|
|
38
|
+
*/
|
|
39
|
+
platform?: "posix" | "windows";
|
|
40
|
+
/**
|
|
41
|
+
* Wrapper presence facts, executable-bit included for the platform's script.
|
|
42
|
+
*/
|
|
43
|
+
wrappers?: {
|
|
44
|
+
mvnw?: boolean;
|
|
45
|
+
mvnwInexecutable?: boolean;
|
|
46
|
+
mvnwCmd?: boolean;
|
|
47
|
+
gradlew?: boolean;
|
|
48
|
+
gradlewInexecutable?: boolean;
|
|
49
|
+
gradlewBat?: boolean;
|
|
50
|
+
composerPhar?: boolean;
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* The Python manager in play.
|
|
54
|
+
*/
|
|
55
|
+
pythonManager?: string | undefined;
|
|
56
|
+
/**
|
|
57
|
+
* Every manager detected, when two or more compete.
|
|
58
|
+
*/
|
|
59
|
+
pythonManagerCandidates?: string[];
|
|
60
|
+
/**
|
|
61
|
+
* The npm client the project names or locks.
|
|
62
|
+
*/
|
|
63
|
+
npmClient?: string;
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* Shape one command string: substitute the template variables the catalog
|
|
67
|
+
* authors into it and report which detection drove the result. A command
|
|
68
|
+
* without any `{{` marker is returned byte-identical and unshaped.
|
|
69
|
+
*
|
|
70
|
+
* @param {string} templateCommand Catalog command template.
|
|
71
|
+
* @param {CommandFacts} [facts] Facts gathered for the scanned project.
|
|
72
|
+
* @returns {{command: string, shapedBy: string|undefined, shapedNote: string|undefined}} The shaped command, the detection behind it, and the question to surface when shaping could not answer.
|
|
73
|
+
*/
|
|
74
|
+
export declare function shapeCommand(templateCommand: string, facts?: CommandFacts): {
|
|
75
|
+
command: string;
|
|
76
|
+
shapedBy: string | undefined;
|
|
77
|
+
shapedNote: string | undefined;
|
|
78
|
+
};
|
|
79
|
+
//# sourceMappingURL=shapeCommand.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shapeCommand.d.ts","sourceRoot":"","sources":["../../../../../lib/stages/postgen/introspection/shapeCommand.js"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH;;;;;GAKG;AACH,eAAO,MAAM,eAAe,EAFlB,QAAQ,CAAC,MAAM,EAAE,CAazB,CAAC;AAEH;;;;;GAKG;AACH,eAAO,MAAM,eAAe,EAFlB,QAAQ,CAAC,MAAM,EAAE,CAEoD,CAAC;AAO7E,YAAkB,YAAY,GAC9B;;;;IAAoB,WAAW,AAA/B,CACA,EADW,MAAM,CACjB;;;;IAA+B,QAAQ,AAAvC,CACA,EADW,OAAO,GAAC,SAAS,CAC5B;;;;IAAoB,QAAQ,AAA5B,CAQA,EAPA;QAA8B,IAAI,AAAlC,CACA,EADW,OAAO,CAClB;QAA8B,gBAAgB,AAA9C,CACA,EADW,OAAO,CAClB;QAA8B,OAAO,AAArC,CACA,EADW,OAAO,CAClB;QAA8B,OAAO,AAArC,CACA,EADW,OAAO,CAClB;QAA8B,mBAAmB,AAAjD,CACA,EADW,OAAO,CAClB;QAA8B,UAAU,AAAxC,CACA,EADW,OAAO,CAClB;QAA8B,YAAY,AAA1C,CACA,EADW,OAAO,CAClB;KAAA,CAAA;;;;IAA8B,aAAa,AAA3C,CACA,EADW,MAAM,GAAC,SAAS,CAC3B;;;;IAAsB,uBAAuB,AAA7C,CACA,EADW,MAAM,EAAE,CACnB;;;;IAAoB,SAAS,AAA7B,CACF,EADa,MAAM,CACnB;CAAA,CAAA;AA2MD;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAAC,eAAe,EAJjC,MAIiC,EAAE,KAAK,AAHhD,CACA,EADQ,YAG6C,GAF3C;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,GAAC,SAAS,CAAC;IAAC,UAAU,EAAE,MAAM,GAAC,SAAS,CAAA;CAAC,CA8BvF"}
|