Conversation
The project has been completely rewritten in Go. The pyproject.toml file containing outdated Python dependencies (Flask, Pillow, opencv-python, etc.) is no longer needed and was flagged by dependency scanning. Removing it resolves the vulnerability warning.
- CI.yml: add explicit permissions: contents: read to each job (test, coverage, lint) to address actions/missing-workflow-permissions alerts - web/routes_shared.go: add isSafePath() helper (absolute path + no null bytes); apply to handleBrowseDirectory, handleThumbnail, handleMedia to fix go/path-injection alerts - web/routes_converter.go: validate folder and every file path with isSafePath() in scan, convert, and delete handlers - web/routes_dupfinder.go: validate folder and file paths in scan and delete handlers - internal/converter/converter.go: guard ConvertImage and ConvertVideo with absolute-path + null-byte check to fix go/command-injection and go/path-injection alerts
There was a problem hiding this comment.
Pull request overview
This PR merges security-focused changes from develop into main, primarily addressing CodeQL alerts around path/command injection in the Go web API and converter, plus tightening GitHub Actions workflow permissions. It also removes stale Python packaging artifacts (pyproject.toml, uv.lock) that were triggering vulnerability noise on the default branch.
Changes:
- Add
isSafePath()and apply it across file-browsing, thumbnail, media-serving, and conversion/dupfinder endpoints. - Add absolute-path guards in
internal/converterforConvertImageandConvertVideo. - Add explicit
contents: readpermissions blocks to the CI workflow and remove stale Python lock/config files.
Reviewed changes
Copilot reviewed 6 out of 7 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
web/routes_shared.go |
Adds isSafePath() and applies it to browse/thumbnail/media handlers. |
web/routes_dupfinder.go |
Applies isSafePath() checks to dupfinder scan/delete inputs. |
web/routes_converter.go |
Applies isSafePath() checks to converter scan/convert/delete inputs. |
internal/converter/converter.go |
Adds absolute-path validation for conversion inputs to mitigate command/path injection. |
.github/workflows/CI.yml |
Adds job/workflow permissions (contents: read). |
pyproject.toml |
Removed stale Python project config. |
uv.lock |
Removed stale Python lockfile. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if len(req.Files) == 0 || req.TargetExt == "" { | ||
| c.JSON(http.StatusBadRequest, gin.H{"error": "files and target_ext required"}) | ||
| return | ||
| } | ||
| for _, f := range req.Files { | ||
| if !isSafePath(f) { | ||
| c.JSON(http.StatusBadRequest, gin.H{"error": "Invalid file path: " + f}) | ||
| return | ||
| } | ||
| } |
| // isSafePath rejects relative paths and paths containing null bytes. | ||
| func isSafePath(p string) bool { | ||
| return filepath.IsAbs(p) && !strings.Contains(p, "\x00") | ||
| } |
| func ConvertVideo(source, targetExt, codec, outputDir string, av1CRF int) (string, error) { | ||
| if !filepath.IsAbs(source) || strings.Contains(source, "\x00") { | ||
| return "", fmt.Errorf("invalid source path") | ||
| } |
| func ConvertImage(source, targetExt, outputDir string) (string, error) { | ||
| if !filepath.IsAbs(source) || strings.Contains(source, "\x00") { | ||
| return "", fmt.Errorf("invalid source path") | ||
| } |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
|
@copilot apply changes based on the comments in this thread |
…pathForBin in ConvertVideo, add validation tests Agent-Logs-Url: https://github.com/exTerEX/morphic/sessions/0c4a5011-f326-4dde-b027-c165fe4c461e Co-authored-by: exTerEX <30706568+exTerEX@users.noreply.github.com>
Applied all changes from the review thread in commit
|
Summary
pyproject.tomlanduv.lock(old Python rewrite — resolves Dependabot vulnerability on default branch)isSafePath()helper in web routes, applied to all file-serving and conversion handlersConvertImageandConvertVideoactions/missing-workflow-permissionsalerts: add per-jobpermissions: contents: readblocks to CI.ymlTest plan
go build ./...passes (verified locally)mainafter merge