Repository navigation
mcp: reject relative paths in tool handlers - #3694
Conversation
|
Welcome @Shrey327! It looks like this is your first PR to knative/func 🎉 |
|
Hi @Shrey327. Thanks for your PR. I'm waiting for a knative member to verify that this patch is reasonable to test. If it is, they should reply with Regular contributors should join the org to skip this step. Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
lkingland
left a comment
There was a problem hiding this comment.
Thanks for the PR. Just two small suggestions.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3694 +/- ##
==========================================
+ Coverage 57.03% 57.10% +0.07%
==========================================
Files 182 182
Lines 21376 21421 +45
==========================================
+ Hits 12191 12233 +42
- Misses 7953 7955 +2
- Partials 1232 1233 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
/ok-to-test |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: lkingland, Shrey327 The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
766fda2 to
7995a39
Compare
|
Thanks @Shrey327. Both my points were addressed. However, since this was submitted, several new tools taking a path have landed on main (config_ci, config_git, invoke, run, run_stop). Please rebase, extend validatePath() to those new tools as well, and we can merge this. One suggestion to keep this from regressing again: rather than per-tool tests alone, a single test that iterates over all registered tools with a path input and asserts a relative path is rejected would catch any future tool that forgets the check. Feel free to include that more advanced approach in this PR, or a separate one, at your discretion. |
…ed tests Signed-off-by: Shrey327 <shreyansh.pathak273@gmail.com>
Signed-off-by: Shrey327 <shreyansh.pathak273@gmail.com>
Signed-off-by: Shrey327 <shreyansh.pathak273@gmail.com>
Tools that landed after knative#3694 (config_ci, config_git, invoke, run, run_stop) now reject relative paths before they shell out. describe and logs are included so a registry-wide test can walk every tool whose schema has a path input and fail if a future tool skips the check. Success-path tests that still passed "." now use an absolute directory. Signed-off-by: Luke Kingland <luke@lukekingland.com>
woke flags the previous name as insensitive. Signed-off-by: Luke Kingland <luke@lukekingland.com>
filepath.IsAbs rejects POSIX literals such as /home/user/myfunc on Windows, so the new validatePath checks failed the Windows unit job. Tests now use testAbsPath, which joins os.TempDir. Signed-off-by: Luke Kingland <luke@lukekingland.com>
e777f09 to
7eb46f8
Compare
|
Rebased onto main, extended /lgtm |
|
Thanks @lkingland for rebasing and extending the checks to the new tools! I’ll be quicker on follow-ups next time. |
Description
Adds
validatePath()to the MCP server that rejects non-absolute path arguments before shelling out to the func CLI. Sincecmd.Diris never set in the executor, relative paths silently resolved against the MCP server's working directory instead of the user's project turning a wrong directory failure into a silent misbehavior. This change turns that into an actionable error, matching the guidance already documented in instructions.md.All existing tests updated to uset.TempDir()and aTestValidatePathunit test added.