Skip to content

Commit d584db5

Browse files
Copilotpelikhan
andauthored
Fix regex to span line breaks in shell-expansion guard detection
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
1 parent 2059a22 commit d584db5

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

actions/setup/js/detect_agent_errors.cjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ const MAX_CACHE_MISSES_EXCEEDED_PATTERN = /(?:\bmax_cache_misses_exceeded\b|\bma
189189
// This guard can misfire on benign multi-line printf/safeoutputs CLI invocations. Retrying the
190190
// identical command is pointless — it will be rejected again — so this is surfaced as a distinct,
191191
// actionable diagnostic instead of a generic shell failure.
192-
const SHELL_EXPANSION_GUARD_REJECTED_PATTERN = /could enable arbitrary code execution\b[^\n]{0,160}\brewrite the command without these expansion patterns\b/i;
192+
const SHELL_EXPANSION_GUARD_REJECTED_PATTERN = /could enable arbitrary code execution\b[\s\S]{0,200}?\brewrite the command without these expansion patterns\b/i;
193193

194194
/**
195195
* Determines if the collected output contains the observed Copilot/CAPI quota exhaustion error.

actions/setup/js/detect_agent_errors.test.cjs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -671,6 +671,11 @@ commentary" has no AI credits pricing`;
671671
expect(SHELL_EXPANSION_GUARD_REJECTED_PATTERN.test(ISSUE_REJECTION_MESSAGE.toUpperCase())).toBe(true);
672672
});
673673

674+
it("matches when the two anchor phrases are split across a line break", () => {
675+
const wrapped = "Command rejected: ...that could enable arbitrary code execution.\nPlease rewrite the command without these expansion patterns.";
676+
expect(isShellExpansionGuardRejectedError(wrapped)).toBe(true);
677+
});
678+
674679
it("does not match unrelated shell errors", () => {
675680
expect(isShellExpansionGuardRejectedError("bash: safeoutputs: command not found")).toBe(false);
676681
expect(isShellExpansionGuardRejectedError("permission denied by workflow tool permissions")).toBe(false);

0 commit comments

Comments
 (0)