Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Add tests for resolveSafePath

Open Beginner friendly
#9 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
88/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
go
Domain
cli

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

testing

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

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Edwin-metcalf/MetCode

All issues in Edwin-metcalf/MetCode

Similar issues

More Go issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.