You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Summary Verdict: Adds an interactive "save patch to file" flow in the TUI patch viewer, but
introduces medium-severity path construction bugs and file-creation security risks.
Medium Severity Findings
1. Non-portable / Incorrect Default Save Path Construction
Description: The default path is constructed with hardcoded slashes using fmt.Sprintf("/%s/roborev-%d.patch", os.TempDir(), m.patchJobID). This results in invalid absolute paths on Windows (e.g., /C:\Temp\...) and redundant double
-slashes on POSIX systems (e.g., //tmp//...).
Suggested Fix: Import path/filepath and use filepath.Join(os.TempDir(), fmt.Sprintf("roborev-%d.patch", m.patchJobID)).
Description: The default save path is deterministic ( /tmp/roborev-<jobID>.patch), and os.WriteFile will follow symlinks and truncate existing targets. On multi-user systems, another local user could pre-create a symlink at that path and cause overwrite of arbitrary files writable by the victim user.
Suggested Fix: Use
a secure creation flow: os.OpenFile(path, os.O_WRONLY|os.O_CREATE|os.O_EXCL, 0o600) (or os.CreateTemp for default path generation), and verify targets are not symlinks.
Verdict: The new patch saving feature is functional but contains a few medium-severity issues regarding predictable temporary files, byte-based string truncation, and a lack of targeted test coverage.
Medium
Predictable filename in shared temp space / Symlink overwrite
Issue: Default save path uses a predictable filename in shared temp space (/tmp/ roborev-<jobID>.patch) and writes via os.WriteFile, which follows symlinks. On multi-user systems, another local user can pre-create that path as a symlink, causing overwrite/truncation of an arbitrary file the victim can write.
Remediation: Use os.CreateTemp (randomized filename) in a private directory (0700) and write through the returned file descriptor. If supporting user-provided paths, open with safer flags (O_CREATE|O_EXCL) and reject symlinks (Lstat/EvalSymlinks +
policy, or platform-specific no-follow behavior).
Issue: Slicing the display string using its byte length (len(display) > inputWidth) can split multi-byte characters in half, resulting in invalid UTF-8 sequences and
rendering artifacts if the file path contains non-ASCII characters.
Remediation: Convert display to a slice of runes before checking its length and slicing (e.g., runes := []rune(display) then string(runes[len(runes)-inputWidth:]) ), or use a display-width aware function consistent with other TUI rendering code.
Issue: No new _test.go coverage appears for: entering/ex
iting save-input mode, default path population, save success/error handling, and patch-view rendering while input is active.
Remediation: Add unit tests for handlePatchKey, handleSavePatchResultMsg, and renderPatchView save-mode UI branches.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When user hits
sin patch view, it'll be prompted for file name (default to/tmp/roborev-<id>.patch).Somewhat related to #407