@vaultcompass/conductor 0.11.0 → 0.13.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 +113 -13
- package/dist/cli.js +28 -2
- package/dist/envelope.d.ts +7 -1
- package/dist/gate-runner.d.ts +66 -10
- package/dist/gate-runner.js +271 -23
- package/dist/normalize.js +28 -3
- package/dist/osv-baseline.d.ts +74 -0
- package/dist/osv-baseline.js +138 -2
- package/dist/osv-coverage.d.ts +18 -2
- package/dist/osv-coverage.js +47 -10
- package/dist/output-sarif.js +37 -0
- package/dist/output-text.d.ts +23 -7
- package/dist/output-text.js +72 -12
- package/dist/products.d.ts +47 -0
- package/dist/products.js +64 -28
- package/dist/run.js +6 -4
- package/dist/unread-manifests.js +4 -0
- package/package.json +1 -1
package/dist/gate-runner.js
CHANGED
|
@@ -25,8 +25,8 @@ import { runGit } from './git.js';
|
|
|
25
25
|
import { NormalizeError } from './envelope.js';
|
|
26
26
|
import { describeLockfiles, normalizeDepGuard, normalizeFailedGate, normalizeGitleaks, normalizeIntentGuard, normalizeMisconfiguredGate, normalizeMissingGate, normalizeOsvScanner, normalizeUnparseableGate, normalizeVaultGuard, } from './normalize.js';
|
|
27
27
|
import { renderOptionFlags } from './policy.js';
|
|
28
|
-
import { NO_RESOLVE_OVERRIDDEN, emptiedLockfiles, noLongerScanned, nothingScannableMessage, notScannedDetail, selectOsvInputs, } from './osv-coverage.js';
|
|
29
|
-
import { compareWithBase, comparisonFailed, } from './osv-baseline.js';
|
|
28
|
+
import { NO_RESOLVE_OVERRIDDEN, emptiedLockfiles, noLongerScanned, noLongerScannedFiles, nothingScannableMessage, notScannedDetail, packageCounts, selectOsvInputs, } from './osv-coverage.js';
|
|
29
|
+
import { checkEmptiedAgainstBase, compareWithBase, comparisonFailed, } from './osv-baseline.js';
|
|
30
30
|
import { ExternalConfigError, materializeExternalConfig, nestedConfigProposals, } from './external-config.js';
|
|
31
31
|
import { osvLockfileKind, profileFor } from './products.js';
|
|
32
32
|
import { unreadManifestsNote } from './unread-manifests.js';
|
|
@@ -82,7 +82,40 @@ export const CONDUCTOR_OWN_REASONS = new Set([
|
|
|
82
82
|
'gate-version-unsupported',
|
|
83
83
|
'history-shallow',
|
|
84
84
|
'timed-out',
|
|
85
|
+
'lockfile-emptied',
|
|
86
|
+
'lockfile-emptied-unverified',
|
|
87
|
+
'version-skew',
|
|
88
|
+
'version-unverified',
|
|
85
89
|
]);
|
|
90
|
+
/**
|
|
91
|
+
* A probed version as it may be printed. The probe for the family gates
|
|
92
|
+
* accepts anything after x.y.z on the first line, and the text reaches a
|
|
93
|
+
* workflow command, the step summary and the reports, so only version
|
|
94
|
+
* characters are kept.
|
|
95
|
+
*/
|
|
96
|
+
export function versionCharacters(raw) {
|
|
97
|
+
return raw.replace(/[^0-9A-Za-z.+-]/g, '').slice(0, 64);
|
|
98
|
+
}
|
|
99
|
+
/** Where a resolved binary came from, in words. Never a machine path. */
|
|
100
|
+
export function resolutionPlace(source) {
|
|
101
|
+
return source === 'node_modules' ? 'node_modules/.bin' : source === 'path' ? 'PATH' : 'the policy command';
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* The remedy for a gate that is not at the expected version, which depends
|
|
105
|
+
* on where the binary came from. THE ONE PLACE it is written: the
|
|
106
|
+
* could-not-run detail and every version-skew line in src/output-text.ts
|
|
107
|
+
* call this.
|
|
108
|
+
*/
|
|
109
|
+
export function versionSkewRemedy(product, source, expected) {
|
|
110
|
+
if (source === 'node_modules') {
|
|
111
|
+
return (`Fix: bump or remove the repository's own ${product} devDependency. node_modules/.bin outranks ` +
|
|
112
|
+
"PATH outside a pull request, so on a push run it shadows the action's install.");
|
|
113
|
+
}
|
|
114
|
+
if (source === 'path') {
|
|
115
|
+
return `Fix: remove the other ${product} from PATH, or install ${expected}.`;
|
|
116
|
+
}
|
|
117
|
+
return `Fix: point the policy command at ${product} ${expected}, or remove the command override.`;
|
|
118
|
+
}
|
|
86
119
|
/**
|
|
87
120
|
* A gate's time limit, and where it came from. THE ONE PLACE the precedence
|
|
88
121
|
* is written: the test hook (`RunGateOptions.timeoutMs`, which no CLI path
|
|
@@ -150,6 +183,11 @@ function timedOutDetail(gate, step, limit, elapsedMs, trustBase) {
|
|
|
150
183
|
return (`the version probe of ${gate.product} was stopped at ${limitSeconds} s (${where}), so the gate ` +
|
|
151
184
|
'was not run and nothing was checked by it.');
|
|
152
185
|
}
|
|
186
|
+
if (step === 'base-check') {
|
|
187
|
+
return (`${gate.product}'s check of the base copies of the lockfiles this pull request emptied was stopped ` +
|
|
188
|
+
`after ${elapsedSeconds} s, at what was left of its ${limitSeconds} s limit (${where}) after the ` +
|
|
189
|
+
`head scan, so the dependencies the pull request removed were not judged. ${remedies}`);
|
|
190
|
+
}
|
|
153
191
|
const what = step === 'scan'
|
|
154
192
|
? `${gate.product} was stopped after ${elapsedSeconds} s, at its ${limitSeconds} s limit (${where}), ` +
|
|
155
193
|
'so nothing was checked by it.'
|
|
@@ -195,6 +233,18 @@ export function cleanOutputLine(raw) {
|
|
|
195
233
|
/** A zerolog line at one level: gitleaks' "<time> ERR ..." shape. */
|
|
196
234
|
const ZEROLOG_ERR = /^\S+\s+ERR\s/;
|
|
197
235
|
const ZEROLOG_WRN = /^\S+\s+WRN\s/;
|
|
236
|
+
/**
|
|
237
|
+
* osv-scanner 2.4.0's progress lines, which come before its error on every
|
|
238
|
+
* run (tests/fixtures/stated-reason-captures.json, audit 2026-10-18 N4): the
|
|
239
|
+
* walk banner, one "Scanned <file> file and found N package(s)" per file
|
|
240
|
+
* read, and the "End status:" counters. Quoting the banner as "gate said"
|
|
241
|
+
* was noise on every osv could-not-run.
|
|
242
|
+
*/
|
|
243
|
+
const OSV_PROGRESS = [
|
|
244
|
+
/^Starting filesystem walk for root: /,
|
|
245
|
+
/^Scanned .+ file and found \d+ packages?$/,
|
|
246
|
+
/^End status: /,
|
|
247
|
+
];
|
|
198
248
|
function plainLine(raw) {
|
|
199
249
|
return raw.replace(/[^\x20-\x7e]/g, ' ').replace(/\s+/g, ' ').trim();
|
|
200
250
|
}
|
|
@@ -209,7 +259,8 @@ function plainLine(raw) {
|
|
|
209
259
|
* 2. Informational lines are never chosen: a `note:` line and every
|
|
210
260
|
* following indented line (a BLANK line ends the note block, so an
|
|
211
261
|
* indented reason after it is not swallowed), and gitleaks' two
|
|
212
|
-
* rename-detection warnings
|
|
262
|
+
* rename-detection warnings, and osv-scanner's progress lines
|
|
263
|
+
* (OSV_PROGRESS).
|
|
213
264
|
* 3. A marker wins: the first remaining INCOMPLETE: or zerolog ERR line,
|
|
214
265
|
* joined with the indented lines after it, skipping blank lines, up to
|
|
215
266
|
* the first non-blank line that is not indented.
|
|
@@ -234,6 +285,9 @@ function statedReasonFromStderr(stderr) {
|
|
|
234
285
|
(line.text.includes('rename detection was skipped') || line.text.includes('diff.renameLimit'))) {
|
|
235
286
|
line.informational = true;
|
|
236
287
|
}
|
|
288
|
+
else if (OSV_PROGRESS.some((pattern) => pattern.test(line.text))) {
|
|
289
|
+
line.informational = true;
|
|
290
|
+
}
|
|
237
291
|
}
|
|
238
292
|
const candidate = (line) => !line.blank && !line.informational && line.text !== '';
|
|
239
293
|
const markerAt = lines.findIndex((line) => candidate(line) && (line.text.startsWith('INCOMPLETE:') || ZEROLOG_ERR.test(line.text)));
|
|
@@ -1142,13 +1196,15 @@ function runGateInner(gate, options, started, progress) {
|
|
|
1142
1196
|
// would read as trust-base-unverified, a packaging problem that does not
|
|
1143
1197
|
// exist), and a local run does not go on to scan with the version
|
|
1144
1198
|
// unknown. Enforced under a trust base, like trust-base-unverified: the
|
|
1145
|
-
// gate could not be placed inside the boundary.
|
|
1199
|
+
// gate could not be placed inside the boundary. Enforced under the
|
|
1200
|
+
// Action's expected-version signal too, like version-unverified: the run
|
|
1201
|
+
// cannot show this is the pinned build.
|
|
1146
1202
|
const detail = timedOutDetail(gate, 'version-probe', timeLimit, probed.elapsedMs, options.trustBase);
|
|
1147
1203
|
const timedOut = timedOutRecord('version-probe', timeLimit, probed.elapsedMs, probed.signal);
|
|
1148
1204
|
return {
|
|
1149
1205
|
...base,
|
|
1150
1206
|
binary,
|
|
1151
|
-
enforce: options.trustBase !== undefined ? true : gate.enforce,
|
|
1207
|
+
enforce: options.trustBase !== undefined || options.expectedVersion !== undefined ? true : gate.enforce,
|
|
1152
1208
|
durationMs: Date.now() - started,
|
|
1153
1209
|
exitCode: null,
|
|
1154
1210
|
couldNotRun: { reason: 'timed-out', detail, timedOut },
|
|
@@ -1158,16 +1214,54 @@ function runGateInner(gate, options, started, progress) {
|
|
|
1158
1214
|
};
|
|
1159
1215
|
}
|
|
1160
1216
|
const version = probed.kind === 'version' ? probed.value : null;
|
|
1161
|
-
//
|
|
1162
|
-
//
|
|
1163
|
-
//
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1217
|
+
// THE EXPECTED VERSION (0.13.0, design
|
|
1218
|
+
// docs/superpowers/specs/2026-10-18-version-skew-could-not-run.md). When
|
|
1219
|
+
// the run was told which version must judge it (the Action's pin), a
|
|
1220
|
+
// binary at another version, or one whose version cannot be read, is
|
|
1221
|
+
// could-not-run, from whichever location resolution took it
|
|
1222
|
+
// (node_modules/.bin, PATH or a policy command). Resolution itself is
|
|
1223
|
+
// unchanged. Here, right after the probe and before the command-line floor
|
|
1224
|
+
// and decideTrustBase, so nothing past the probe runs. ENFORCED whatever
|
|
1225
|
+
// the policy says, like a refused program: the gate produced no verdict for
|
|
1226
|
+
// `enforce: false` to be a decision about. No expectation (every plain run)
|
|
1227
|
+
// skips all of this.
|
|
1228
|
+
if (options.expectedVersion !== undefined && version !== options.expectedVersion) {
|
|
1229
|
+
const expected = options.expectedVersion;
|
|
1230
|
+
const relative = path.relative(options.repoRoot, binary.program);
|
|
1231
|
+
const inside = relative !== '' && relative !== '..' && !relative.startsWith(`..${path.sep}`) && !path.isAbsolute(relative);
|
|
1232
|
+
// Repository-relative inside the repository; outside it, words only,
|
|
1233
|
+
// because this detail reaches the reports and a published log.
|
|
1234
|
+
const place = binary.source === 'node_modules' && inside ? relative : resolutionPlace(binary.source);
|
|
1235
|
+
const remedy = versionSkewRemedy(gate.product, binary.source, expected);
|
|
1236
|
+
const pinned = `${expected} (the version the action pinned)`;
|
|
1237
|
+
const detail = version === null
|
|
1238
|
+
? `${gate.product} did not run: the version of the build resolved from ${place} could not be read, ` +
|
|
1239
|
+
`so it is not known to be ${pinned}. ${remedy}`
|
|
1240
|
+
: `${gate.product} did not run: the build resolved from ${place} reports version ` +
|
|
1241
|
+
`${versionCharacters(version)}, but this run expects ${pinned}. ${remedy}`;
|
|
1242
|
+
return {
|
|
1243
|
+
...base,
|
|
1244
|
+
...(version === null
|
|
1245
|
+
? {}
|
|
1246
|
+
: {
|
|
1247
|
+
// Kept for the job-log line, the annotation, the step summary,
|
|
1248
|
+
// the text report line and the SARIF note that 0.12.0 printed.
|
|
1249
|
+
versionSkew: {
|
|
1250
|
+
expected,
|
|
1251
|
+
found: version,
|
|
1252
|
+
source: binary.source,
|
|
1253
|
+
path: inside ? relative : binary.program,
|
|
1254
|
+
},
|
|
1255
|
+
}),
|
|
1256
|
+
productVersion: version,
|
|
1257
|
+
binary,
|
|
1258
|
+
enforce: true,
|
|
1259
|
+
durationMs: Date.now() - started,
|
|
1260
|
+
couldNotRun: { reason: version === null ? 'version-unverified' : 'version-skew', detail },
|
|
1261
|
+
findings: [normalizeFailedGate(gate.role, gate.product, detail)],
|
|
1262
|
+
run: EMPTY_RUN,
|
|
1263
|
+
diagnostics: [],
|
|
1264
|
+
};
|
|
1171
1265
|
}
|
|
1172
1266
|
// The command-line floor. Only the external tools have one: the umbrella
|
|
1173
1267
|
// writes flags they grew at a known release (gitleaks' git subcommand,
|
|
@@ -1300,6 +1394,94 @@ function spawnAndRead(ctx) {
|
|
|
1300
1394
|
// notes. Carried onto every outcome from here on that reports a scan.
|
|
1301
1395
|
let selection = null;
|
|
1302
1396
|
const selectionDiagnostics = [];
|
|
1397
|
+
// On a decided trust base, the base lockfiles the head deleted or moved:
|
|
1398
|
+
// candidates for the emptied-lockfile base check below. Null when the base
|
|
1399
|
+
// tree could not be listed, which that check reads as unverified.
|
|
1400
|
+
let removedLockfiles = [];
|
|
1401
|
+
// THE EMPTIED-LOCKFILE BASE CHECK (audit 2026-10-18 N1, design
|
|
1402
|
+
// docs/superpowers/specs/2026-10-18-emptied-lockfile-under-trust-base.md).
|
|
1403
|
+
// Only on a decided trust base and only for the vulnerabilities gate. The
|
|
1404
|
+
// candidates are the emptied handed lockfiles plus the base lockfiles the
|
|
1405
|
+
// head deleted or moved. Called after a completed head scan (every head
|
|
1406
|
+
// could-not-run returns first), or, when nothing at all was handed, in its
|
|
1407
|
+
// place. Returns the could-not-run outcome, or null when the head result
|
|
1408
|
+
// stands. `headArgv` null means no head run, so there is no command line
|
|
1409
|
+
// to hold the base one against.
|
|
1410
|
+
const removalCheck = (input) => {
|
|
1411
|
+
if (gate.product !== 'osv-scanner' || decidedRef === undefined) {
|
|
1412
|
+
return null;
|
|
1413
|
+
}
|
|
1414
|
+
const removed = removedLockfiles;
|
|
1415
|
+
if (input.emptied.length === 0 && removed !== null && removed.length === 0) {
|
|
1416
|
+
return null;
|
|
1417
|
+
}
|
|
1418
|
+
const baseArgv = (copies) => [
|
|
1419
|
+
...binary.argvPrefix,
|
|
1420
|
+
...gateArgs(gate, options.staged, options.intent, decidedRef, { ...external, lockfiles: [...copies] }),
|
|
1421
|
+
];
|
|
1422
|
+
const checked = removed === null
|
|
1423
|
+
? { kind: 'unverified', detail: `the base tree at ${decidedRef} could not be listed` }
|
|
1424
|
+
: workDir === null
|
|
1425
|
+
? { kind: 'unverified', detail: 'there is no work directory to hold the base copies' }
|
|
1426
|
+
: checkEmptiedAgainstBase({
|
|
1427
|
+
repoRoot: options.repoRoot,
|
|
1428
|
+
ref: decidedRef,
|
|
1429
|
+
workDir,
|
|
1430
|
+
emptied: input.emptied,
|
|
1431
|
+
removed,
|
|
1432
|
+
headCounts: input.headCounts,
|
|
1433
|
+
headArgv: input.headArgv,
|
|
1434
|
+
baseArgv,
|
|
1435
|
+
budgetMs: input.budgetMs,
|
|
1436
|
+
spawn: (argv, cwd, budget) => {
|
|
1437
|
+
const baseChild = spawnSync(binary.command, [...argv], {
|
|
1438
|
+
cwd,
|
|
1439
|
+
encoding: 'utf8',
|
|
1440
|
+
timeout: budget,
|
|
1441
|
+
maxBuffer: 64 * 1024 * 1024,
|
|
1442
|
+
});
|
|
1443
|
+
return {
|
|
1444
|
+
status: baseChild.status,
|
|
1445
|
+
stderr: stripAnsi(baseChild.stderr ?? ''),
|
|
1446
|
+
failure: spawnFailure(baseChild),
|
|
1447
|
+
};
|
|
1448
|
+
},
|
|
1449
|
+
});
|
|
1450
|
+
if (checked.kind === 'clear') {
|
|
1451
|
+
return null;
|
|
1452
|
+
}
|
|
1453
|
+
const done = { ...input.outcome, durationMs: Date.now() - started };
|
|
1454
|
+
if (checked.kind === 'timed-out') {
|
|
1455
|
+
const detail = timedOutDetail(gate, 'base-check', timeLimit, checked.elapsedMs, options.trustBase);
|
|
1456
|
+
const timedOut = timedOutRecord('base-check', timeLimit, checked.elapsedMs, checked.signal);
|
|
1457
|
+
return {
|
|
1458
|
+
...done,
|
|
1459
|
+
couldNotRun: { reason: 'timed-out', detail, timedOut },
|
|
1460
|
+
findings: [timedOutFinding(gate, detail, timedOut)],
|
|
1461
|
+
run: EMPTY_RUN,
|
|
1462
|
+
diagnostics: [],
|
|
1463
|
+
};
|
|
1464
|
+
}
|
|
1465
|
+
const named = [...new Set([...input.emptied, ...(removed ?? [])])];
|
|
1466
|
+
const detail = checked.kind === 'emptied'
|
|
1467
|
+
? `${checked.files
|
|
1468
|
+
.map((entry) => entry.removed
|
|
1469
|
+
? `${entry.path} is not in this pull request but had ${entry.packages} package(s) at the base (${decidedRef})`
|
|
1470
|
+
: `${entry.path} read no packages at the head but ${entry.packages} at the base (${decidedRef})`)
|
|
1471
|
+
.join('; ')}, so the dependencies this pull request removed cannot be judged. Regenerate the ` +
|
|
1472
|
+
'lockfile, or add its replacement beside the same manifest in this pull request, or remove ' +
|
|
1473
|
+
"the manifest's dependencies with it."
|
|
1474
|
+
: `${named.join(', ')} ${named.length === 1 ? 'was' : 'were'} emptied, deleted or moved by this pull ` +
|
|
1475
|
+
`request, and the check that the base had no packages there could not be completed: ` +
|
|
1476
|
+
`${checked.detail}. Nothing the pull request removed was judged.`;
|
|
1477
|
+
return {
|
|
1478
|
+
...done,
|
|
1479
|
+
couldNotRun: { reason: checked.kind === 'emptied' ? 'lockfile-emptied' : 'lockfile-emptied-unverified', detail },
|
|
1480
|
+
findings: [normalizeFailedGate(gate.role, gate.product, detail)],
|
|
1481
|
+
run: EMPTY_RUN,
|
|
1482
|
+
diagnostics: [],
|
|
1483
|
+
};
|
|
1484
|
+
};
|
|
1303
1485
|
// Tracked manifests this gate was NOT handed, when it was handed others
|
|
1304
1486
|
// (review of 1b.2, item 5): a run note, so a Podfile.lock beside a scanned
|
|
1305
1487
|
// mix.lock is named without pushing a clean run off its one-line summary.
|
|
@@ -1355,6 +1537,7 @@ function spawnAndRead(ctx) {
|
|
|
1355
1537
|
selectionDiagnostics.push(...selection.diagnostics);
|
|
1356
1538
|
if (decidedRef !== undefined) {
|
|
1357
1539
|
selectionDiagnostics.push(...noLongerScanned(options.repoRoot, decidedRef, new Set(tracked)));
|
|
1540
|
+
removedLockfiles = noLongerScannedFiles(options.repoRoot, decidedRef, new Set(tracked));
|
|
1358
1541
|
}
|
|
1359
1542
|
if (external.lockfiles.length > 0) {
|
|
1360
1543
|
const unread = unreadManifestsNote(tracked, new Set(selection.handed), gate.product);
|
|
@@ -1365,6 +1548,25 @@ function spawnAndRead(ctx) {
|
|
|
1365
1548
|
// without spawning it. The verdict is unchanged (clean); what changes is
|
|
1366
1549
|
// what is said: which requirements files the pin check left out, and
|
|
1367
1550
|
// which tracked manifests were not handed to this scanner.
|
|
1551
|
+
// Every lockfile the base had may have been deleted: on a trust base
|
|
1552
|
+
// the removed ones are still checked, with no head scan to precede
|
|
1553
|
+
// it, so the whole limit is the budget.
|
|
1554
|
+
const removedOutcome = removalCheck({
|
|
1555
|
+
emptied: [],
|
|
1556
|
+
headCounts: new Map(),
|
|
1557
|
+
headArgv: null,
|
|
1558
|
+
budgetMs: timeoutMs,
|
|
1559
|
+
outcome: {
|
|
1560
|
+
...base,
|
|
1561
|
+
productVersion: version,
|
|
1562
|
+
binary,
|
|
1563
|
+
...(trustBase === undefined ? {} : { trustBase }),
|
|
1564
|
+
exitCode: null,
|
|
1565
|
+
},
|
|
1566
|
+
});
|
|
1567
|
+
if (removedOutcome !== null) {
|
|
1568
|
+
return removedOutcome;
|
|
1569
|
+
}
|
|
1368
1570
|
const unread = unreadManifestsNote(tracked, new Set(selection.handed), gate.product);
|
|
1369
1571
|
const cleanBecause = 'the verdict is clean because there was nothing to read, not because a scan found nothing.';
|
|
1370
1572
|
return {
|
|
@@ -1517,6 +1719,15 @@ function spawnAndRead(ctx) {
|
|
|
1517
1719
|
// Keep the backstop's view current, so an unexpected throw below still
|
|
1518
1720
|
// reports which binary ran and what it printed.
|
|
1519
1721
|
Object.assign(progress, withRun);
|
|
1722
|
+
// The emptied-lockfile base check after a completed head scan, under what
|
|
1723
|
+
// is left of the limit (removalCheck, above).
|
|
1724
|
+
const emptiedOnBase = (emptied, headCounts, exitCode) => removalCheck({
|
|
1725
|
+
emptied,
|
|
1726
|
+
headCounts,
|
|
1727
|
+
headArgv: argv,
|
|
1728
|
+
budgetMs: timeoutMs - (Date.now() - spawnStarted),
|
|
1729
|
+
outcome: { ...withRun, exitCode },
|
|
1730
|
+
});
|
|
1520
1731
|
// THE FIRST THING READ after spawnSync returns, ahead of every status,
|
|
1521
1732
|
// signal, report and stdout check, and it returns for every error. A child
|
|
1522
1733
|
// stopped at the limit that handled SIGTERM can come back with status 0, or
|
|
@@ -1556,6 +1767,12 @@ function spawnAndRead(ctx) {
|
|
|
1556
1767
|
// scan that did not happen. So it is clean, and the report says why.
|
|
1557
1768
|
if (exitCode !== null && profile.exit.nothingToScan.includes(exitCode)) {
|
|
1558
1769
|
const handedAll = external.lockfiles ?? [];
|
|
1770
|
+
// Every handed file read nothing: on a trust base, each one's base copy
|
|
1771
|
+
// is checked (the emptied-lockfile check above).
|
|
1772
|
+
const emptiedAll = emptiedOnBase(handedAll, new Map(), exitCode);
|
|
1773
|
+
if (emptiedAll !== null) {
|
|
1774
|
+
return emptiedAll;
|
|
1775
|
+
}
|
|
1559
1776
|
return {
|
|
1560
1777
|
...withRun,
|
|
1561
1778
|
exitCode: 0,
|
|
@@ -1713,6 +1930,45 @@ function spawnAndRead(ctx) {
|
|
|
1713
1930
|
// never a could-not-run, unlike the normalizer failure the catch below
|
|
1714
1931
|
// is for.
|
|
1715
1932
|
let findings = normalized.findings;
|
|
1933
|
+
// A handed lockfile osv-scanner read no packages from, while it read
|
|
1934
|
+
// packages from another (audit finding F2). Exit 128 above covers only
|
|
1935
|
+
// the all-empty case; this is the rest, named on the coverage line and
|
|
1936
|
+
// in a diagnostic, so an emptied lockfile's advisories never vanish
|
|
1937
|
+
// without a word. Annotation only on a plain run; on a trust base the
|
|
1938
|
+
// emptied-lockfile check runs first, BEFORE the comparison, and a head
|
|
1939
|
+
// that blocked is checked too, so the verdict is could-not-run rather
|
|
1940
|
+
// than blocked when the head emptied a file the base had packages in.
|
|
1941
|
+
const emptied = gate.product === 'osv-scanner'
|
|
1942
|
+
? emptiedLockfiles(withRun.stderr, external.lockfiles ?? [], spawnCwd)
|
|
1943
|
+
: [];
|
|
1944
|
+
const headCounts = gate.product === 'osv-scanner'
|
|
1945
|
+
? packageCounts(withRun.stderr, external.lockfiles ?? [], spawnCwd)
|
|
1946
|
+
: new Map();
|
|
1947
|
+
// A LOWERED VERBOSITY FAILS CLOSED on a trust base: without a count line
|
|
1948
|
+
// for a handed lockfile, an emptied one cannot be told from a populated
|
|
1949
|
+
// one, so the check that the head removed nothing cannot run. Said, and
|
|
1950
|
+
// the option left alone: conductor never edits a gate's configuration.
|
|
1951
|
+
const uncounted = gate.product === 'osv-scanner' && decidedRef !== undefined
|
|
1952
|
+
? (external.lockfiles ?? []).filter((file) => osvLockfileKind(path.posix.basename(file)) !== 'requirements' && !headCounts.has(file))
|
|
1953
|
+
: [];
|
|
1954
|
+
if (uncounted.length > 0) {
|
|
1955
|
+
const detail = `osv-scanner printed no package count for ${uncounted.join(', ')}, which the trust-base check that ` +
|
|
1956
|
+
'this pull request emptied, deleted or moved no lockfile needs. A verbosity option in the ' +
|
|
1957
|
+
"policy's osv-scanner options hides those counts: remove it.";
|
|
1958
|
+
return {
|
|
1959
|
+
...withRun,
|
|
1960
|
+
durationMs: Date.now() - started,
|
|
1961
|
+
exitCode,
|
|
1962
|
+
couldNotRun: { reason: 'lockfile-emptied-unverified', detail },
|
|
1963
|
+
findings: [normalizeFailedGate(gate.role, gate.product, detail)],
|
|
1964
|
+
run: EMPTY_RUN,
|
|
1965
|
+
diagnostics: [],
|
|
1966
|
+
};
|
|
1967
|
+
}
|
|
1968
|
+
const emptiedOutcome = emptiedOnBase(emptied, headCounts, exitCode);
|
|
1969
|
+
if (emptiedOutcome !== null) {
|
|
1970
|
+
return emptiedOutcome;
|
|
1971
|
+
}
|
|
1716
1972
|
let baseComparison;
|
|
1717
1973
|
const comparisonDiagnostics = [];
|
|
1718
1974
|
if (gate.product === 'osv-scanner' &&
|
|
@@ -1757,14 +2013,6 @@ function spawnAndRead(ctx) {
|
|
|
1757
2013
|
baseComparison = compared.comparison;
|
|
1758
2014
|
comparisonDiagnostics.push(...compared.diagnostics);
|
|
1759
2015
|
}
|
|
1760
|
-
// A handed lockfile osv-scanner read no packages from, while it read
|
|
1761
|
-
// packages from another (audit finding F2). Exit 128 above covers only
|
|
1762
|
-
// the all-empty case; this is the rest, named on the coverage line and
|
|
1763
|
-
// in a diagnostic, so an emptied lockfile's advisories never vanish
|
|
1764
|
-
// without a word. Annotation only: the verdict is osv-scanner's.
|
|
1765
|
-
const emptied = gate.product === 'osv-scanner'
|
|
1766
|
-
? emptiedLockfiles(withRun.stderr, external.lockfiles ?? [], spawnCwd)
|
|
1767
|
-
: [];
|
|
1768
2016
|
const emptyDiagnostics = emptied.length === 0
|
|
1769
2017
|
? []
|
|
1770
2018
|
: [
|
package/dist/normalize.js
CHANGED
|
@@ -736,13 +736,38 @@ export function normalizeGitleaks(raw, version, blocked) {
|
|
|
736
736
|
const entry = needRecord(rawEntry, product, where);
|
|
737
737
|
const rule = needString(entry.RuleID, product, `${where}.RuleID`);
|
|
738
738
|
const file = needString(entry.File, product, `${where}.File`);
|
|
739
|
-
|
|
739
|
+
// Required, and then floored like the columns below: SARIF 2.1.0 gives
|
|
740
|
+
// startLine a minimum of 1, so a line below 1 or not an integer is 1.
|
|
741
|
+
const startLine = needNumber(entry.StartLine, product, `${where}.StartLine`);
|
|
742
|
+
const line = Number.isInteger(startLine) && startLine >= 1 ? startLine : 1;
|
|
740
743
|
// Carried as gitleaks reports them, which is also what its own SARIF
|
|
741
744
|
// output uses. gitleaks 8.30.1 column numbers are not consistently 0- or
|
|
742
745
|
// 1-based across findings (one token at character 21 was reported at 22,
|
|
743
746
|
// another at character 15 at 15), so no correction is applied.
|
|
744
|
-
|
|
745
|
-
|
|
747
|
+
//
|
|
748
|
+
// BUT A COLUMN BELOW 1 IS NEVER CARRIED. The envelope's columns are
|
|
749
|
+
// 1-based and SARIF 2.1.0 gives startColumn and endColumn a minimum of 1,
|
|
750
|
+
// and gitleaks 8.30.1 writes "EndColumn": 0 on its private-key rule over
|
|
751
|
+
// a PEM file (tests/fixtures/gitleaks-8.30.1-private-key-endcolumn-zero.json),
|
|
752
|
+
// which made the SARIF file invalid and so refused by code scanning
|
|
753
|
+
// (audit 2026-10-18 B1). A start column below 1 becomes 1. The end column
|
|
754
|
+
// is kept only as an integer that is at least 1 and at least the start
|
|
755
|
+
// column, on a finding whose EndLine is absent or equals its StartLine:
|
|
756
|
+
// the subject carries no end line, so a region read from it ends on its
|
|
757
|
+
// start line, and an end column from a later line would mark the wrong
|
|
758
|
+
// span. Otherwise it is left out, which SARIF reads as "to the end of
|
|
759
|
+
// the line".
|
|
760
|
+
const column = typeof entry.StartColumn === 'number' && Number.isInteger(entry.StartColumn) && entry.StartColumn >= 1
|
|
761
|
+
? entry.StartColumn
|
|
762
|
+
: 1;
|
|
763
|
+
const oneLine = entry.EndLine === undefined || entry.EndLine === entry.StartLine;
|
|
764
|
+
const endColumn = oneLine &&
|
|
765
|
+
typeof entry.EndColumn === 'number' &&
|
|
766
|
+
Number.isInteger(entry.EndColumn) &&
|
|
767
|
+
entry.EndColumn >= 1 &&
|
|
768
|
+
entry.EndColumn >= column
|
|
769
|
+
? entry.EndColumn
|
|
770
|
+
: undefined;
|
|
746
771
|
const commit = optionalString(entry.Commit, product, `${where}.Commit`);
|
|
747
772
|
const date = optionalString(entry.Date, product, `${where}.Date`);
|
|
748
773
|
// gitleaks' own Fingerprint is commit:file:rule:line, identical across
|
package/dist/osv-baseline.d.ts
CHANGED
|
@@ -75,6 +75,80 @@ export interface CompareResult {
|
|
|
75
75
|
* finding is introduced. Never could-not-run.
|
|
76
76
|
*/
|
|
77
77
|
export declare function comparisonFailed(args: CompareArgs, reason: string): CompareResult;
|
|
78
|
+
/** How the emptied-lockfile check's one spawn went, classified by the caller's spawnFailure. */
|
|
79
|
+
export interface EmptiedSpawnResult {
|
|
80
|
+
status: number | null;
|
|
81
|
+
stderr: string;
|
|
82
|
+
failure: null | {
|
|
83
|
+
reason: 'timed-out';
|
|
84
|
+
signal: string | null;
|
|
85
|
+
} | {
|
|
86
|
+
reason: 'spawn-failed';
|
|
87
|
+
message: string;
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
export interface EmptiedCheckArgs {
|
|
91
|
+
repoRoot: string;
|
|
92
|
+
ref: string;
|
|
93
|
+
workDir: string;
|
|
94
|
+
/** Repository-relative: the emptied handed lockfiles, or every handed one on exit 128. */
|
|
95
|
+
emptied: readonly string[];
|
|
96
|
+
/** Repository-relative: base lockfiles the head no longer tracks (deleted or moved). */
|
|
97
|
+
removed: readonly string[];
|
|
98
|
+
/** The head run's package count for each handed lockfile, for the same-directory replacement rule. */
|
|
99
|
+
headCounts: ReadonlyMap<string, number>;
|
|
100
|
+
/** Null when nothing was handed and the head was never spawned: no symmetry check. */
|
|
101
|
+
headArgv: readonly string[] | null;
|
|
102
|
+
baseArgv: (copies: readonly string[]) => string[];
|
|
103
|
+
/** What is left of the gate's time limit after the head scan. */
|
|
104
|
+
budgetMs: number;
|
|
105
|
+
spawn: (argv: readonly string[], cwd: string, timeoutMs: number) => EmptiedSpawnResult;
|
|
106
|
+
}
|
|
107
|
+
export type EmptiedCheckResult = {
|
|
108
|
+
kind: 'clear';
|
|
109
|
+
} | {
|
|
110
|
+
kind: 'emptied';
|
|
111
|
+
files: Array<{
|
|
112
|
+
path: string;
|
|
113
|
+
packages: number;
|
|
114
|
+
removed: boolean;
|
|
115
|
+
}>;
|
|
116
|
+
} | {
|
|
117
|
+
kind: 'unverified';
|
|
118
|
+
detail: string;
|
|
119
|
+
} | {
|
|
120
|
+
kind: 'timed-out';
|
|
121
|
+
elapsedMs: number;
|
|
122
|
+
signal: string | null;
|
|
123
|
+
};
|
|
124
|
+
/**
|
|
125
|
+
* Whether `file` is a regular file (mode 100644 or 100755, stage 0) in the
|
|
126
|
+
* head's index: the listing the gate's handed files come from (`git
|
|
127
|
+
* ls-files`). A symbolic link (120000), a submodule, a conflicted or missing
|
|
128
|
+
* entry, and an index git cannot read are all false (fail closed). The path
|
|
129
|
+
* is passed as a literal pathspec, so no character in it is a glob.
|
|
130
|
+
*/
|
|
131
|
+
export declare function regularInHeadIndex(repoRoot: string, file: string): boolean;
|
|
132
|
+
/**
|
|
133
|
+
* The emptied-lockfile base check (design
|
|
134
|
+
* docs/superpowers/specs/2026-10-18-emptied-lockfile-under-trust-base.md,
|
|
135
|
+
* audit 2026-10-18 N1). On a decided trust base, a handed lockfile that read
|
|
136
|
+
* no packages at the head, and a base lockfile the head deleted or moved,
|
|
137
|
+
* is copied from the base and osv-scanner is run once on those copies; a
|
|
138
|
+
* copy with packages means the head removed what the gate judges. A removed
|
|
139
|
+
* file is cleared only by a head-handed lockfile in the SAME directory that
|
|
140
|
+
* read packages, is not a requirements file, is absent from the base tree,
|
|
141
|
+
* is of the removed file's ecosystem family, and is a regular file in the
|
|
142
|
+
* head's index (a migration, say npm to pnpm, beside the same manifest).
|
|
143
|
+
*
|
|
144
|
+
* FAIL CLOSED, unlike compareWithBase, whose labels only ever move toward
|
|
145
|
+
* introduced. This check exists only to stop a head from removing what the
|
|
146
|
+
* gate judges, so anything that keeps it from clearing the head (a base
|
|
147
|
+
* copy that cannot be read, an asymmetric command line, a base run that
|
|
148
|
+
* fails, times out or prints no count for a copy) is a failure the caller
|
|
149
|
+
* turns into could-not-run. Requirements files are not checked (known-open).
|
|
150
|
+
*/
|
|
151
|
+
export declare function checkEmptiedAgainstBase(args: EmptiedCheckArgs): EmptiedCheckResult;
|
|
78
152
|
/**
|
|
79
153
|
* Runs the comparison. Assumes the caller has established section 3.1: a
|
|
80
154
|
* decided trust base, a head run that exited blocked, at least one finding.
|