harden: validate MCP shrink_media inputs (file source, positive target)#175
Open
seonghobae wants to merge 1 commit into
Open
harden: validate MCP shrink_media inputs (file source, positive target)#175seonghobae wants to merge 1 commit into
seonghobae wants to merge 1 commit into
Conversation
The MCP tool checked only that the source path exists. A directory source, or target_bytes <= 0, fell through to the engine and surfaced as an opaque "Conversion failed with error: ..." string instead of a clear, actionable message at the trust boundary. - Reject a source that is not a regular file (e.g. a directory). - Reject target_bytes <= 0 up front. Both return a clear "Error: ..." string, consistent with the existing source-not-found handling and the web app's input validation. Tests (+2): directory source rejected, non-positive target rejected. mcp_driver.py stays at 100% coverage; interrogate 100%; full suite 115 tests, no new failures (5 macOS-only xattr errors pre-existing / Linux-green). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CJRVbDrp1vGYkJgNHMGPpG
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
The MCP
shrink_mediatool checked only that the source path exists. Two invalid inputs fell through to the engine and surfaced as an opaque"Conversion failed with error: ..."string rather than a clear message at the trust boundary:exists()), andtarget_bytes <= 0.What
target_bytes <= 0up front.Both return a clear
"Error: ..."string, consistent with the existing source-not-found handling and the web app's input validation.(No upper bound on
target_byteshere — unlike the web upload path, this is a local tool where a large target is a legitimate request; an arbitrary cap would reject valid use.)Tests (+2)
Directory source rejected; non-positive target rejected.
Verified:
mcp_driver.py100% coverage,interrogate100%, full suite 115 tests, no new failures (5 macOS-onlyos.listxattrerrors are pre-existing / Linux-green).Independence
Off base
main; touches onlymcp_driver.py. Independent of #163–#167 and #174.🤖 Generated with Claude Code