Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/qwen-autofix.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
name: 'Qwen Autofix'

# One workflow for the whole autonomous-fix lifecycle:
Expand Down Expand Up @@ -5222,6 +5222,7 @@
WORKDIR="${WORKDIR}" \
BRANCH="${BRANCH}" \
GITHUB_OUTPUT="${GITHUB_OUTPUT}" \
CI="${CI:-true}" \
Comment thread
doudouOUC marked this conversation as resolved.
Resolved
KISS_AUDIT="${KISS_AUDIT:-false}" \
FOOTPRINT_ENFORCE="${FOOTPRINT_ENFORCE:-advisory}" \
bash --norc "${RUNNER_TEMP}/run-autofix-review-verification.sh"
Expand Down Expand Up @@ -5431,6 +5432,7 @@
WORKDIR="${WORKDIR}" \
BRANCH="${BRANCH}" \
GITHUB_OUTPUT="${GITHUB_OUTPUT}" \
CI="${CI:-true}" \
KISS_AUDIT="${KISS_AUDIT:-false}" \
FOOTPRINT_ENFORCE="${FOOTPRINT_ENFORCE:-advisory}" \
bash --norc "${RUNNER_TEMP}/run-autofix-review-verification.sh"
Expand Down
85 changes: 84 additions & 1 deletion scripts/tests/qwen-autofix-workflow.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11201,6 +11201,89 @@ exit 1
expect(reviewVerificationGateStep).not.toContain(
'bash .github/scripts/run-autofix-review-verification.sh',
);
// The gate launches through an env -i clean child with a SANCTIONED
// allowlist (R5-1): every variable the gate's own build/test checks need
// must be passed, and the runner-provided CI=true is one of them — without
// it the gate's checks run with inverted CI semantics and the 18
// deliberately-skipped TUI-input tests un-skip inside the gate (one flakes
// ~5s, reject_fix fires retryable on a fix the PR's own CI passes green).
// Pin the launch STRUCTURALLY — one verbatim adjacency chain from the
// LD_* prefix through the digest-verified script, every entry in order
// with its exact value — not as text tokens: shell edits that preserve
// token text (a commented-out entry, a dropped `\`, an =-less operand, a
// quote suffix, an entry smuggled behind a `bash --norc` value, the
// launch head moved into a comment) each broke the child's isolation
// while every token-level pin stayed green (R2-1). Anchoring the chain
// on the LD_* prefix pins the one channel env -i cannot block; the
// body-side unset and PATH export that protect the pre-launch digest
// check are pinned with it (R3-1, R2-2). The shapes AROUND the chain
// are closed by pinning the run body's whole statement list with
// comments stripped: a prefix command word that demotes the whole chain
// to one command's argv (the gate never executes and a forged outcome
// survives), a command appended or inserted around the launch, a
// demotion of the pinned block into a never-run arm, a commented-out or
// relocated statement — each adds, drops, reorders, or renames a
// statement here (R4-2, R4-3, R4-4). Within the chain, separators allow
// only bash whitespace — space/tab after the continuation newline: JS
// `\s` also matches a blank line, which splits the chain into two
// commands (the orphaned env -i prints and exits 0 while the rest runs
// with the FULL step environment), and NBSP/U+2028, which glue into the
// next operand and rename it; the statement list sees neither shape
// (blank lines filter out, trim strips a leading NBSP), so only this
// pin closes them (R4-1).
const gateLaunchTokens = [
'LD_PRELOAD= LD_AUDIT= LD_LIBRARY_PATH=',
'/usr/bin/env -i',
'PATH="${TRUSTED_PATH}"',
'HOME="${HOME}"',
'RUNNER_TEMP="${RUNNER_TEMP}"',
'WORKDIR="${WORKDIR}"',
'BRANCH="${BRANCH}"',
'GITHUB_OUTPUT="${GITHUB_OUTPUT}"',
'CI="${CI:-true}"',
'KISS_AUDIT="${KISS_AUDIT:-false}"',
'FOOTPRINT_ENFORCE="${FOOTPRINT_ENFORCE:-advisory}"',
'bash --norc "${RUNNER_TEMP}/run-autofix-review-verification.sh"',
];
const gateLaunchPin = new RegExp(
gateLaunchTokens
.map((token) => token.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'))
.join(' \\\\\n[ \\t]*'),
);
// The digest check executes in the PARENT shell before the clean child
// exists, so its own defenses — the TRUSTED_PATH export and the LD_*
// unset — and their order live in the pinned statement list: a
// commented copy matched a bare toContain, and a planted LD_PRELOAD or
// PATH reached the sha256sum exec (R4-4). The digest line is pinned
// whole and per step — a workflow-wide count accepts relocation out of
// the gates, and `|| true` accepts a digest mismatch under bash -e
// (R4-3, the resanitize sibling's doctrine).
const gateDigestCheck =
'echo "${VERIFY_RUNNER_SHA256} ${RUNNER_TEMP}/run-autofix-review-verification.sh" | sha256sum -c - > /dev/null';
const gateBodyStatements = [
'export PATH="${TRUSTED_PATH}"',
'unset LD_PRELOAD LD_AUDIT LD_LIBRARY_PATH',
gateDigestCheck,
...gateLaunchTokens.map((token, index) =>
index < gateLaunchTokens.length - 1 ? `${token} \\` : token,
),
];
for (const step of [
reviewVerificationGateStep,
repairVerificationGateStep,
]) {
expect(step).toMatch(gateLaunchPin);
expect(
step
.slice(step.indexOf('run: |-') + 'run: |-'.length)
.split('\n')
.map((line) => line.trim())
.filter((line) => line !== '' && !line.startsWith('#')),
).toEqual(gateBodyStatements);
// Exactly one launch per step: a second, unpinned `bash --norc` (the
// pinned block demoted into a never-run arm) must fail here (R2-1).
expect((step.match(/bash --norc/g) ?? []).length).toBe(1);
}
expect(
reviewVerifyGate.indexOf(
'bash "${RUNNER_TEMP}/check-autofix-contracts.sh"',
Expand Down Expand Up @@ -12793,7 +12876,7 @@ exit 1
// Delimited tokens, not substrings: match `NAME=value` up to the line
// continuation, so a value swap or an extra entry is visible.
const assignments = (
argList.match(/[A-Z_][A-Z0-9_]*=(?:"[^"]*"|[^\s\\]*)/g) ?? []
argList.match(/[A-Za-z_][A-Za-z0-9_]*=(?:"[^"]*"|[^\s\\]*)/g) ?? []
).map((m) => m.trim());
const passed = assignments.map((m) => m.split('=')[0]);
// Sorted multiset, not a Set: a symmetric duplicate entry is exactly
Expand Down
Loading