-
Notifications
You must be signed in to change notification settings - Fork 4
fix(modules): sanitize slash-containing source versions #168
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -319,7 +319,7 @@ func resolveDeps(mod module.Version, modFS fs.ReadFileFS, frla *formula.Formula, | |
| // TODO(MeteorsLiu): Design source cache dir | ||
| // In the most common case, onRequire only read one file like CMakelist.txt, etc. | ||
| // So missing cache here is acceptable. | ||
| tmpSourceDir, err := os.MkdirTemp("", fmt.Sprintf("source-%s-%s*", strings.ReplaceAll(mod.Path, "/", "-"), mod.Version)) | ||
| tmpSourceDir, err := os.MkdirTemp("", fmt.Sprintf("source-%s-%s*", strings.ReplaceAll(mod.Path, "/", "-"), strings.ReplaceAll(mod.Version, "/", "-"))) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [P3] Duplicated sanitization expression across packages This exact |
||
| if err != nil { | ||
| return nil, err | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[P2] Version not sanitized/validated (installDir uncovered)
This fix sanitizes the temp-dir name, but the same raw
mod.Versionstill flows unescaped intoinstallDir(internal/build/cache.go:83, the persistent output dir). A slash version creates a nested dir tree there, and becausefilepath.JoincallsClean, a..-containing version could escapeworkspaceDir.Root cause:
mod.Versionisn't validated at the trust boundary (unlikemod.Path). Per-char/replacement misses.., backslashes, and control chars. Consider validating/escaping the version centrally (e.g.module.EscapeVersion/allowlist) so both this call site andinstallDirare covered. A brief comment explaining the git-ref motivation would also help.