Harden runner-guard Docker command rendering - #51753
Conversation
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Hardens runner-guard Docker invocation and verbose command rendering.
Changes:
- Centralizes Docker arguments in
runnerGuardDockerArgs. - Reuses arguments for execution and shell-rendered output.
- Adds focused argument-boundary coverage.
Show a summary per file
| File | Description |
|---|---|
pkg/cli/runner_guard.go |
Centralizes and safely renders Docker arguments. |
pkg/cli/runner_guard_test.go |
Tests dynamic argument preservation and quoting. |
Review details
Tip
Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
- Files reviewed: 2/2 changed files
- Comments generated: 1
- Review effort level: Balanced
| if verbose { | ||
| dockerCmd := fmt.Sprintf("docker run --rm -v \"%s:/workdir\" -w /workdir %s scan %s --format json", | ||
| gitRoot, RunnerGuardImage, containerScanPath) | ||
| dockerCmd := shellJoinArgs(append([]string{"docker"}, dockerArgs...)) |
|
🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅
|
|
✅ Test Quality Sentinel completed test quality analysis.
|
|
✅ Ponytail Reviewer completed successfully! Reviewed diff for over-engineering: extracting runnerGuardDockerArgs and using shellJoinArgs is a straightforward, minimal refactor with no speculative abstraction or unneeded complexity. Lean already. Ship.
|
|
✅ PR Code Quality Reviewer completed the code quality review. Warning Threat Detection Engine Failure — The analysis engine could not complete. This is a tooling failure, not a security finding. What happenedThe threat detection engine failed to produce results. Review the workflow run logs for details. Warning Firewall blocked 1 domainThe following domain was blocked by the firewall during workflow execution:
To allow these domains, add them to the network:
allowed:
- defaults
- "api.individual.githubcopilot.com"See Network Configuration for more information.
|
|
✅ Design Decision Gate 🏗️ completed the design decision gate check. No ADR enforcement needed: PR #51753 does not have the 'implementation' label and has only 37 new lines of code in business logic directories (threshold: 100).
|
There was a problem hiding this comment.
The refactor cleanly extracts runnerGuardDockerArgs for testability and switches the verbose display to use shellJoinArgs for proper quoting. exec.Command still passes args directly to the OS (no shell), so no security regression. The new test covers spaces and flag-injection in paths. LGTM.
🧵 Reviewed using Impeccable skills by Impeccable Skills Reviewer · sonnet46 · 16.7 AIC · ⌖ 7 AIC · ⊞ 5.4K
There was a problem hiding this comment.
Skills-Based Review 🧠
Applied /diagnosing-bugs and /tdd — changes look well-targeted.
📋 Key Themes & Highlights
Key Themes
- Argument centralisation:
runnerGuardDockerArgscleanly unifies theexec.Commandbuild and the verbose display path, eliminating drift. - Test coverage: The new test verifies both argument discreteness (defence against option injection) and shell-quoting for display — good dual coverage.
One open concern
- The pre-existing
shellEscapeArgimplementation omits!from its special-character set. Single-quoted strings are safe in POSIX sh, but interactive Bash withhistexpandenabled will still expand!in history-expansion contexts. The generated command is display-only (neverevald), so this is low-severity, but worth noting for paths that may contain!.
Positive Highlights
- ✅
runnerGuardDockerArgsis a pure function — easy to test and reason about. - ✅
#nosec G204comment retained with the original rationale, keeping the security context local to the call site. - ✅ Test uses adversarial inputs (
./--help, spaces in path) that cover real injection vectors.
🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · sonnet46 · 28.4 AIC · ⌖ 7.45 AIC · ⊞ 7.1K
Comment /matt to run again
🧪 Test Quality Sentinel Report✅ Test Quality Score: 100/100 — Excellent
📊 Metrics (1 test)
Quality Analysis
Verdict
|
|
@copilot PR sous-chef triage: please refresh the current maintainer-facing state on the latest head, resolve any addressed unresolved review threads, refresh the branch if GitHub can update it cleanly, and run the No failed checks were listed in the compact candidate snapshot.
|
Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
Added |
|
🎉 This pull request is included in a new release. Release: |
Sighthound identified dynamic Docker command arguments as potential command-injection sinks. The execution path already validates mount and scan-path inputs; this change makes the argument boundary explicit and secures verbose command rendering.
Fixed argument construction
runnerGuardDockerArgs.exec.Command.Safe verbose output
shellJoinArgsrather than interpolating mount paths into a quoted string.