Pass regex capture groups to known-error help text and fixes#343
Merged
Conversation
ScopeKnownError patterns can now capture text from the matched error line and
reuse it in help text and fix commands/prompts, via minijinja's existing
{{ }} templating: positional groups as {{ captures[1] }} (index 0 is the
whole match) and named groups like (?<file>.*) as {{ file }}.
Fix-building moves from config-load time to match time so captures are
available when needed, but the fix is still eagerly validated at load time
(with empty captures) so a broken template fails fast rather than only
surfacing mid-run. Capture group names "working_dir" and "captures" are
rejected at load time since they'd otherwise shadow the reserved template
variables.
Closes #196.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
rubberduck203
marked this pull request as ready for review
July 23, 2026 17:09
|
This pull request introduces a critical command injection vulnerability in
🔴 Command Injection in
|
| Vulnerability | Command Injection |
|---|---|
| Description | The application substitutes regex capture groups directly into command strings, which are then executed. While the DoctorCommand structure is used, the command string is ultimately passed to an execution provider. If an attacker can control the log output that matches the KnownError regex, they can inject shell metacharacters into the capture groups, which are then rendered into the command string and executed. The current implementation does not appear to sanitize these captures for shell safety before execution. |
scope/src/shared/models/internal/command.rs
Lines 30 to 33 in 88c0377
Comment to provide feedback on these findings.
Report false positive: @dryrunsecurity fp [FINDING ID] [FEEDBACK]
Report low-impact: @dryrunsecurity nit [FINDING ID] [FEEDBACK]
Example: @dryrunsecurity fp drs_90eda195 This code is not user-facing
All finding details can be found in the DryRun Security Dashboard.
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.
Summary
ScopeKnownErrorpatterns can now capture text from the matched error line and reuse it inhelptext and infix'scommands/prompt, via the existing minijinja{{ }}templating: positional groups as{{ captures[1] }}(index0is the whole match) and named groups like(?<file>.*)as{{ file }}. Closes Feature: Allow passing regex matches to fixes #196.KnownErrorstoresVec<Regex>instead of aRegexSet(needed to pull capture groups out of a match) and the rawDoctorFixSpecinstead of a pre-builtDoctorFix— fix-building moves to match time, once captures are known, via new_with_capturessibling functions (DoctorCommand::try_new_with_captures,DoctorCommands::from_commands_with_captures,DoctorFix::from_spec_with_captures). The originals are unchanged thin wrappers, soScopeDoctorGroupfixes are untouched.working_dirorcapturesis rejected at load time, since it would otherwise silently shadow the reserved template variable of the same name.help_textrendering falls back to the raw string on a template error, since it predates this feature and may contain literal brace-like text that was never meant to be a template.KnownErrorPattern/KnownErrorSpec, a newexamples/v1alpha/KnownErrorWithCapture.yaml, and the generatedschema/*.json(the docs site symlinks to these).Test plan
cargo build,cargo test(177 unit + all integration suites pass)cargo fmt --check,cargo clippy --all-targets --all-features -- -D warningscleantests/test-cases/intercept-known-error-capture/(test_intercept_fix_uses_captured_regex_group) — captures a filename from a real error message and uses it, unmodified, in help text and the fix commandtests/test-cases/intercept-known-error-multi-command-fix/(test_intercept_fix_stops_after_first_command_fails) — confirms a multi-command fix stops after the first failing command; manually verified this test fails if that short-circuit is brokenworking_dir).expect(), and one real mutation-testing gap in the fix short-circuit logic)