mirror of
https://github.com/garrytan/gstack.git
synced 2026-11-30 03:44:38 +01:00
Let /gstack-ship handle very large results PRs (GST-4003) (#4847)
`/gstack-ship` now works on results PRs with tens of thousands of files and hundreds of megabytes of diff: more exclusion patterns, a secrets check with no size limit, a faster review plan and docs check, and bulleted ruled notes. Why: two 16,000-file results PRs hit each of these limits in real runs. Nothing to do: existing policies keep working unchanged. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> Review-Finding: p1/red-team#1 reader=red-team Review-Finding: p2/adversarial-native#1 reader=adversarial-native Review-Finding: p2/outside-voice#1 reader=outside-voice Review-Finding: p2/outside-voice#2 reader=outside-voice Review-Finding: p2/outside-voice#3 reader=outside-voice Review-Finding: p2/outside-voice#4 reader=outside-voice Review-Finding: p2/specialist-batched#2 reader=specialist-batched
This commit is contained in:
1 parent
0febbce1e4
commit
77da8a0160
21 files changed
+756
-101
No files matched your search
@@ -16,6 +16,7 @@ import { spawnSync } from '../lib/spawn-sync';
|
||||
import * as fs from 'node:fs';
|
||||
import * as path from 'node:path';
|
||||
import { BANNED_TERMS_PATH, addedLines, exampleBannedTermsJson, loadBannedTerms, renderBannedTerms, scanBannedTerms, validateBannedTerms, wholeFiles } from '../lib/banned-terms';
|
||||
import { gitDiffInParts, mergeParts } from '../lib/diff-parts';
|
||||
import { baseArg } from '../lib/gate-diff/git';
|
||||
import { EXIT, exitTableHelp } from '../lib/headless-artifacts';
|
||||
import { resultLine } from '../lib/result-codes';
|
||||
@@ -78,9 +79,10 @@ function main(argv: string[]): number {
|
||||
else {
|
||||
const diffBase = flag(rest, '--diff-base') ?? (() => { const mb = spawnSync('git', ['merge-base', baseArg('gstack-banned-terms', base, repoRoot), 'HEAD'], { cwd: repoRoot, encoding: 'utf8', timeout: 30_000 }); return mb.status === 0 ? mb.stdout.trim() : undefined; })();
|
||||
if (!diffBase) { process.stderr.write(`gstack-banned-terms: no merge base with ${base}; pass --diff-base <sha> or --files <csv>\n`); return EXIT.usage; }
|
||||
const diff = spawnSync('git', ['diff', '--unified=0', '--no-color', diffBase], { cwd: repoRoot, encoding: 'utf8', timeout: 120_000, maxBuffer: 256 * 1024 * 1024 });
|
||||
if (diff.status !== 0) { process.stderr.write(`gstack-banned-terms: git diff ${diffBase} failed\n`); return EXIT.fail; }
|
||||
files = addedLines(diff.stdout);
|
||||
const added = new Map<string, Array<{ line: number; text: string }>>();
|
||||
const diff = gitDiffInParts(['diff', '--unified=0', '--no-color', diffBase], { cwd: repoRoot, timeout: 120_000 }, part => mergeParts(added, addedLines(part)));
|
||||
if (!diff.ok) { process.stderr.write(`gstack-banned-terms: git diff ${diffBase} failed\n`); return EXIT.fail; }
|
||||
files = added;
|
||||
}
|
||||
const result = scanBannedTerms(load.config, load.source, files);
|
||||
if (json) process.stdout.write(JSON.stringify(result) + '\n'); else process.stdout.write(renderBannedTerms(result));
|
||||
|
||||
@@ -62,7 +62,7 @@ import { RISK_CLASSES, type RiskClass } from '../lib/review-risk';
|
||||
import { checkReceiptProse, proseLine } from '../lib/ship-receipt-prose';
|
||||
import { resolveStateRoot } from '../lib/state-root';
|
||||
import { readPause, receiptBaseRed } from '../lib/base-red';
|
||||
import { publicRuledNote, readRuledNotes, ruledNoteText } from '../lib/ruled-notes';
|
||||
import { bodyListsLine, publicRuledNote, readRuledNotes, ruledNoteText } from '../lib/ruled-notes';
|
||||
import { appliedGateDispositions, gateDispositionText, publicGateDisposition } from '../lib/gate-dispositions';
|
||||
import { securityFingerprints } from '../lib/security-findings';
|
||||
import { laneExceptionBodyLines } from '../lib/test-lane-exception';
|
||||
@@ -304,7 +304,7 @@ async function cmdWrite(rest: string[], json: boolean): Promise<number> {
|
||||
const leaked = securityFingerprints(bodyText);
|
||||
if (leaked.length) { process.stderr.write(resultLine('gstack-ship-receipt write', 'RECEIPT_INVALID', `${bodyFile} names security finding ${leaked.join(', ')}: a PR body is public, so a security finding appears only as the redacted line gstack-approvals rulings, dispositions or gstack-review-scope render prints, and its location and reason stay in the private record (docs/troubleshooting.md#security-finding-in-body); nothing written`) + '\n'); return EXIT.fail; }
|
||||
const ruledNotes = readRuledNotes(repoRoot);
|
||||
const unlisted = bodyFile ? ruledNotes.map(n => `Ruled note: ${ruledNoteText(n)}`).find(l => !bodyText.split(/\r?\n/).some(b => b.trim() === l)) : undefined;
|
||||
const unlisted = bodyFile ? ruledNotes.map(n => `Ruled note: ${ruledNoteText(n)}`).find(l => !bodyListsLine(bodyText, l)) : undefined;
|
||||
if (unlisted) { process.stderr.write(resultLine('gstack-ship-receipt write', 'RECEIPT_INVALID', `${bodyFile} does not list ruled note ${JSON.stringify(unlisted)} (gstack-approvals rulings prints each line the body carries); nothing written`) + '\n'); return EXIT.fail; }
|
||||
let gateDispositions: ReturnType<typeof appliedGateDispositions>['applied'];
|
||||
try { gateDispositions = appliedGateDispositions(repoRoot, { pin: 'HEAD' }).applied; }
|
||||
|
||||
Reference in new issue
Block a user