Repository navigation
Conversation
There was a problem hiding this comment.
🟢 Approval recommended
There are no active review issues for the branch-name and node-URL validation changes.
No open issues 🎉
What changed in this PR
Strengthens input validation for Git branch names in the node and configured node URLs in the remote helper.
Changes:
- Validates literal
refs/heads/names independently of the working repository while preserving short-name restrictions. - Requires a parseable HTTP(S) node URL before applying transport policy, with regression tests covering plaintext opt-in.
| File | Description |
|---|---|
crates/twigpine-node/src/git/store.rs |
Replaces branch-shorthand validation with literal full-ref validation. |
crates/git-remote-twigpine/src/main.rs |
Validates node URLs and tests malformed or unsupported configurations. |
Review effort: Balanced
beardthelion
left a comment
There was a problem hiding this comment.
Branch validation now runs git check-ref-format refs/heads/<name> with explicit rejection of HEAD and a leading -. I ran the old --branch path against the new logic on git 2.43.0 over 49 names (@{-1}, .lock, .., control characters, -x, HEAD, refs/heads/x) and accept/reject matched on every one. Removing the HEAD/dash guard turns the existing validate_git_ref tests red, so the guard is covered.
check_transport_security now fails closed on an unparseable or non-http(s) TWIGPINE_NODE, including with the plaintext opt-in set. Dropping either the parse error or the scheme check turns gate_requires_a_valid_node_url_even_with_plaintext_opt_in red. repo_base is still built from the raw string, and is_insecure_remote re-parses its input, so gating on the normalized URL gives the same result.
Callers of validate_git_ref only match on the Invalid/GitUnavailable variants, so dropping git's stderr changes message text only. Two non-blocking notes: no test pins the repo-independent behavior the description claims (reverting to --branch stays green), and the gl gate in twigpine-cli/src/http.rs has no equivalent parse step.
|
Continued in #673, same commit carried over unchanged on an upstream branch. Closing this one in favor of it. |
Pull request was closed
Summary
Validate Git branch names as literal local refs and require a valid HTTP(S) node URL before the remote helper builds its request destination.
Motivation & context
Git's branch shorthand validator can consult the working repository. Validation should depend only on the name being stored or used. The remote helper now rejects malformed node configuration before appending repository path components.
Kind of change
What changed
twigpine-nodechecks the literal full ref with Git and applies the short-name rules before launch.git-remote-twigpineparses the configured node URL before applying the existing transport policy. Regression coverage checks malformed configuration with and without the plaintext opt-in.How a reviewer can verify
Before you request review
cargo test --workspacepassed locallyThe PostgreSQL-backed real-node deny and models harness, release build, and MSRV check on Rust 1.91.1 also passed. CodeQL 2.27.6 removed the branch-validation command-line result and found no new results. Its surviving HTTP result follows a test fixture that verifies a signed request locally.
Reviewed commit
aae8dde92d86a38dba9513cb3e495577118b40fe.Summary by CodeRabbit
HEAD, begin with a hyphen, or fail Git’s reference-format rules are rejected. Invalid branch names now produce a consistent error message.