Repository navigation
fix(scanner): resolve docker via shellwrap in source extraction path - #421
Merged
Merged
Conversation
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]>
Deploying mcpproxy-docs with
|
| 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 |
5 tasks done
Contributor
📦 Build ArtifactsWorkflow Run: View Run Available Artifacts
How to DownloadOption 1: GitHub Web UI (easiest)
Option 2: GitHub CLI gh run download 24959615082 --repo smart-mcp-proxy/mcpproxy-go
|
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
internal/security/scanner/source_resolver.go(ps/diff/cp/exec) throughshellwrap.ResolveDockerPathso they work when mcpproxy is launched from a sandboxed$PATH(PKInstallSandbox, GUI launchd) where baredockeris unresolvable.findServerContainerfails so users can see why source extraction fell back totool_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 toSourceMethod=tool_definitions_only, and the AI scanner then false-flagged the synthetictools.jsonas obfuscated code (MCP-MC-001) — chained downstream effects from one root cause.Verification
Reproduced against the live
mcpproxy-obsidian-pilot-9179container withPATH="/bin:/sbin:/usr/bin:/usr/sbin:/usr/libexec"(the PKInstallSandbox-equivalent — no docker on PATH):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./Applications/Docker.app/Contents/Resources/bin/docker, returnsMethod=docker_extract, ContainerID populated, extracts 21 files of realobsidianpilotsource (server.py,models/obsidian.py, etc.).Test plan
TestDockerCmdUsesResolvedBinary—dockerCmdproduces*exec.Cmdwith absolute resolvedPath, never a bare relative"docker".TestDockerCmdFallbackWhenShellwrapFails— helper never returns nil or emptyPath.$PATHsucceeds withdocker_extract.go test ./internal/security/scanner/ -count=1passes.golangci-lint run ./internal/security/scanner/...clean.🤖 Generated with Claude Code