Skip to content

Potential fix for code scanning alert no. 3: Uncontrolled data used in path expression - #17

Merged
ShadowDara merged 1 commit into
mainfrom
alert-autofix-3
Sep 13, 2026
Merged

ShadowDara merged 1 commit into
mainfrom
alert-autofix-3

Conversation

@ShadowDara

Copy link
Copy Markdown
Owner

Potential fix for https://github.com/ShadowDara/finder/security/code-scanning/3

Best fix: strictly validate cache template names as a single safe path component before building file paths.
That means rejecting names containing path separators (/, \), parent traversal (..), empty values, and optionally names that normalize to ".".

Implement this in internal/cache/cache.go (single source of truth), then call it in both SaveCache and LoadCache before filepath.Join(...). This avoids changing functionality for normal template names while blocking traversal/path injection. Add fmt and strings imports for validation error creation and checks. No route-level behavior changes are required; invalid names will naturally return an error and existing handlers already map errors to HTTP responses.

Suggested fixes powered by Copilot Autofix. Review carefully before merging.

…n path expression

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@ShadowDara
ShadowDara marked this pull request as ready for review September 13, 2026 21:21
@ShadowDara
ShadowDara merged commit ce8b92c into main Sep 13, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant