fix: round-H audit hardening (pid, filename, ssh timeout, throttling)#17
Merged
Conversation
- Verify cmdline before signaling PID-file pid (`isSshshotDaemonPid`). Prevents `sshshot stop` from killing an unrelated process when the OS recycles the daemon's old PID. - generateFilename() now includes ms + 4-char random suffix, eliminating same-second collisions on rapid-fire screenshots. SAFE_REMOTE_FILENAME_RE and tests updated. - ProcessInfo loses the synthetic `command` field; it now carries an explicit nullable `target`. Status output no longer prints "(from" when discovery used the PID file. - getRemoteHomePath() asks the remote directly via `ssh remote 'echo \$HOME'` with a per-daemon cache. Falls back to the user@host / ssh -G heuristic on failure. Handles non-standard home dirs (/Users/<user>, /data/<user>, custom HOME overrides) instead of guessing /home/<user>. - Add `-o ConnectTimeout=5` to pipeToRemote and the new echo-\$HOME probe so an unreachable host fails in ~5s instead of SSH's default ~75s. - Throttle loadConfig() parse/read error stderr to once per unique error message — a persistent broken file no longer floods stderr 5x/sec. Adds two new tests covering filename uniqueness and the new shape.
|
🎉 This PR is included in version 0.7.3 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Six bugs from the latest audit batch, all in one
fix:PR (sr → patch release).sshshot+--daemonbefore sending a signal. Preventssshshot stopkilling an unrelated PID-recycled process.generateFilename()collided on same-second screenshots. Adds milliseconds + 4-char random hex suffix.SAFE_REMOTE_FILENAME_REupdated; new test covers 100 same-tick calls being unique.--daemon\s+(\S+)regex extracted"(from".ProcessInfonow carries a nullabletargetinstead ofcommand; PID-file path readsconfig.activeTargetfor display.ssh remote 'echo $HOME'with per-daemon cache. Handles/Users/<user>,/data/<user>, custom HOME overrides — anythinggetent passwdwould resolve. Heuristic fallback retained for unreachable hosts.pipeToRemoteand the echo-$HOME probe. Failures now surface in ~5s instead of SSH's ~75s default.loadConfigwrites stderr once per unique read/parse error; persistent broken file stops spamming 5x/sec.Test plan
yarn typecheckyarn lintyarn buildyarn format:checkyarn test(25 tests, +2 new for filename uniqueness/shape)