fix(sync): remote URL allowlist, exit codes, progress output - #242
Merged
Conversation
Contributor
|
🎉 PR Validation ✅ PASSED Commit: Checks:
Ready to merge! ✨ 🔗 View workflow run |
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.
What
Hardens
vaultgit sync against poisoned remotes and improvesvault syncUX.src/sync/remote-url.ts(isSafeRemoteUrl/assertSafeRemoteUrl). Allows onlyhttps://,ssh://,git://,file://, scp-likeuser@host:path, and absolute local paths. Rejects transport helpers (ext::,fd::,transport::, any<helper>::) and any URL starting with-- these let git run arbitrary commands on auto-sync. Enforced atvault add --git(friendly error, exit 1) and in the sync planner (skips the origin with a one-line warning so one bad origin can't kill the cycle), plus a minimal defensive gate incycle.tsthat returnsskipped: 'invalid-remote'before anyremote add/set-url.user:pass@hostin a remote is redacted touser:***@hostin all human output (formatVaultLine,vault addecho,vault syncreport) and--json(vault list). The stored value is untouched.vault sync <nonexistent>exit code. A name not in the registry now errorsvault '<name>' not foundand exits 1 (mirrorsvault remove). A registered vault with no syncable origin keeps its no-op message and exit 0.vault syncprints an upfrontSyncing <N> vault(s)...line and a per-vault<name>...line before each sync starts, so it no longer looks hung on slow remotes.Why
Git honors transport-helper URLs as remotes, so a poisoned
vaults.jsonorigin was arbitrary command execution when the daemon auto-syncs. Printed remotes could also leak credentials, andvault synchad a misleading exit code + no progress output.Notes
file://and absolute local paths are allowed alongside the scheme allowlist: they are legitimate git transports that cannot execute commands (and the crash-recovery cycle tests sync to local bare repos).cycle.tschange is a single validation gate; its crash-recovery tests are untouched.Verified: npm run verify green locally (357 tests); npm run test:coverage exit 0, thresholds met.