@intentius/chant 0.124.97 → 0.124.98
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/audit/core.d.ts +29 -0
- package/dist/audit/core.d.ts.map +1 -1
- package/dist/audit/core.js +48 -11
- package/dist/audit/identity.d.ts +27 -0
- package/dist/audit/identity.d.ts.map +1 -0
- package/dist/audit/identity.js +36 -0
- package/dist/audit/report-html.d.ts +3 -1
- package/dist/audit/report-html.d.ts.map +1 -1
- package/dist/audit/report-html.js +1 -1
- package/dist/audit/report-model.d.ts +16 -0
- package/dist/audit/report-model.d.ts.map +1 -1
- package/dist/audit/report-model.js +5 -1
- package/dist/ci-agent.d.ts +17 -0
- package/dist/ci-agent.d.ts.map +1 -1
- package/dist/ci-agent.js +32 -0
- package/dist/ci-comment-allow.d.ts +88 -0
- package/dist/ci-comment-allow.d.ts.map +1 -0
- package/dist/ci-comment-allow.js +178 -0
- package/dist/ci-comment-commands.d.ts +12 -0
- package/dist/ci-comment-commands.d.ts.map +1 -1
- package/dist/ci-comment-commands.js +22 -0
- package/dist/ci-control.d.ts +6 -1
- package/dist/ci-control.d.ts.map +1 -1
- package/dist/ci-control.js +6 -1
- package/dist/ci-product.d.ts +3 -0
- package/dist/ci-product.d.ts.map +1 -1
- package/dist/ci-product.js +3 -0
- package/dist/cli/commands/audit.d.ts +3 -1
- package/dist/cli/commands/audit.d.ts.map +1 -1
- package/dist/cli/commands/audit.js +23 -6
- package/dist/cli/commands/import.d.ts +8 -1
- package/dist/cli/commands/import.d.ts.map +1 -1
- package/dist/cli/commands/import.js +31 -6
- package/dist/cli/handlers/agent.d.ts.map +1 -1
- package/dist/cli/handlers/agent.js +12 -2
- package/dist/cli/handlers/pr-comment.d.ts +6 -0
- package/dist/cli/handlers/pr-comment.d.ts.map +1 -1
- package/dist/cli/handlers/pr-comment.js +12 -0
- package/dist/cli/handlers/promote.d.ts.map +1 -1
- package/dist/cli/handlers/promote.js +53 -6
- package/dist/cli/main.d.ts.map +1 -1
- package/dist/cli/main.js +29 -6
- package/dist/cli/parse-args.d.ts.map +1 -1
- package/dist/cli/parse-args.js +23 -0
- package/dist/cli/registry.d.ts +8 -0
- package/dist/cli/registry.d.ts.map +1 -1
- package/dist/cloud-lister/mask.d.ts +30 -1
- package/dist/cloud-lister/mask.d.ts.map +1 -1
- package/dist/cloud-lister/mask.js +66 -3
- package/dist/components/driver.d.ts +8 -1
- package/dist/components/driver.d.ts.map +1 -1
- package/dist/components/driver.js +1 -0
- package/dist/components/product-pipeline.d.ts +23 -1
- package/dist/components/product-pipeline.d.ts.map +1 -1
- package/dist/components/product-pipeline.js +40 -7
- package/dist/components/product-plan.d.ts +20 -0
- package/dist/components/product-plan.d.ts.map +1 -1
- package/dist/components/product-plan.js +11 -1
- package/dist/control/applied.d.ts +8 -1
- package/dist/control/applied.d.ts.map +1 -1
- package/dist/control/applied.js +18 -2
- package/dist/control/dispatch.d.ts +52 -0
- package/dist/control/dispatch.d.ts.map +1 -1
- package/dist/control/dispatch.js +140 -4
- package/dist/control/train.d.ts +198 -0
- package/dist/control/train.d.ts.map +1 -0
- package/dist/control/train.js +294 -0
- package/dist/deep-observation.js +2 -2
- package/dist/floor-table.data.d.ts.map +1 -1
- package/dist/floor-table.data.js +11 -0
- package/dist/graph-detail.d.ts +9 -0
- package/dist/graph-detail.d.ts.map +1 -1
- package/dist/graph-detail.js +38 -13
- package/dist/graph-refs.d.ts +233 -3
- package/dist/graph-refs.d.ts.map +1 -1
- package/dist/graph-refs.js +106 -15
- package/dist/lint/post-synth.d.ts +22 -0
- package/dist/lint/post-synth.d.ts.map +1 -1
- package/dist/lint/rules/declarable-naming-convention.d.ts +12 -0
- package/dist/lint/rules/declarable-naming-convention.d.ts.map +1 -1
- package/dist/lint/rules/declarable-naming-convention.js +38 -8
- package/dist/lint/rules/imported-source.d.ts +20 -0
- package/dist/lint/rules/imported-source.d.ts.map +1 -0
- package/dist/lint/rules/imported-source.js +27 -0
- package/dist/lint/rules/no-unused-declarable.d.ts.map +1 -1
- package/dist/lint/rules/no-unused-declarable.js +3 -0
- package/dist/op/gate.d.ts +2 -0
- package/dist/op/gate.d.ts.map +1 -1
- package/dist/op/gate.js +8 -1
- package/dist/pr-forge-reads.d.ts +17 -0
- package/dist/pr-forge-reads.d.ts.map +1 -1
- package/dist/pr-forge-reads.js +55 -0
- package/dist/release-floors.d.ts +9 -1
- package/dist/release-floors.d.ts.map +1 -1
- package/dist/release-floors.js +9 -1
- package/dist/repo-path.d.ts +29 -0
- package/dist/repo-path.d.ts.map +1 -0
- package/dist/repo-path.js +81 -0
- package/dist/sensitive-key.d.ts +23 -0
- package/dist/sensitive-key.d.ts.map +1 -1
- package/dist/sensitive-key.js +37 -0
- package/dist/terraform/hcl2json.d.ts +7 -0
- package/dist/terraform/hcl2json.d.ts.map +1 -1
- package/dist/terraform/hcl2json.js +7 -0
- package/dist/wave-runtime.mjs +352 -345
- package/dist/workspace/catalog-edges.d.ts +147 -0
- package/dist/workspace/catalog-edges.d.ts.map +1 -0
- package/dist/workspace/catalog-edges.js +461 -0
- package/dist/workspace/compose-graph.d.ts +73 -3
- package/dist/workspace/compose-graph.d.ts.map +1 -1
- package/dist/workspace/declaration.d.ts +2 -0
- package/dist/workspace/declaration.d.ts.map +1 -1
- package/dist/workspace/declaration.js +1 -0
- package/dist/workspace/declaration.schema.json +6 -0
- package/dist/workspace/discover.d.ts +134 -0
- package/dist/workspace/discover.d.ts.map +1 -0
- package/dist/workspace/discover.js +372 -0
- package/dist/workspace/graph-cli.d.ts +20 -0
- package/dist/workspace/graph-cli.d.ts.map +1 -1
- package/dist/workspace/graph-cli.js +178 -20
- package/dist/workspace/graph.schema.json +195 -2
- package/dist/workspace/release-train.d.ts +214 -3
- package/dist/workspace/release-train.d.ts.map +1 -1
- package/dist/workspace/release-train.js +552 -16
- package/dist/workspace/repo-ref.d.ts +14 -0
- package/dist/workspace/repo-ref.d.ts.map +1 -1
- package/dist/workspace/repo-ref.js +26 -1
- package/dist/workspace/workspace-gates.d.ts +24 -0
- package/dist/workspace/workspace-gates.d.ts.map +1 -1
- package/dist/workspace/workspace-gates.js +29 -5
- package/dist/workspace/workspace-ledger.d.ts +31 -5
- package/dist/workspace/workspace-ledger.d.ts.map +1 -1
- package/dist/workspace/workspace-ledger.js +2 -1
- package/dist/workspace/workspace-run.d.ts +14 -0
- package/dist/workspace/workspace-run.d.ts.map +1 -1
- package/dist/workspace/workspace-run.js +2 -2
- package/dist/yaml.d.ts.map +1 -1
- package/dist/yaml.js +33 -8
- package/package.json +1 -1
- package/src/audit/core.test.ts +64 -1
- package/src/audit/core.ts +75 -10
- package/src/audit/identity.test.ts +31 -0
- package/src/audit/identity.ts +43 -0
- package/src/audit/report-html.ts +4 -2
- package/src/audit/report-model.ts +21 -1
- package/src/ci-agent.test.ts +32 -0
- package/src/ci-agent.ts +42 -0
- package/src/ci-comment-allow.test.ts +380 -0
- package/src/ci-comment-allow.ts +184 -0
- package/src/ci-comment-commands.ts +25 -0
- package/src/ci-control.ts +42 -0
- package/src/ci-product.ts +3 -0
- package/src/cli/commands/audit-parser-notice.test.ts +74 -0
- package/src/cli/commands/audit.test.ts +12 -0
- package/src/cli/commands/audit.ts +25 -7
- package/src/cli/commands/import-layout.test.ts +2 -1
- package/src/cli/commands/import.ts +29 -6
- package/src/cli/handlers/agent.ts +13 -2
- package/src/cli/handlers/pr-comment.ts +12 -0
- package/src/cli/handlers/promote.test.ts +68 -0
- package/src/cli/handlers/promote.ts +52 -6
- package/src/cli/main.test.ts +5 -0
- package/src/cli/main.ts +29 -6
- package/src/cli/parse-args.ts +18 -0
- package/src/cli/registry.ts +8 -0
- package/src/cloud-lister/kubernetes.k3d.e2e.test.ts +104 -0
- package/src/cloud-lister/mask-references.test.ts +132 -0
- package/src/cloud-lister/mask.ts +68 -3
- package/src/components/driver.ts +9 -1
- package/src/components/product-pipeline.ts +57 -7
- package/src/components/product-plan.ts +27 -2
- package/src/control/applied.ts +33 -3
- package/src/control/dispatch.ts +156 -5
- package/src/control/train.test.ts +215 -0
- package/src/control/train.ts +413 -0
- package/src/deep-observation.ts +2 -2
- package/src/floor-table.data.ts +6 -0
- package/src/graph-detail.ts +37 -12
- package/src/graph-refs.test.ts +45 -1
- package/src/graph-refs.ts +321 -14
- package/src/lint/post-synth.ts +20 -0
- package/src/lint/rules/declarable-naming-convention.test.ts +35 -1
- package/src/lint/rules/declarable-naming-convention.ts +35 -8
- package/src/lint/rules/imported-source.test.ts +22 -0
- package/src/lint/rules/imported-source.ts +31 -0
- package/src/lint/rules/no-unused-declarable.test.ts +16 -0
- package/src/lint/rules/no-unused-declarable.ts +7 -0
- package/src/op/gate.ts +10 -2
- package/src/pr-forge-reads.ts +62 -0
- package/src/release-floors.ts +13 -1
- package/src/repo-path.test.ts +72 -0
- package/src/repo-path.ts +103 -0
- package/src/sensitive-key.ts +38 -0
- package/src/terraform/hcl2json.ts +8 -0
- package/src/workspace/application-set.e2e.test.ts +405 -0
- package/src/workspace/catalog-edges.ts +507 -0
- package/src/workspace/ci-green-workflow.test.ts +2 -2
- package/src/workspace/cluster-join.e2e.test.ts +150 -0
- package/src/workspace/compose-graph.ts +74 -5
- package/src/workspace/declaration.schema.json +6 -0
- package/src/workspace/declaration.ts +3 -0
- package/src/workspace/discover.e2e.test.ts +122 -0
- package/src/workspace/discover.test.ts +225 -0
- package/src/workspace/discover.ts +406 -0
- package/src/workspace/external-secret-catalog.e2e.test.ts +98 -0
- package/src/workspace/external-secret-catalog.test.ts +142 -0
- package/src/workspace/graph-cli.ts +207 -21
- package/src/workspace/graph-contract.test.ts +92 -0
- package/src/workspace/graph.schema.json +195 -2
- package/src/workspace/helm-references.e2e.test.ts +135 -0
- package/src/workspace/identity-annotation-catalog.e2e.test.ts +91 -0
- package/src/workspace/identity-annotation-catalog.test.ts +139 -0
- package/src/workspace/release-train-repos.test.ts +304 -0
- package/src/workspace/release-train.test.ts +296 -0
- package/src/workspace/release-train.ts +631 -16
- package/src/workspace/repo-ref.ts +26 -1
- package/src/workspace/runs-on.test.ts +45 -0
- package/src/workspace/workspace-gates.ts +48 -5
- package/src/workspace/workspace-ledger.ts +28 -5
- package/src/workspace/workspace-run.test.ts +1 -1
- package/src/workspace/workspace-run.ts +2 -2
- package/src/yaml.test.ts +96 -8
- package/src/yaml.ts +36 -8
package/dist/audit/core.d.ts
CHANGED
|
@@ -80,6 +80,8 @@ export interface AuditFinding {
|
|
|
80
80
|
kind: string;
|
|
81
81
|
scope: string;
|
|
82
82
|
};
|
|
83
|
+
/** Carried verbatim from the producing `PostSynthDiagnostic.locator` (#5106); one input of the finding's identity. */
|
|
84
|
+
locator?: string;
|
|
83
85
|
}
|
|
84
86
|
/**
|
|
85
87
|
* Resolve the post-synth checks for a lexicon. Injectable so the core can be
|
|
@@ -113,6 +115,29 @@ export type EntitiesProvider = (lexicon: AuditLexicon) => Promise<EntitiesParser
|
|
|
113
115
|
/** Thrown when a lexicon package the audit needs isn't installed. */
|
|
114
116
|
export declare class MissingLexiconError extends Error {
|
|
115
117
|
}
|
|
118
|
+
/**
|
|
119
|
+
* A lexicon whose files were found but not read, because an optional parser it
|
|
120
|
+
* needs is not installed (#5083). Without this a missing parser and a clean
|
|
121
|
+
* repository both produce no findings. `paths` are the audited inputs the
|
|
122
|
+
* lexicon could not read (for terraform, directories).
|
|
123
|
+
*/
|
|
124
|
+
export interface AuditSkip {
|
|
125
|
+
lexicon: string;
|
|
126
|
+
reason: "parser-not-installed";
|
|
127
|
+
/** The npm package to install. */
|
|
128
|
+
package: string;
|
|
129
|
+
/** The command that installs it. */
|
|
130
|
+
install: string;
|
|
131
|
+
paths: string[];
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* The npm package an entities parser reports as missing: any error with a
|
|
135
|
+
* string `parserPackage` property. A lexicon sets it instead of importing a
|
|
136
|
+
* class from here, which keeps lexicon packages free of audit internals.
|
|
137
|
+
*/
|
|
138
|
+
export declare function parserPackageOf(err: unknown): string | undefined;
|
|
139
|
+
/** The sentence `chant audit` prints for a skip, in the log and in text reports. */
|
|
140
|
+
export declare function describeSkip(skip: AuditSkip): string;
|
|
116
141
|
/**
|
|
117
142
|
* Mutable out-param for the inline (`# chant-ignore*`) suppression count
|
|
118
143
|
* (chant #2111): `auditFiles`'s return type stays `AuditFinding[]` for every
|
|
@@ -132,8 +157,12 @@ export declare function auditFiles(inputs: AuditInput[], opts?: {
|
|
|
132
157
|
checksProvider?: ChecksProvider;
|
|
133
158
|
entitiesProvider?: EntitiesProvider;
|
|
134
159
|
suppressionStats?: SuppressionStats;
|
|
160
|
+
/** Filled in place with each lexicon whose parser is not installed (#5083); stays empty on a full read. */
|
|
161
|
+
skips?: AuditSkip[];
|
|
135
162
|
/** Check ids the project enabled with `lint.rules`; a check marked `auditOptIn` runs only when listed here (#3190). */
|
|
136
163
|
enabledRules?: ReadonlySet<string>;
|
|
164
|
+
/** The directory the audit walked, absolute; absent for a remote tree. Reaches a check as `ctx.audit.root` (#5109). */
|
|
165
|
+
root?: string;
|
|
137
166
|
}): Promise<AuditFinding[]>;
|
|
138
167
|
/** Label for findings that span more than one file (e.g. duplicate names). */
|
|
139
168
|
export declare const CROSS_FILE = "(cross-file)";
|
package/dist/audit/core.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../../src/audit/core.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;
|
|
1
|
+
{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../../src/audit/core.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAIH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,KAAK,EAAE,cAAc,EAAyC,MAAM,oBAAoB,CAAC;AAGhG,OAAO,KAAK,EAAE,kBAAkB,EAAiB,MAAM,YAAY,CAAC;AACpE,OAAO,KAAK,EAAE,UAAU,EAAE,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H,IAAI,CAAC,EAAE,MAAM,CAAC;CACV,GACL,OAAO,CAAC,YAAY,EAAE,CAAC,CAqBzB;AAED,8EAA8E;AAC9E,eAAO,MAAM,UAAU,iBAAiB,CAAC"}
|
package/dist/audit/core.js
CHANGED
|
@@ -19,7 +19,8 @@
|
|
|
19
19
|
* so the same graph-reading checks that fire on `chant build` fire on the
|
|
20
20
|
* audit too, with no output-reading rule variants to drift.
|
|
21
21
|
*/
|
|
22
|
-
import {
|
|
22
|
+
import { statSync } from "fs";
|
|
23
|
+
import { basename, dirname, resolve } from "path";
|
|
23
24
|
import { applyInlineSuppressions } from "../lint/suppressions.js";
|
|
24
25
|
import { isPackageNotFound, lexiconModulePath, lexiconPackagesToInstall, lexiconSourceLabel } from "../lexicon-module.js";
|
|
25
26
|
const checksCache = new Map();
|
|
@@ -113,6 +114,33 @@ async function defaultEntitiesProvider(lexicon) {
|
|
|
113
114
|
entitiesParserCache.set(lexicon, parser);
|
|
114
115
|
return parser;
|
|
115
116
|
}
|
|
117
|
+
/**
|
|
118
|
+
* The npm package an entities parser reports as missing: any error with a
|
|
119
|
+
* string `parserPackage` property. A lexicon sets it instead of importing a
|
|
120
|
+
* class from here, which keeps lexicon packages free of audit internals.
|
|
121
|
+
*/
|
|
122
|
+
export function parserPackageOf(err) {
|
|
123
|
+
const pkg = err?.parserPackage;
|
|
124
|
+
return typeof pkg === "string" ? pkg : undefined;
|
|
125
|
+
}
|
|
126
|
+
/** The sentence `chant audit` prints for a skip, in the log and in text reports. */
|
|
127
|
+
export function describeSkip(skip) {
|
|
128
|
+
const n = skip.paths.length;
|
|
129
|
+
const shown = skip.paths.slice(0, 10).join(", ") + (n > 10 ? `, and ${n - 10} more` : "");
|
|
130
|
+
return (`${skip.lexicon} files were found but not read: the parser ${skip.package} is not installed, ` +
|
|
131
|
+
`so ${n} ${n === 1 ? "input produced" : "inputs produced"} no findings (${shown}). ` +
|
|
132
|
+
`Install it with: ${skip.install}`);
|
|
133
|
+
}
|
|
134
|
+
/** The directory an audit target reads from: the target itself, or the directory of a single file. */
|
|
135
|
+
function auditRootDir(target) {
|
|
136
|
+
const abs = resolve(target);
|
|
137
|
+
try {
|
|
138
|
+
return statSync(abs).isFile() ? dirname(abs) : abs;
|
|
139
|
+
}
|
|
140
|
+
catch {
|
|
141
|
+
return abs;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
116
144
|
/**
|
|
117
145
|
* Audit a set of CI files and return all findings. Pure with respect to the
|
|
118
146
|
* filesystem and network — callers supply file contents.
|
|
@@ -133,7 +161,7 @@ export async function auditFiles(inputs, opts = {}) {
|
|
|
133
161
|
if (checks.length === 0)
|
|
134
162
|
continue;
|
|
135
163
|
const parseEntities = await entitiesProvider(lexicon);
|
|
136
|
-
findings.push(...(await auditLexicon(lexicon, files, checks, parseEntities, opts.suppressionStats)));
|
|
164
|
+
findings.push(...(await auditLexicon(lexicon, files, checks, parseEntities, opts.suppressionStats, opts.skips, { ...(opts.root !== undefined ? { root: auditRootDir(opts.root) } : {}) })));
|
|
137
165
|
}
|
|
138
166
|
return findings;
|
|
139
167
|
}
|
|
@@ -152,9 +180,9 @@ function toOutput(file) {
|
|
|
152
180
|
return file.content;
|
|
153
181
|
return { primary: file.content, files: { [basename(file.path)]: file.content } };
|
|
154
182
|
}
|
|
155
|
-
function runChecks(checks, outputs, entities = new Map()) {
|
|
183
|
+
function runChecks(checks, outputs, entities = new Map(), audit) {
|
|
156
184
|
const buildResult = { outputs, entities, warnings: [], errors: [], sourceFileCount: outputs.size };
|
|
157
|
-
const ctx = { outputs, entities: buildResult.entities, buildResult };
|
|
185
|
+
const ctx = { outputs, entities: buildResult.entities, buildResult, ...(audit ? { audit } : {}) };
|
|
158
186
|
const diags = [];
|
|
159
187
|
for (const check of checks) {
|
|
160
188
|
try {
|
|
@@ -171,7 +199,7 @@ function runChecks(checks, outputs, entities = new Map()) {
|
|
|
171
199
|
return applyInlineSuppressions(diags, entities);
|
|
172
200
|
}
|
|
173
201
|
function diagKey(d) {
|
|
174
|
-
return `${d.checkId}\u0000${d.entity ?? ""}\u0000${d.message}`;
|
|
202
|
+
return `${d.checkId}\u0000${d.entity ?? ""}\u0000${d.locator ?? ""}\u0000${d.message}`;
|
|
175
203
|
}
|
|
176
204
|
/**
|
|
177
205
|
* Merge per-file entity maps into one graph for the all-files pass. A key
|
|
@@ -212,7 +240,8 @@ function mergeEntities(maps) {
|
|
|
212
240
|
* may be async (a lexicon's own choice, e.g. a wasm-backed HCL parser); this
|
|
213
241
|
* function awaits each file's entities before either pass runs.
|
|
214
242
|
*/
|
|
215
|
-
async function auditLexicon(lexicon, files, checks, parseEntities, suppressionStats) {
|
|
243
|
+
async function auditLexicon(lexicon, files, checks, parseEntities, suppressionStats, skips, audit) {
|
|
244
|
+
const unread = new Map();
|
|
216
245
|
const entitiesFor = async (file) => {
|
|
217
246
|
if (!parseEntities)
|
|
218
247
|
return new Map();
|
|
@@ -223,13 +252,21 @@ async function auditLexicon(lexicon, files, checks, parseEntities, suppressionSt
|
|
|
223
252
|
...(file.baseDir !== undefined ? { baseDir: file.baseDir } : {}),
|
|
224
253
|
});
|
|
225
254
|
}
|
|
226
|
-
catch {
|
|
255
|
+
catch (err) {
|
|
256
|
+
// A missing parser is not unparseable content: the files were never
|
|
257
|
+
// read, so say so instead of letting them read as clean (#5083).
|
|
258
|
+
const pkg = parserPackageOf(err);
|
|
259
|
+
if (pkg !== undefined)
|
|
260
|
+
unread.set(pkg, [...(unread.get(pkg) ?? []), file.path]);
|
|
227
261
|
// The audit contract is "runs against any repo" — unparseable content
|
|
228
262
|
// contributes no entities, never a crash.
|
|
229
263
|
return new Map();
|
|
230
264
|
}
|
|
231
265
|
};
|
|
232
266
|
const perEntities = new Map(await Promise.all(files.map(async (f) => [f.path, await entitiesFor(f)])));
|
|
267
|
+
for (const [pkg, paths] of unread) {
|
|
268
|
+
skips?.push({ lexicon, reason: "parser-not-installed", package: pkg, install: `npm install -D ${pkg}`, paths: paths.sort() });
|
|
269
|
+
}
|
|
233
270
|
const perFindings = [];
|
|
234
271
|
const perKeys = new Set();
|
|
235
272
|
// chant #2111: meta findings (an expired/misplaced/denied suppression
|
|
@@ -238,24 +275,24 @@ async function auditLexicon(lexicon, files, checks, parseEntities, suppressionSt
|
|
|
238
275
|
// directive again. Counted the same way, once, here too.
|
|
239
276
|
const metaFindings = [];
|
|
240
277
|
for (const file of files) {
|
|
241
|
-
const { diagnostics: diags, suppressed, meta } = runChecks(checks, new Map([[file.path, toOutput(file)]]), perEntities.get(file.path));
|
|
278
|
+
const { diagnostics: diags, suppressed, meta } = runChecks(checks, new Map([[file.path, toOutput(file)]]), perEntities.get(file.path), audit);
|
|
242
279
|
if (suppressionStats)
|
|
243
280
|
suppressionStats.count += suppressed.length;
|
|
244
281
|
for (const m of meta) {
|
|
245
282
|
metaFindings.push({ checkId: m.checkId, severity: m.severity, message: m.message, file: m.file, lexicon, line: m.line });
|
|
246
283
|
}
|
|
247
284
|
for (const d of diags) {
|
|
248
|
-
perFindings.push({ checkId: d.checkId, severity: d.severity, message: d.message, file: file.path, lexicon: d.lexicon ?? lexicon, entity: d.entity, missing: d.missing });
|
|
285
|
+
perFindings.push({ checkId: d.checkId, severity: d.severity, message: d.message, file: file.path, lexicon: d.lexicon ?? lexicon, entity: d.entity, missing: d.missing, ...(d.locator !== undefined ? { locator: d.locator } : {}) });
|
|
249
286
|
perKeys.add(diagKey(d));
|
|
250
287
|
}
|
|
251
288
|
}
|
|
252
289
|
const allOutputs = new Map(files.map((f) => [f.path, toOutput(f)]));
|
|
253
|
-
const { diagnostics: allDiags } = runChecks(checks, allOutputs, mergeEntities([...perEntities.values()]));
|
|
290
|
+
const { diagnostics: allDiags } = runChecks(checks, allOutputs, mergeEntities([...perEntities.values()]), audit);
|
|
254
291
|
const allKeys = new Set(allDiags.map(diagKey));
|
|
255
292
|
const out = perFindings.filter((f) => allKeys.has(diagKey(f)));
|
|
256
293
|
for (const d of allDiags) {
|
|
257
294
|
if (!perKeys.has(diagKey(d))) {
|
|
258
|
-
out.push({ checkId: d.checkId, severity: d.severity, message: d.message, file: CROSS_FILE, lexicon: d.lexicon ?? lexicon, entity: d.entity, missing: d.missing });
|
|
295
|
+
out.push({ checkId: d.checkId, severity: d.severity, message: d.message, file: CROSS_FILE, lexicon: d.lexicon ?? lexicon, entity: d.entity, missing: d.missing, ...(d.locator !== undefined ? { locator: d.locator } : {}) });
|
|
259
296
|
}
|
|
260
297
|
}
|
|
261
298
|
return [...out, ...metaFindings];
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Finding identity (#5106). A report's `findings[].identity` and a SARIF
|
|
3
|
+
* result's `partialFingerprints` name a finding by what it is, so two audit
|
|
4
|
+
* runs over a base and a head can be compared without reading message text.
|
|
5
|
+
*
|
|
6
|
+
* The identity is a hash of the rule id, the file, the entity (the object's
|
|
7
|
+
* name or address), the diagnostic's `locator` (its place inside the object:
|
|
8
|
+
* kind, container index, path in the block), the fingerprint of a flagged
|
|
9
|
+
* secret, and the finding's order among findings that agree on all of those.
|
|
10
|
+
* `message` is not an input, so a name that only appears in the text of a
|
|
11
|
+
* message (a renamed container) does not change it. Renaming the object the
|
|
12
|
+
* entity names does change it.
|
|
13
|
+
*
|
|
14
|
+
* Not a cryptographic digest; it only has to tell findings apart.
|
|
15
|
+
*/
|
|
16
|
+
import type { AuditFinding } from "./core.js";
|
|
17
|
+
/** The SARIF `partialFingerprints` key the identity is published under. */
|
|
18
|
+
export declare const IDENTITY_FINGERPRINT_KEY = "chantFindingIdentity/v1";
|
|
19
|
+
type IdentityInput = Pick<AuditFinding, "checkId" | "file" | "entity" | "locator" | "fingerprint" | "missing">;
|
|
20
|
+
/**
|
|
21
|
+
* One identity per finding, in the order given. Findings that agree on every
|
|
22
|
+
* input are told apart by their position among themselves, so the order the
|
|
23
|
+
* audit emitted them in must be the order passed here.
|
|
24
|
+
*/
|
|
25
|
+
export declare function findingIdentities(findings: readonly IdentityInput[]): string[];
|
|
26
|
+
export {};
|
|
27
|
+
//# sourceMappingURL=identity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identity.d.ts","sourceRoot":"","sources":["../../src/audit/identity.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAG3C,2EAA2E;AAC3E,eAAO,MAAM,wBAAwB,4BAA4B,CAAC;AAElE,KAAK,aAAa,GAAG,IAAI,CAAC,YAAY,EAAE,SAAS,GAAG,MAAM,GAAG,QAAQ,GAAG,SAAS,GAAG,aAAa,GAAG,SAAS,CAAC,CAAC;AAM/G;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,SAAS,aAAa,EAAE,GAAG,MAAM,EAAE,CAS9E"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Finding identity (#5106). A report's `findings[].identity` and a SARIF
|
|
3
|
+
* result's `partialFingerprints` name a finding by what it is, so two audit
|
|
4
|
+
* runs over a base and a head can be compared without reading message text.
|
|
5
|
+
*
|
|
6
|
+
* The identity is a hash of the rule id, the file, the entity (the object's
|
|
7
|
+
* name or address), the diagnostic's `locator` (its place inside the object:
|
|
8
|
+
* kind, container index, path in the block), the fingerprint of a flagged
|
|
9
|
+
* secret, and the finding's order among findings that agree on all of those.
|
|
10
|
+
* `message` is not an input, so a name that only appears in the text of a
|
|
11
|
+
* message (a renamed container) does not change it. Renaming the object the
|
|
12
|
+
* entity names does change it.
|
|
13
|
+
*
|
|
14
|
+
* Not a cryptographic digest; it only has to tell findings apart.
|
|
15
|
+
*/
|
|
16
|
+
import { fingerprintSecret } from "./secrets.js";
|
|
17
|
+
/** The SARIF `partialFingerprints` key the identity is published under. */
|
|
18
|
+
export const IDENTITY_FINGERPRINT_KEY = "chantFindingIdentity/v1";
|
|
19
|
+
function baseKey(f) {
|
|
20
|
+
return [f.checkId, f.file, f.entity ?? "", f.missing ? `${f.missing.kind}@${f.missing.scope}` : "", f.locator ?? "", f.fingerprint ?? ""].join("\u0000");
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* One identity per finding, in the order given. Findings that agree on every
|
|
24
|
+
* input are told apart by their position among themselves, so the order the
|
|
25
|
+
* audit emitted them in must be the order passed here.
|
|
26
|
+
*/
|
|
27
|
+
export function findingIdentities(findings) {
|
|
28
|
+
const seen = new Map();
|
|
29
|
+
return findings.map((f) => {
|
|
30
|
+
const key = baseKey(f);
|
|
31
|
+
const n = seen.get(key) ?? 0;
|
|
32
|
+
seen.set(key, n + 1);
|
|
33
|
+
// Two 64-bit halves over differently salted inputs: 32 hex characters.
|
|
34
|
+
return fingerprintSecret(`${key}\u0000${n}`) + fingerprintSecret(`${n}\u0000${key}`);
|
|
35
|
+
});
|
|
36
|
+
}
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* Customization: a default template with `{{placeholder}}` slots, overridable
|
|
8
8
|
* via `template`, plus theme knobs (title, logo, accent, footer).
|
|
9
9
|
*/
|
|
10
|
-
import type { AuditFinding } from "./core.js";
|
|
10
|
+
import type { AuditFinding, AuditSkip } from "./core.js";
|
|
11
11
|
import { type AuditSnapshot, type BuildModelOptions } from "./report-model.js";
|
|
12
12
|
export type { AuditSnapshot } from "./report-model.js";
|
|
13
13
|
/** Customizable theme knobs filled into the template. */
|
|
@@ -31,6 +31,8 @@ export interface RenderHtmlOptions extends BuildModelOptions {
|
|
|
31
31
|
limit: number;
|
|
32
32
|
flag: string;
|
|
33
33
|
};
|
|
34
|
+
/** Lexicons skipped for want of a parser (#5083), carried into the embedded JSON report. */
|
|
35
|
+
skipped?: AuditSkip[];
|
|
34
36
|
}
|
|
35
37
|
/** Render an audit report as a self-contained HTML document. */
|
|
36
38
|
export declare function renderHtml(findings: AuditFinding[], opts?: RenderHtmlOptions): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"report-html.d.ts","sourceRoot":"","sources":["../../src/audit/report-html.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"report-html.d.ts","sourceRoot":"","sources":["../../src/audit/report-html.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAEtD,OAAO,EAAqC,KAAK,aAAa,EAAE,KAAK,iBAAiB,EAAoF,MAAM,gBAAgB,CAAC;AAEjM,YAAY,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAEpD,yDAAyD;AACzD,MAAM,WAAW,WAAW;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,0DAA0D;IAC1D,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,6BAA6B;IAC7B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,6CAA6C;IAC7C,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,iBAAkB,SAAQ,iBAAiB;IAC1D,QAAQ,CAAC,EAAE,aAAa,CAAC;IACzB,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,kGAAkG;IAClG,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,6EAA6E;IAC7E,SAAS,CAAC,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;IAC5C,4FAA4F;IAC5F,OAAO,CAAC,EAAE,SAAS,EAAE,CAAC;CACvB;AAwJD,gEAAgE;AAChE,wBAAgB,UAAU,CAAC,QAAQ,EAAE,YAAY,EAAE,EAAE,IAAI,GAAE,iBAAsB,GAAG,MAAM,CAoCzF"}
|
|
@@ -163,7 +163,7 @@ export function renderHtml(findings, opts = {}) {
|
|
|
163
163
|
const footer = theme.footer ?? DEFAULT_FOOTER;
|
|
164
164
|
// Machine-readable data embedded so the HTML report is also parseable.
|
|
165
165
|
// `<` escaped so the JSON can't break out of the <script> element.
|
|
166
|
-
const dataJson = JSON.stringify(buildReportJson(findings, { snapshot: opts.snapshot, truncated: opts.truncated }), null, 0).replace(/</g, "\\u003c");
|
|
166
|
+
const dataJson = JSON.stringify(buildReportJson(findings, { snapshot: opts.snapshot, truncated: opts.truncated, skipped: opts.skipped }), null, 0).replace(/</g, "\\u003c");
|
|
167
167
|
const dataScript = `<script type="application/json" id="chant-audit-report">${dataJson}</script>`;
|
|
168
168
|
let body;
|
|
169
169
|
if (model.counts.total === 0) {
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
import type { AuditFinding } from "./core.js";
|
|
8
8
|
import type { UnclaimedFile } from "./discover.js";
|
|
9
9
|
import { type Authority, type Category, type FixKind, type Lineage, type RuleMeta, type Tier } from "./catalog.js";
|
|
10
|
+
import type { AuditSkip } from "./core.js";
|
|
10
11
|
import { type ProveOptions } from "./proof.js";
|
|
11
12
|
import type { Severity } from "../lint/rule.js";
|
|
12
13
|
/**
|
|
@@ -19,6 +20,8 @@ export declare const REPORT_SCHEMA_VERSION = "1.0";
|
|
|
19
20
|
export declare const SEVERITY_WEIGHT: Record<Severity, number>;
|
|
20
21
|
export interface EnrichedFinding extends AuditFinding {
|
|
21
22
|
meta: RuleMeta;
|
|
23
|
+
/** Stable across runs while the defect is the same; see `identity.ts` (#5106). */
|
|
24
|
+
identity: string;
|
|
22
25
|
}
|
|
23
26
|
/** A per-file quick-win: a combined patch plus any findings still needing input. */
|
|
24
27
|
export interface QuickWinFile {
|
|
@@ -84,6 +87,12 @@ export interface SerializedFinding {
|
|
|
84
87
|
line?: number;
|
|
85
88
|
/** Redaction-safe fingerprint of a flagged value, when applicable (see `secrets.ts`). */
|
|
86
89
|
fingerprint?: string;
|
|
90
|
+
/**
|
|
91
|
+
* Names the finding across runs (#5106): the same value while the rule, file,
|
|
92
|
+
* object and place in the object stay the same, whatever the message says
|
|
93
|
+
* and wherever the finding sits among others. See `identity.ts`.
|
|
94
|
+
*/
|
|
95
|
+
identity: string;
|
|
87
96
|
/** Set when the finding is an absence rather than a defect — see `PostSynthDiagnostic.missing` (chant #2113). */
|
|
88
97
|
missing?: {
|
|
89
98
|
kind: string;
|
|
@@ -129,6 +138,12 @@ export interface AuditReportJson {
|
|
|
129
138
|
limit: number;
|
|
130
139
|
flag: string;
|
|
131
140
|
};
|
|
141
|
+
/**
|
|
142
|
+
* Lexicons whose files were found but not read, because an optional parser
|
|
143
|
+
* is not installed (#5083). A lexicon listed here has no findings because it
|
|
144
|
+
* was skipped, not because it is clean. Absent when every lexicon was read.
|
|
145
|
+
*/
|
|
146
|
+
skipped?: AuditSkip[];
|
|
132
147
|
}
|
|
133
148
|
export declare function metaFor(id: string, catalog?: Record<string, RuleMeta>): RuleMeta;
|
|
134
149
|
export declare function sortFindings(a: EnrichedFinding, b: EnrichedFinding): number;
|
|
@@ -154,5 +169,6 @@ export declare function buildReportJson(findings: AuditFinding[], opts?: {
|
|
|
154
169
|
limit: number;
|
|
155
170
|
flag: string;
|
|
156
171
|
};
|
|
172
|
+
skipped?: AuditSkip[];
|
|
157
173
|
}): AuditReportJson;
|
|
158
174
|
//# sourceMappingURL=report-model.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"report-model.d.ts","sourceRoot":"","sources":["../../src/audit/report-model.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAC3C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,EAA4B,KAAK,SAAS,EAAE,KAAK,QAAQ,EAAE,KAAK,OAAO,EAAE,KAAK,OAAO,EAAE,KAAK,QAAQ,EAAE,KAAK,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1I,OAAO,EAAyB,KAAK,YAAY,EAAE,MAAM,SAAS,CAAC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severity counts.
|
|
6
6
|
*/
|
|
7
7
|
import { RULE_CATALOG, ruleDocUrl } from "./catalog.js";
|
|
8
|
+
import { findingIdentities } from "./identity.js";
|
|
8
9
|
import { proveFix, unifiedDiff } from "./proof.js";
|
|
9
10
|
/**
|
|
10
11
|
* Version of the machine-readable JSON report. Stability contract: additive
|
|
@@ -116,7 +117,8 @@ function buildClusters(findings) {
|
|
|
116
117
|
/** Build the structured report model from raw findings. */
|
|
117
118
|
export function buildReportModel(findings, opts = {}) {
|
|
118
119
|
const catalog = opts.catalog ?? RULE_CATALOG;
|
|
119
|
-
const
|
|
120
|
+
const identities = findingIdentities(findings);
|
|
121
|
+
const enriched = findings.map((f, i) => ({ ...f, identity: identities[i], meta: metaFor(f.checkId, catalog) }));
|
|
120
122
|
const contents = new Map((opts.files ?? []).map((f) => [f.path, f.content]));
|
|
121
123
|
const mergeWorthy = enriched.filter((f) => f.meta.tier === "merge-worthy");
|
|
122
124
|
// A deterministic fix is a quick win whatever the finding's tier. Every
|
|
@@ -181,6 +183,7 @@ export function buildReportJson(findings, opts = {}) {
|
|
|
181
183
|
entity: f.entity,
|
|
182
184
|
line: f.line,
|
|
183
185
|
fingerprint: f.fingerprint,
|
|
186
|
+
identity: f.identity,
|
|
184
187
|
missing: f.missing,
|
|
185
188
|
lexicon: f.lexicon,
|
|
186
189
|
tier: f.meta.tier,
|
|
@@ -194,5 +197,6 @@ export function buildReportJson(findings, opts = {}) {
|
|
|
194
197
|
})),
|
|
195
198
|
unclaimed: opts.unclaimed && opts.unclaimed.length > 0 ? opts.unclaimed : undefined,
|
|
196
199
|
truncated: opts.truncated,
|
|
200
|
+
skipped: opts.skipped && opts.skipped.length > 0 ? opts.skipped : undefined,
|
|
197
201
|
};
|
|
198
202
|
}
|
package/dist/ci-agent.d.ts
CHANGED
|
@@ -32,6 +32,7 @@
|
|
|
32
32
|
*
|
|
33
33
|
* Nothing here applies, approves, unlocks or merges.
|
|
34
34
|
*/
|
|
35
|
+
import { type CommentAllow, type CommentAllowReads } from "./ci-comment-allow.js";
|
|
35
36
|
import { type CiProductWords } from "./ci-product-words.js";
|
|
36
37
|
import type { OpRunRecord, OpRunRecordInput } from "./op/runtime.js";
|
|
37
38
|
import type { RunOrigin } from "./lifecycle/release-ledger.js";
|
|
@@ -85,6 +86,16 @@ export interface OpAgentSpec {
|
|
|
85
86
|
branch?: string;
|
|
86
87
|
/** The ledger environment the runs are recorded under. Default `local`, the rule every Op follows (#4551 ruling A). */
|
|
87
88
|
env?: string;
|
|
89
|
+
/**
|
|
90
|
+
* Who may ask, beyond write access, for `on: "comment"` (INTENTIUS/terragucci#1461,
|
|
91
|
+
* `./ci-comment-allow.ts`): the map's `agent` list, else its `default`. The
|
|
92
|
+
* generated job carries it as `CHANT_COMMENT_ALLOW`, so it is read from the
|
|
93
|
+
* workflow on the default branch. GitHub and Forgejo only; a team on
|
|
94
|
+
* another forge fails closed.
|
|
95
|
+
*/
|
|
96
|
+
commentAllow?: CommentAllow;
|
|
97
|
+
/** The secret that holds the token team membership is read with, for `commentAllow`. Default: the job's token. */
|
|
98
|
+
commentAllowTokenEnv?: string;
|
|
88
99
|
}
|
|
89
100
|
/** An agent's settings, every default filled and checked. */
|
|
90
101
|
export interface AgentSettings {
|
|
@@ -100,6 +111,10 @@ export interface AgentSettings {
|
|
|
100
111
|
guarded: string[];
|
|
101
112
|
branch?: string;
|
|
102
113
|
env: string;
|
|
114
|
+
/** See {@link OpAgentSpec.commentAllow}. */
|
|
115
|
+
commentAllow?: CommentAllow;
|
|
116
|
+
/** See {@link OpAgentSpec.commentAllowTokenEnv}. */
|
|
117
|
+
commentAllowTokenEnv?: string;
|
|
103
118
|
}
|
|
104
119
|
/** The Claude Code release the default agent command runs (terragucci's pin, as the review agent's). */
|
|
105
120
|
export declare const AGENT_CLAUDE_CODE_VERSION = "2.1.290";
|
|
@@ -286,6 +301,8 @@ export interface PrepareInput {
|
|
|
286
301
|
event?: unknown;
|
|
287
302
|
/** A read client: who may write, and the pull request's head. */
|
|
288
303
|
forge?: Pick<PrForge, "pullRequestHead" | "userCanWrite">;
|
|
304
|
+
/** With `settings.commentAllow` (INTENTIUS/terragucci#1461): the reads of a token that can read teams. Absent: a list that names a team fails closed. */
|
|
305
|
+
teams?: CommentAllowReads;
|
|
289
306
|
/** The agent's earlier run records on the ledger. */
|
|
290
307
|
readRuns: () => Promise<OpRunRecord[]>;
|
|
291
308
|
git: AgentGit;
|
package/dist/ci-agent.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ci-agent.d.ts","sourceRoot":"","sources":["../src/ci-agent.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAOH,OAAO,EAAuB,KAAK,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAE9E,OAAO,KAAK,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAClE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAE1C,kIAAkI;AAClI,eAAO,MAAM,cAAc,aAAa,CAAC;AAEzC,gCAAgC;AAChC,MAAM,MAAM,YAAY,GAAG,SAAS,GAAG,OAAO,CAAC;AAC/C,eAAO,MAAM,cAAc,EAAE,SAAS,YAAY,EAAyB,CAAC;AAE5E;;;;;GAKG;AACH,MAAM,MAAM,eAAe,GAAG,YAAY,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;AAE3D;;;;;;GAMG;AACH,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,YAAY,CAAC;IACjB,8EAA8E;IAC9E,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,wGAAwG;IACxG,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,iHAAiH;IACjH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,0EAA0E;IAC1E,OAAO,CAAC,EAAE,MA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,WAAW,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,SAAS,CAAC;CACvB,GAAG,gBAAgB,CAgCnB;AAID;;;;;GAKG;AACH,wBAAsB,eAAe,CAAC,CAAC,EAAE,SAAS,GAAG,OAAO,CAAC,WAAW,CAAC,CAwKxE;AAID;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,QAAQ,GAAG,QAAQ,GAAG,SAAS,EAAE,GAAG,CAAC,EAAE,MAAM,EAAE,GAAG,GAAE,MAAkB,GAAG;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAO/J;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,gBAAgB,GAAG,QAAQ,GAAG,MAAM,EAAE,CAO/F;AAED,+HAA+H;AAC/H,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,QAAQ,GAAG,QAAQ,GAAG,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,GAAE,MAAuB,GAAG,MAAM,CAI/H"}
|
package/dist/ci-agent.js
CHANGED
|
@@ -37,6 +37,7 @@ import { spawn } from "node:child_process";
|
|
|
37
37
|
import { existsSync, mkdirSync, readFileSync, statSync, writeFileSync } from "node:fs";
|
|
38
38
|
import { join } from "node:path";
|
|
39
39
|
import { CHANT_EXIT } from "./exit-codes.js";
|
|
40
|
+
import { COMMENT_ALLOW_ENV, commentAllowFromEnv, commentAllowProblems, decideCommentAllow } from "./ci-comment-allow.js";
|
|
40
41
|
import { parseProductComment } from "./ci-product-words.js";
|
|
41
42
|
import { quoted } from "./op/activities/review-agent.js";
|
|
42
43
|
/** The first chant with the agent job and the scheduled Op spec's `agent` and `runner` (#4616). Products feature-detect on it. */
|
|
@@ -165,6 +166,13 @@ export function resolveAgentSpec(name, spec, product = "chant") {
|
|
|
165
166
|
const env = spec.env ?? "local";
|
|
166
167
|
if (!NAME.test(env))
|
|
167
168
|
throw new AgentError(`${where}: env is a ledger environment name`);
|
|
169
|
+
if (spec.commentAllow !== undefined) {
|
|
170
|
+
const problems = commentAllowProblems(spec.commentAllow, `${where}: commentAllow`);
|
|
171
|
+
if (problems.length > 0)
|
|
172
|
+
throw new AgentError(problems.join("; "));
|
|
173
|
+
}
|
|
174
|
+
if (spec.commentAllowTokenEnv !== undefined && !VAR.test(spec.commentAllowTokenEnv))
|
|
175
|
+
throw new AgentError(`${where}: commentAllowTokenEnv is a variable name`);
|
|
168
176
|
return {
|
|
169
177
|
name,
|
|
170
178
|
on: spec.on,
|
|
@@ -178,6 +186,8 @@ export function resolveAgentSpec(name, spec, product = "chant") {
|
|
|
178
186
|
guarded: [...guarded],
|
|
179
187
|
...(branch !== undefined ? { branch } : {}),
|
|
180
188
|
env,
|
|
189
|
+
...(spec.commentAllow !== undefined ? { commentAllow: spec.commentAllow } : {}),
|
|
190
|
+
...(spec.commentAllowTokenEnv !== undefined ? { commentAllowTokenEnv: spec.commentAllowTokenEnv } : {}),
|
|
181
191
|
};
|
|
182
192
|
}
|
|
183
193
|
/** The settings as the generated jobs' variables. */
|
|
@@ -195,6 +205,7 @@ export function agentSettingsEnv(s) {
|
|
|
195
205
|
...(s.guarded.length > 0 ? { [AGENT_ENV.guarded]: JSON.stringify(s.guarded) } : {}),
|
|
196
206
|
...(s.branch ? { [AGENT_ENV.branch]: s.branch } : {}),
|
|
197
207
|
[AGENT_ENV.env]: s.env,
|
|
208
|
+
...(s.commentAllow ? { [COMMENT_ALLOW_ENV]: JSON.stringify(s.commentAllow) } : {}),
|
|
198
209
|
};
|
|
199
210
|
}
|
|
200
211
|
/** The settings back from the job's variables, checked as {@link resolveAgentSpec} checks a spec. */
|
|
@@ -243,6 +254,15 @@ export function agentSettingsFromEnv(env, product = "chant") {
|
|
|
243
254
|
...(env[AGENT_ENV.branch] ? { branch: env[AGENT_ENV.branch] } : {}),
|
|
244
255
|
...(env[AGENT_ENV.env] ? { env: env[AGENT_ENV.env] } : {}),
|
|
245
256
|
};
|
|
257
|
+
let commentAllow;
|
|
258
|
+
try {
|
|
259
|
+
commentAllow = commentAllowFromEnv(env[COMMENT_ALLOW_ENV]);
|
|
260
|
+
}
|
|
261
|
+
catch (e) {
|
|
262
|
+
throw new AgentError(e.message);
|
|
263
|
+
}
|
|
264
|
+
if (commentAllow)
|
|
265
|
+
spec.commentAllow = commentAllow;
|
|
246
266
|
return resolveAgentSpec(name, spec, product);
|
|
247
267
|
}
|
|
248
268
|
// ── what an agent may change ───────────────────────────────────────────────
|
|
@@ -501,6 +521,18 @@ export async function prepareAgentRun(i) {
|
|
|
501
521
|
// GitHub's job condition already asks for a writer; Forgejo's runner has no author association, so the forge is asked.
|
|
502
522
|
if (i.forge?.userCanWrite && !(await i.forge.userCanWrite(ask.user)))
|
|
503
523
|
return no(`${ask.user} cannot write to the repository, so the agent does not run for them`, { pr: ask.pr });
|
|
524
|
+
// INTENTIUS/terragucci#1461: the pipeline's list, from the workflow on the default branch.
|
|
525
|
+
if (i.settings.commentAllow) {
|
|
526
|
+
let decision;
|
|
527
|
+
try {
|
|
528
|
+
decision = await decideCommentAllow(i.settings.commentAllow, "agent", ask.user, i.teams);
|
|
529
|
+
}
|
|
530
|
+
catch (e) {
|
|
531
|
+
return no(`could not check who may ask the agent (${errText(e)}), so it does not run`, { pr: ask.pr });
|
|
532
|
+
}
|
|
533
|
+
if (!decision.ok)
|
|
534
|
+
return no(decision.reason, { pr: ask.pr });
|
|
535
|
+
}
|
|
504
536
|
}
|
|
505
537
|
let records = [];
|
|
506
538
|
try {
|