feat: retry intercept script when known-error fix succeeds#302
Merged
Conversation
When scope-intercept wraps a failing command, it now prompts the user to run any available known-error fixes (the same fix infrastructure used by scope doctor), and if a fix succeeds, automatically retries the entire original command. Previously, known errors were detected and help text was shown, but fixes were never run and the command was never retried — the self-healing behaviour only existed in scope doctor. Closes LDE-463 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…tor known-error fix - Add --yolo / -y flag to scope-intercept to auto-approve fix prompts (required for E2E tests since assert_cmd pipes stdin, no TTY) - Thread yolo through process_lines and prompt_and_run_fix in shared::analyze so callers control whether to prompt or auto-approve - Thread yolo from DoctorRunArgs through DefaultDoctorActionRun to analyze_known_errors, fixing a gap where scope doctor --yolo did not auto-approve known-error fix prompts triggered during check analysis - Add comment to scope analyze explaining why yolo is not applicable there - Add 7 E2E integration tests for scope-intercept (fix succeeds/retries, fix retried but still fails, no fix available, no TTY denial, succeeds first try, no match with exit code preserved, shebang script path) - Add 4 unit tests for DefaultDoctorActionRun::analyze_known_errors (yolo auto-approves, no-TTY denied, no match, match without fix) - Add test fixtures for intercept and doctor known-error scenarios Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
This pull request introduces a critical security issue: the 'yolo' mode in scope-intercept will automatically load KnownError configurations from any .scope/ directory in the current or ancestor directories and execute commands defined there without confirmation, allowing an attacker to plant a malicious .scope/known-error.yaml in a repository and achieve arbitrary command execution with the victim's privileges. This behavior should be treated as a high-priority security fix (disable auto-execution, restrict config discovery, and require explicit user confirmation).
🔴 Arbitrary Command Execution via 'yolo' mode in
|
| Vulnerability | Arbitrary Command Execution via 'yolo' mode |
|---|---|
| Description | The 'yolo' mode in scope-intercept enables automatic, non-interactive execution of commands defined in KnownError configurations. These configurations are loaded automatically from any .scope/ directory found in the current directory or its parent ancestors. An attacker can place a malicious .scope/known-error.yaml file in a repository. When a victim runs scope-intercept --yolo within that repository, the tool will parse the attacker-controlled configuration and execute the defined command automatically without further user confirmation, leading to arbitrary command execution with the user's privileges. |
scope/src/shared/analyze/mod.rs
Lines 85 to 88 in 66667ee
All finding details can be found in the DryRun Security Dashboard.
kejadlen
approved these changes
Apr 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
`scope-intercept` is used as a shebang interpreter for setup scripts. When the wrapped command fails, it already detected known errors and showed help text — but it never ran fixes or retried the script. This meant engineers still had to manually apply the fix and re-run the script themselves.
`scope doctor` gained self-healing behaviour in #204: when a fix succeeds, the action is automatically retried. This PR extends the same behaviour to `scope-intercept`.
What changed
src/shared/mod.rs— Changedpub(crate) mod analyzetopub mod analyzeso the shared fix-and-analyze infrastructure is accessible from the binary crates.src/shared/analyze/mod.rs— Addedyolo: booltoprocess_linesandprompt_and_run_fix. Whentrue, known-error fix prompts are auto-approved without requiring a TTY. This is the shared fix-prompt path used by bothscope-interceptandscope doctor.src/bin/scope-intercept.rs— Added--yolo/-yflag. On command failure:analyze::process_linesto match known errors, prompt, and run fixes.offer_bug_report()to avoid duplicating that logic across the original-failure and retry-failure paths.src/doctor/check.rs/src/doctor/commands/run.rs— Bug fix discovered while adding--yoloto scope-intercept:scope doctor --yolowas not auto-approving known-error fix prompts that fire during check analysis (analyze_known_errors), even though it correctly auto-approved the check's own fix prompts. Theyoloflag was never threaded intoDefaultDoctorActionRun. Fixed by addingyolo: boolto the struct and passingargs.yoloat construction.src/analyze/cli.rs— Updatedprocess_linescall sites to passyolo: false; added a comment explaining whyscope analyzeis always interactive and doesn't expose--yolo.Tests
7 E2E integration tests (
tests/scope_intercept.rs):--yolo→ fix denied, command fails4 unit tests (
src/doctor/check.rs,analyze_known_errors_spec):yolo: trueauto-approves the known-error fixyolo: falsewithout a TTY returnsKnownErrorFoundUserDeniedNoKnownErrorsFoundKnownErrorFoundNoFixFound🤖 Generated with Claude Code