Skip to content

Enforce bash parser specification invariants in JS Copilot SDK parser#37394

Merged
pelikhan merged 3 commits into
mainfrom
copilot/review-bash-parser-specification
Jun 6, 2026
Merged

Enforce bash parser specification invariants in JS Copilot SDK parser#37394
pelikhan merged 3 commits into
mainfrom
copilot/review-bash-parser-specification

Conversation

Copilot AI commented Jun 6, 2026

Copy link
Copy Markdown
Contributor

This PR aligns the JavaScript bash parser with the parser specification used by Copilot SDK permissions, focusing on robustness and strict conformance behavior. It tightens parser guarantees so malformed or adversarial shell input remains non-throwing and semantically stable.

  • Parser semantics hardening

    • Replaced recursive prefix skipping in extractCommandName with iterative scanning for !, {, and } prefixes.
    • Preserves existing extraction behavior while removing recursion-depth failure risk on long prefix chains.
  • Spec contract enforcement

    • Added explicit type-contract tests for all parser APIs with non-string StringLike runtime inputs, asserting total-function behavior ([] / null, never throw).
    • Added targeted robustness vectors for both moderate and extreme prefix depth to enforce stack-safe command extraction.
  • Conformance coverage expansion

    • Extended spec-vector tests so JS behavior is directly enforced against documented invariants rather than relying only on ad hoc cases.
// iterative prefix skipping (stack-safe)
if (word === "!" || word === "{" || word === "}") {
  remaining = remaining.slice(word.length).trim();
  if (!remaining) return null;
  continue;
}

Copilot AI and others added 3 commits June 6, 2026 20:35
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title Enforce bash parser specification on JS Copilot SDK parser Enforce bash parser specification invariants in JS Copilot SDK parser Jun 6, 2026
Copilot AI requested a review from pelikhan June 6, 2026 20:40
@pelikhan pelikhan marked this pull request as ready for review June 6, 2026 20:46
Copilot AI review requested due to automatic review settings June 6, 2026 20:46
@pelikhan pelikhan merged commit 0b58556 into main Jun 6, 2026
@pelikhan pelikhan deleted the copilot/review-bash-parser-specification branch June 6, 2026 20:46

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR hardens the actions/setup JavaScript bash command parser to be stack-safe under long prefix chains and expands test coverage to enforce strict “total-function” behavior (never throw, stable []/null outputs). It also includes updates to compiled workflow/action pin artifacts.

Changes:

  • Replaced recursive prefix skipping in extractCommandName with an iterative scan to avoid recursion-depth failures.
  • Added type-contract and robustness tests ensuring all parser APIs return []/null for non-string runtime inputs and handle extreme prefix depth.
  • Updated generated workflow lock/pin data (including removal of an unused setup action pin and regeneration of a lock workflow file).
Show a summary per file
File Description
pkg/workflow/data/action_pins.json Removes an action pin entry (generated pin data update).
pkg/actionpins/data/action_pins.json Mirrors the action pin removal in the second pin dataset.
actions/setup/js/bash_command_parser.cjs Makes extractCommandName iterative to avoid stack overflows on long prefix chains.
actions/setup/js/bash_command_parser_spec_vectors.test.cjs Adds runtime type-contract + deep-prefix robustness tests for parser APIs.
.github/workflows/daily-awf-spec-compiler-surfacing.lock.yml Regenerates a compiled workflow lock file (operational/workflow artifact update).

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 5/5 changed files
  • Comments generated: 1

Comment on lines +109 to +118
- name: Checkout actions folder
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
repository: github/gh-aw
sparse-checkout: |
actions
persist-credentials: false
- name: Setup Scripts
id: setup
uses: github/gh-aw-actions/setup@v0.77.5
uses: ./actions/setup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants