@arjunkhera/atlas 0.4.48 → 0.4.49
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/.claude-plugin/plugin.json +1 -1
- package/door/lib/approve.mjs +25 -8
- package/package.json +1 -1
package/door/lib/approve.mjs
CHANGED
|
@@ -337,9 +337,22 @@ export function auditCause(deps, repo, { run, sha, pr, main }) {
|
|
|
337
337
|
return null;
|
|
338
338
|
}
|
|
339
339
|
|
|
340
|
+
// Why the audit on this Mac does not find only "owner-unsigned" for this
|
|
341
|
+
// pull request at this merge, or null when it does (item aef880cb). It runs
|
|
342
|
+
// the code of the installed Atlas on the owner's clone at `root`.
|
|
343
|
+
async function macFindings(deps, { repo, root, sha, pr }) {
|
|
344
|
+
let found;
|
|
345
|
+
try { found = await (deps.audit ?? macAudit)({ repo, root: resolve(root ?? '.'), sha }); }
|
|
346
|
+
catch (error) { return `the audit on this Mac stopped: ${plainText(error?.message ?? error).slice(0, 200)}`; }
|
|
347
|
+
if (Array.isArray(found) && found.some((one) => one?.pin === 'unread')) return `the audit on this Mac could not read the head or the base of #${pr} in this clone. Run git fetch origin pull/${pr}/head, then the command again`;
|
|
348
|
+
const only = Array.isArray(found) && found.length === 1 && found[0]?.kind === AUDIT_TEST && found[0].sha === sha && Number(found[0].pr) === pr && found[0].key === `${AUDIT_TEST}:${sha}` && found[0].pin === undefined;
|
|
349
|
+
if (only) return null;
|
|
350
|
+
return `the audit on this Mac found ${Array.isArray(found) && found.length ? found.map((one) => plainText(one?.key ?? one?.kind)).join(', ') : 'nothing to accept'}, not only ${AUDIT_TEST} for #${pr}`;
|
|
351
|
+
}
|
|
352
|
+
|
|
340
353
|
// One open audit issue, read from GitHub: the pull request that made the
|
|
341
354
|
// merge, its head, and the red audit run. `skip` says why it is not signed.
|
|
342
|
-
export async function auditRow(deps, repo, issue, main, kinds = new Map()) {
|
|
355
|
+
export async function auditRow(deps, repo, issue, main, kinds = new Map(), root = '.', named = new Set()) {
|
|
343
356
|
const sha = AUDIT_ISSUE.exec(String(issue.title ?? ''))[1];
|
|
344
357
|
const row = { issue: Number(issue.number), sha };
|
|
345
358
|
const pull = (deps.gh('GET', `repos/${repo}/commits/${sha}/pulls`) ?? []).find((each) => each?.merged_at && each.merge_commit_sha === sha);
|
|
@@ -347,6 +360,8 @@ export async function auditRow(deps, repo, issue, main, kinds = new Map()) {
|
|
|
347
360
|
const head = String(pull.head?.sha ?? '');
|
|
348
361
|
if (!/^[0-9a-f]{40}$/.test(head)) return { ...row, pr: Number(pull.number), skip: 'GitHub gave no head' };
|
|
349
362
|
Object.assign(row, { pr: Number(pull.number), head, title: plainText(pull.title).slice(0, 120), merged_at: String(pull.merged_at) });
|
|
363
|
+
// A run that names pull requests reads and audits only those rows.
|
|
364
|
+
if (named.size && !named.has(row.pr)) return { ...row, skip: 'not named' };
|
|
350
365
|
const runs = (deps.gh('GET', `repos/${repo}/commits/${sha}/check-runs?per_page=100`)?.check_runs ?? [])
|
|
351
366
|
.filter((run) => run?.name === AUDIT_CHECK)
|
|
352
367
|
.sort((a, b) => String(b.started_at ?? '').localeCompare(String(a.started_at ?? '')));
|
|
@@ -364,6 +379,12 @@ export async function auditRow(deps, repo, issue, main, kinds = new Map()) {
|
|
|
364
379
|
if (code.files.length) return { ...row, skip: `the merge changed ${code.files[0]}, so its audit ran its own code: read that diff and sign it with atlas approve audit-code ${row.pr}` };
|
|
365
380
|
const parent = String(commit?.parents?.[0]?.sha ?? '');
|
|
366
381
|
if (!/^[0-9a-f]{40}$/.test(parent)) return { ...row, skip: 'GitHub gave no parent of the merge commit' };
|
|
382
|
+
// Item aef880cb: the findings above came from the audit run on GitHub.
|
|
383
|
+
// The Atlas on this Mac audits the merge again with its own code, as
|
|
384
|
+
// atlas approve audit-code does. It must find this owner merge and
|
|
385
|
+
// nothing else.
|
|
386
|
+
const mac = await macFindings(deps, { repo, root, sha, pr: row.pr });
|
|
387
|
+
if (mac) return { ...row, skip: mac };
|
|
367
388
|
// Item 65c6c907: a merge made before the first owner key takes the keys
|
|
368
389
|
// at the tip of the default branch, within the limits of preKeyKeys.
|
|
369
390
|
const owner = await ownerKeys(deps, repo, { parent, head, main });
|
|
@@ -400,7 +421,7 @@ export async function approveAudit({ prs = [], repo, root, key, provider, yes =
|
|
|
400
421
|
line(` ${issues.length} open audit issue(s) of an owner merge with no touch. Each one can take about 5 seconds.`);
|
|
401
422
|
const rows = [];
|
|
402
423
|
for (const issue of issues) {
|
|
403
|
-
const row = await auditRow(deps, name, issue, main, kinds);
|
|
424
|
+
const row = await auditRow(deps, name, issue, main, kinds, root, only);
|
|
404
425
|
if (only.size && !only.has(row.pr)) continue;
|
|
405
426
|
rows.push(row);
|
|
406
427
|
}
|
|
@@ -545,12 +566,8 @@ export async function approveAuditCode({ prs = [], repo, root, key, provider, ye
|
|
|
545
566
|
// The audit of that run ran the code of this merge, or never ran. So the
|
|
546
567
|
// Atlas on this Mac audits the merge again with its own code (security
|
|
547
568
|
// review S2): it must find this owner merge and nothing else.
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
catch (error) { throw new ApproveError(`the audit on this Mac stopped: ${plainText(error?.message ?? error).slice(0, 200)}. Nothing was signed.`); }
|
|
551
|
-
if (Array.isArray(found) && found.some((one) => one?.pin === 'unread')) throw new ApproveError(`the audit on this Mac could not read the head or the base of #${pr} in this clone. Run git fetch origin pull/${pr}/head, then the command again. Nothing was signed.`);
|
|
552
|
-
const only = Array.isArray(found) && found.length === 1 && found[0]?.kind === AUDIT_TEST && found[0].sha === sha && Number(found[0].pr) === pr && found[0].key === `${AUDIT_TEST}:${sha}` && found[0].pin === undefined;
|
|
553
|
-
if (!only) throw new ApproveError(`the audit on this Mac found ${Array.isArray(found) && found.length ? found.map((one) => plainText(one?.key ?? one?.kind)).join(', ') : 'nothing to accept'}, not only ${AUDIT_TEST} for #${pr}. Nothing was signed.`);
|
|
569
|
+
const mac = await macFindings(deps, { repo: name, root, sha, pr });
|
|
570
|
+
if (mac) throw new ApproveError(`${mac}. Nothing was signed.`);
|
|
554
571
|
const owner = await ownerKeys(deps, name, { parent, head, main });
|
|
555
572
|
if (!owner.keys.length) throw new ApproveError(`${SIGNERS_FILE} holds no owner key that counts for this merge: ${owner.why ?? 'no reason'}.`);
|
|
556
573
|
line(`atlas approve audit-code: ${name} #${pr} ${plainText(pull.title).slice(0, 120)}`);
|
package/package.json
CHANGED