Skip to content

fix(scanner): resolve docker via shellwrap in source extraction path - #421

Merged
Dumbris merged 1 commit into
mainfrom
fix/scanner-source-resolver-docker-path
Apr 26, 2026
Merged

Dumbris merged 1 commit into
mainfrom
fix/scanner-source-resolver-docker-path

Conversation

@Dumbris

@Dumbris Dumbris commented Apr 26, 2026

Copy link
Copy Markdown
Member

Summary

  • Routes all 15 docker invocations in internal/security/scanner/source_resolver.go (ps/diff/cp/exec) through shellwrap.ResolveDockerPath so they work when mcpproxy is launched from a sandboxed $PATH (PKInstallSandbox, GUI launchd) where bare docker is unresolvable.
  • Adds a Warn log when findServerContainer fails so users can see why source extraction fell back to tool_definitions_only — previously a silent path that produced the misleading "Local (no Docker)" badge in the UI for servers that were running in Docker.

Why

Same class of bug as #420, which fixed the docker image probe but missed the source-extraction path. With a stripped $PATH, the resolver returned "no Docker container found" with zero diagnostic logging, the scan fell through to SourceMethod=tool_definitions_only, and the AI scanner then false-flagged the synthetic tools.json as obfuscated code (MCP-MC-001) — chained downstream effects from one root cause.

Verification

Reproduced against the live mcpproxy-obsidian-pilot-9179 container with PATH="/bin:/sbin:/usr/bin:/usr/sbin:/usr/libexec" (the PKInstallSandbox-equivalent — no docker on PATH):

  • Before: Resolve() returned "could not resolve source for server obsidian-pilot: no Docker container found, no working_dir configured, and no local file paths in command args", SourceMethod=tool_definitions_only.
  • After: Resolver picks up docker via /Applications/Docker.app/Contents/Resources/bin/docker, returns Method=docker_extract, ContainerID populated, extracts 21 files of real obsidianpilot source (server.py, models/obsidian.py, etc.).

Test plan

  • Unit: TestDockerCmdUsesResolvedBinary — dockerCmd produces *exec.Cmd with absolute resolved Path, never a bare relative "docker".
  • Unit: TestDockerCmdFallbackWhenShellwrapFails — helper never returns nil or empty Path.
  • Manual: end-to-end resolve against running container with stripped $PATH succeeds with docker_extract.
  • go test ./internal/security/scanner/ -count=1 passes.
  • golangci-lint run ./internal/security/scanner/... clean.

🤖 Generated with Claude Code

When mcpproxy is launched from a sandboxed PATH (PKInstallSandbox or a
GUI launchd context that strips /usr/local/bin), the source resolver's
bare exec.CommandContext("docker", ...) fails silently. The resolver
returns "no Docker container found" with no diagnostic logging, and the
scan falls through to SourceMethod=tool_definitions_only. That makes the
Web UI render the misleading "Local (no Docker)" badge for servers that
ARE running in Docker, and triggers MCP-MC-001 false positives because
the scanner sees only the synthetic tools.json instead of real source.

PR #420 fixed the same class of bug for the docker IMAGE probe in
internal/security/scanner/docker.go but missed source_resolver.go,
which has 15 separate bare "docker" invocations (ps/diff/cp/exec).

This commit:
  - Adds (*SourceResolver).dockerCmd that resolves the binary via
    shellwrap.ResolveDockerPath, mirroring the helper already used
    in scanner/docker.go.
  - Routes all 15 docker invocations (including dockerExecCapture,
    converted to a method) through the helper.
  - Adds a Warn log when findServerContainer fails so users can see
    why source extraction fell back to tool_definitions_only —
    previously this was a silent path that produced misleading UI.

Verified manually against the running mcpproxy-obsidian-pilot-9179
container with PATH="/bin:/sbin:/usr/bin:/usr/sbin:/usr/libexec":
the resolver now finds docker at /Applications/Docker.app/Contents/
Resources/bin/docker, returns Method=docker_extract, ContainerID set,
and extracts 21 files of obsidianpilot source. Previously this exact
scenario produced "could not resolve source... no Docker container
found" and SourceMethod=tool_definitions_only.

Tests:
  - TestDockerCmdUsesResolvedBinary: dockerCmd produces *exec.Cmd
    with absolute resolved Path, never a bare relative "docker" that
    would silently rely on $PATH.
  - TestDockerCmdFallbackWhenShellwrapFails: helper never returns nil
    or empty Path, mirroring the documented fallback in docker.go.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying mcpproxy-docs with  Cloudflare Pages  Cloudflare Pages

Latest commit: ea89e1b
Status: ✅  Deploy successful!
Preview URL: https://4dbefe41.mcpproxy-docs.pages.dev
Branch Preview URL: https://fix-scanner-source-resolver.mcpproxy-docs.pages.dev

View logs

@github-actions

Copy link
Copy Markdown
Contributor

📦 Build Artifacts

Workflow Run: View Run
Branch: fix/scanner-source-resolver-docker-path

Available Artifacts

  • archive-darwin-amd64 (26 MB)
  • archive-darwin-arm64 (23 MB)
  • archive-linux-amd64 (15 MB)
  • archive-linux-arm64 (13 MB)
  • archive-windows-amd64 (26 MB)
  • archive-windows-arm64 (23 MB)
  • frontend-dist-pr (0 MB)
  • installer-dmg-darwin-amd64 (19 MB)
  • installer-dmg-darwin-arm64 (18 MB)

How to Download

Option 1: GitHub Web UI (easiest)

  1. Go to the workflow run page linked above
  2. Scroll to the bottom "Artifacts" section
  3. Click on the artifact you want to download

Option 2: GitHub CLI

gh run download 24959615082 --repo smart-mcp-proxy/mcpproxy-go

Note: Artifacts expire in 14 days.

@Dumbris
Dumbris merged commit 5200185 into main Apr 26, 2026
23 checks passed
@Dumbris
Dumbris deleted the fix/scanner-source-resolver-docker-path branch April 26, 2026 15:53
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.

2 participants