Add tests for resolveSafePath
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 88/100
Research direction
Read resolveSafePath at the bottom of internal/tools/files.go, then inspect existing conventions in internal/tools/tools_test.go. Add cases for the listed paths using a temporary root and run the tools package tests. Done means the in-root paths resolve without error and every escaping or absolute path returns an error.
Written by the indexing model from the issue text.
Description
What
resolveSafePath is the function that jails every file tool to the launch directory. It is pretty thin right now, add tests to try and break it and find real work around bugs to fix.
Where
internal/tools/files.go — the function is at the bottom of the file.
Tests go in internal/tools/tools_test.go (same package tools, so unexported funcs are reachable).
Cases to cover
Should resolve (no error), given a root like /tmp/root:
"main.go"→ inside root"sub/dir/file.go"→ inside root"./main.go"→ inside root (cleanup)""→ root itself
Should error (path escapes root):
"../secret""../../etc/passwd""sub/../../escape"- an absolute path like
"/etc/passwd"(should not silently land inside root)
Notes
It's a pure function do not need ollama, try and break it its good if you find it failing
- Dominant language
- Go
- Stars
- 1
- Forks
- 2
- Avg merge
- 1h 31m
- Merged PRs (30d)
- 7
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Edwin-metcalf/MetCode
-
documentation enhancement help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
Edwin-metcalf/MetCode#19 ·
-
bug good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Edwin-metcalf/MetCode#18 ·
-
enhancement good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Edwin-metcalf/MetCode#16 ·
-
Add a MakefileOpenenhancement good first issue help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Edwin-metcalf/MetCode#8 ·
-
Add a --host flagOpenenhancement
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Edwin-metcalf/MetCode#7 ·
All issues in Edwin-metcalf/MetCode
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
QuantumNous/new-api#7839 ·
Maintainers usually reply within 1 day
-
bug needs-triage service/costoptimizationhub
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
hashicorp/terraform-provider-aws#50507 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
adcontextprotocol/adcp-go#567 ·
Maintainers usually reply within 1 day
-
bug raised-by:desk
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
medici-finance/assay#3097 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
supabase-community/supabase-kubernetes#275 ·
Maintainers usually reply within 1 day