Skip to content

Merge develop into main: security fixes and CodeQL alerts#23

Merged
exTerEX merged 13 commits intomainfrom
develop
May 6, 2026
Merged

Merge develop into main: security fixes and CodeQL alerts#23
exTerEX merged 13 commits intomainfrom
develop

Conversation

@exTerEX
Copy link
Copy Markdown
Owner

@exTerEX exTerEX commented May 6, 2026

Summary

  • Remove stale pyproject.toml and uv.lock (old Python rewrite — resolves Dependabot vulnerability on default branch)
  • Fix CodeQL path-injection alerts: add isSafePath() helper in web routes, applied to all file-serving and conversion handlers
  • Fix CodeQL command-injection alerts: add absolute-path guards in ConvertImage and ConvertVideo
  • Fix actions/missing-workflow-permissions alerts: add per-job permissions: contents: read blocks to CI.yml

Test plan

  • go build ./... passes (verified locally)
  • CI workflow passes on merge
  • Dependabot vulnerability alert clears on main after merge
  • Python CodeQL alerts (#31–#43) auto-dismiss on next scan (files already deleted)

exTerEX added 6 commits April 1, 2026 23:40
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
Copilot AI review requested due to automatic review settings May 6, 2026 20:32
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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/converter for ConvertImage and ConvertVideo.
  • Add explicit contents: read permissions 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.

Comment thread web/routes_dupfinder.go Outdated
Comment thread web/routes_converter.go Outdated
Comment thread web/routes_converter.go
Comment on lines 94 to +103
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
}
}
Comment thread web/routes_shared.go Outdated
Comment on lines +216 to +219
// isSafePath rejects relative paths and paths containing null bytes.
func isSafePath(p string) bool {
return filepath.IsAbs(p) && !strings.Contains(p, "\x00")
}
Comment thread internal/converter/converter.go Outdated
Comment on lines 220 to +223
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")
}
Comment on lines 128 to +131
func ConvertImage(source, targetExt, outputDir string) (string, error) {
if !filepath.IsAbs(source) || strings.Contains(source, "\x00") {
return "", fmt.Errorf("invalid source path")
}
exTerEX and others added 3 commits May 6, 2026 22:44
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>
@exTerEX exTerEX self-assigned this May 6, 2026
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@exTerEX
Copy link
Copy Markdown
Owner Author

exTerEX commented May 6, 2026

@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>
Copy link
Copy Markdown
Contributor

Copilot AI commented May 6, 2026

@copilot apply changes based on the comments in this thread

Applied all changes from the review thread in commit 273a7bd:

  • Renamed isSafePathisAbsPath across all call sites (routes_shared.go, routes_converter.go, routes_dupfinder.go) with an updated comment clarifying it only validates absolute paths + no NUL bytes, without enforcing a sandbox root.
  • Validated target_ext in handleConverterConvert using a new exported converter.IsValidTargetExt() function before starting the async job — rejects path separators, control characters, and any extension not in the image/video allowlists.
  • Added validateVideoTargetExt (mirrors validateImageTargetExt) and wired it into ConvertVideo, replacing the bare normaliseTargetExt call.
  • Fixed ConvertVideo to use pathForBin for the -i source and output destination in ffmpeg args, matching the existing convertImageByFFmpeg approach.
  • Updated probeVideoBitrate to convert the source path via pathForBin when a Windows binary (ffprobe.exe) is selected.
  • Added four unit tests confirming ConvertImage and ConvertVideo both reject relative source paths and NUL-byte source paths.

Copilot finished work on behalf of exTerEX May 6, 2026 20:58
@exTerEX exTerEX merged commit 226c830 into main May 6, 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.

3 participants