Commit Graph
342 Commits
Author SHA1 Message Date
Daniel Norman eee5cb8d8c radicle: Reject COB changes with forged identity
Each COB change names an identity commit in its `Rad-Resource`
trailer. Patches and issues check the rights of the author against the
document in that commit. Nothing checked that the commit is a revision
of the repository identity. Any user could write a commit with a
document that names them as a delegate, cite it, and act as a delegate.

- Add `Identity::is_accepted`, which follows each revision's parent
  back from `rad/id`, so a change that cites the head costs one blob
  read
- Add `ReadRepository::identity_revision_doc`, which returns the
  document of an accepted identity revision only
- Use it in `Op::identity_doc`, so a change with any other resource
  gets no identity document and is rejected
- Document that `identity_doc_at` does not check the commit
- Test forged resources on patches and issues, and the accepted chain

Accepted revisions form a chain, because a revision is only adopted if
its parent is the current revision. Callers synchronize `rad/id` with
the current revision after identity writes, so the chain holds every
accepted revision.
2026-11-02 21:27:45 +01:00
Daniel Norman 783b06fb04 radicle: Keep rad/id at the current identity
Every caller of `IdentityMut` had to move `rad/id` itself. `rad id
accept` only moved it when the accepted revision became current. When
an accept also adopted a queued child, `rad/id` stayed behind.

- Move `rad/id` to the current revision after each identity write
- Route `IdentityMut::update` through the same commit helper
- Remove the now redundant updates from `rad id` and `rad publish`
- Test that an update and a cascading accept move `rad/id`
2026-11-02 21:27:45 +01:00
Lorenz Leutgeb 09d04d1787 cli/cob: Fix Race Condition in Test
Bob may fetch before Alice creates the issue, because the
clone may join an in-flight fetch.

Create the issue before connecting the nodes to avoid the race.
2026-10-23 20:45:48 +02:00
Lorenz Leutgeb 15e2d7d455 cli/test: Relax matching error message
On Windows, these tests sometimes produced a different error message.
The message itself, and the hint that follows, should be good enough to
match on.
2026-10-23 20:06:14 +02:00
Lorenz Leutgeb 7a21a472c2 cli: End lines in unified diffs with line feed
The workaround for Windows is not necessary anymore.
2026-10-23 20:04:49 +02:00
Lorenz Leutgeb b7bc88037f cli: Avoid overflow in xdiff on Windows
We would like the diff output of changes to the identity document to not
collapse into separate hunks, but show all of the identity document in
the diff. The way to do this is to set the number of context lines
sufficiently high. It turns out that `u32::MAX` is too high for `xdiff`,
which is commonly used on Windows. `xdiff` stores the context lines in
a signed integer of 32 bits. Also, it appears to double line numbers
when it merges hunks. Thus, a safe value seems to be half of `i32::MAX`.
2026-10-23 20:03:12 +02:00
Lorenz Leutgeb 83137067f0 cli/test: Remove .exe
It turns out that `clap` already helpfully strips the extension on
Windows.
2026-10-23 19:35:12 +02:00
Lorenz Leutgeb 134e249b2d cli/test: Skip rad_cob_multiset on Windows
The test uses a script with a shebang that cannot
be executed on Windows.
2026-10-23 19:35:12 +02:00
Lorenz Leutgeb 41608ee678 cli/test/init: Set invalid default branch 2026-10-23 19:35:12 +02:00
Xeonacid 5e0f26a73f cli/tests: Give private-clone success paths more time
The unauthorized clone in `rad-init-private-clone` keeps a 1s timeout
so it still fails quickly. The success paths used 1s and 3s, which is
not enough on slower hosts: `rad sync --announce` reports "All seeds
timed out" after Bob has already fetched, and `rad seed`/`rad clone`
miss the fetch handshake.

Raise those success timeouts to 30s, matching `DEFAULT_TIMEOUT`. The
wait ends as soon as the target is met, so passing runs are not slower.

Signed-off-by: Xeonacid <h.dwwwwww@gmail.com>
2026-10-20 17:56:30 +02:00
Xeonacid ec3a58050b cli/tests: Wait for seed discovery after clone
`git_push_canonical` clones the repository as Bob and then immediately
runs `git push` as Alice, expecting "Synced with 1 seed(s)".

`clone` announces Bob's inventory, but Alice only treats Bob as a seed
after that announcement is applied to her routing table. On a slower
host the reactor can still be busy when Alice looks up seeds, so she
reports "No seeds found".

Wait until Alice's routing table contains Bob for the repository before
pushing. Apply the same wait to the lightweight-tags variant, which
uses the same setup.

Signed-off-by: Xeonacid <h.dwwwwww@gmail.com>
2026-10-20 17:48:26 +02:00
Xeonacid 422b7c033f cli/tests: Treat exit code 127 as "not found"
`fn program_reports_version` skips optional tools such as `jq` and
`jj` when they are missing. It currently only treats an error returned
by `std::process::Command::status` of kind
`std::io::ErrorKind::NotFound` as absence.

Rust's `std::command::Command` uses glibc's `posix_spawn` on Unix.
When `execve` fails after `spawn` has already returned, POSIX requires
the child to exit with code 127 rather than reporting `errno` to the
parent. glibc usually copies that failure back through a
`CLONE_VM|CLONE_VFORK` shared-stack channel, but not every
implementation preserves it. qemu-user, OpenBSD, and HPPA surface a
successful `spawn` and an exit code of 127 instead.

On those platforms the helper panics, so tests that are meant to skip
without `jq` or `jj` fail. Treat exit status 127 the same as
`NotFound`.

See `man:posix_spawn(3)` and POSIX.1.

Signed-off-by: Xeonacid <h.dwwwwww@gmail.com>
2026-10-20 17:40:39 +02:00
Daniel Norman ceb74c9971 cli: Test explorer URL for annotated tag push
- Push an annotated tag and expect the tree URL of the tagged commit
- Currently fails: the URL uses the tag object id
2026-10-08 12:43:42 +02:00
Lorenz Leutgeb c4cc462483 Revert "remote-helper: Compute HEAD for user namespaces"
This reverts commit 2747c52beb.

I forgot that this is only supported from Git 2.48 onwards.
2026-10-08 12:34:56 +02:00
Yorgos Saslis 3129de3b95 cli/init: Warn about Vulnerability
All released versions of Radicle are affected by vulnerabilities [1] in the
network protocol: traffic is unencrypted and peers are not authenticated.
A network observer can read the contents of private repositories, and an
attacker can impersonate a node that to fetch them. No fix has been released
yet.

Since users may rely on private repositories being confidential, `rad
init` now warns about this before the interactive "Visibility" prompt,
so the warning is printed before the choice is made. The warning is printed
again in the epilogue whenever the created repository is private. This
also covers `--private`, which skips the prompt.

Update the `rad-init-private` and `rad-init-private-no-seed` examples
to match the new output.

[1]: https://radicle.dev/2026/09/23/disclosure-of-vulnerability-in-network-protocol
2026-10-05 16:36:47 +02:00
Lorenz Leutgeb d8298a1d4c treewide: Remove test_ prefix from test fns
This redundancy does not add much. These functions are already marked
via `#[test]`, and often times they are in a separate module named
"test" or "tests".
2026-09-08 14:47:53 +02:00
Daniel NormanandLorenz Leutgeb 4867917f37 radicle/canonical: Remove RawRules::matches
Testing revealed that the implementation violated RIP-0006, which
requires the most specific rule matching the target of `HEAD`
to use an `allow` of `delegates` and the document threshold.
`validate_head_rule` took the first match from `RawRules`, which orders
patterns lexicographically, so a glob could be validated in place of the
rule that actually governs the branch.
The issue here is that the correct order for matching patterns is only
guaranteed on `Rules`, but not on `RawRules`.

To prevent such errors in the future, remove `RawRules::matches`. This
requires some refactoring, and makes synthesis of the default branch
rule slightly less efficient in the worst case, but we are willing to
take that hit for a cleaner implementation.

Co-authored-by: Lorenz Leutgeb <lorenz.leutgeb@radicle.dev>
2026-09-01 19:41:02 +02:00
Lorenz Leutgeb fd4e4903d7 radicle, cli: Move Git versions
Move `struct Version` from `radicle` to `radicle-cli`, where it is used.
2026-08-30 23:53:25 +02:00
Lorenz Leutgeb 2747c52beb remote-helper: Compute HEAD for user namespaces
If a user pushes to the reference of the same name as the default branch
according to the identity document, expose this as `HEAD`, too.
2026-08-30 17:37:09 +02:00
Lorenz Leutgeb 138404df6f radicle: Rely less on ….project payload
Many codepaths error if the `xyz.radicle.project` payload is not present
in the identity document. Change these to fall back gracefully.

Loading of payloads is unified in `GetPayload`.

An important detail is that `PayloadError::NotFound` is removed, and
`Option` is used instead.
2026-08-30 17:37:09 +02:00
Lorenz Leutgeb de43682f16 rust: 1.97.1 → 1.98.0
The changes to `**/args.rs` are due to better linting: Clippy found that
we may use `as_chunks`. Note that this function was stabilized in 1.88.0.
2026-08-30 14:28:36 +02:00
Lorenz Leutgeb 3054779bfa windows: Set process creation flags
When executing programs on Windows, we suppress creating a new window,
and, if the process should continue to run in the background, we
explicitly create a new process group and detach.
2026-08-25 22:58:56 +02:00
Lorenz Leutgeb 9c06c4086a cli/patch: Spawn git for diffs directly
Spawning `rad diff` works, but prints a deprecation notice, because
`rad diff` itself is deprecated. `rad patch diff` however is not
deprecated and should just take a shortcut.
2026-08-25 20:39:29 +02:00
Lorenz Leutgeb 17ff650ec1 cli/node: Label Process ID
Resolve issue bb28940307 by clarifying
that the number printed is a process identifier.
2026-08-23 22:48:34 +02:00
Lorenz Leutgeb d66f7e598b cli, crypto: Comment keys in SSH Agent
To avoid confusion how the key ended up in SSH Agent, add a comment that
adds some explanation.

See also
<https://radicle.zulipchat.com/#narrow/channel/392584-Feedback/topic/ssh-key.20with.20comment.20in.20agent/with/618208959>.
2026-08-23 19:28:32 +02:00
Lorenz Leutgeb 31f3d08d63 radicle/cob/thread: Use timeline: IndexSet
Plenty conservative `debug_assert!`s, cause panics as soon as two
actions that should be added to the timeline appear within the same
operation. But there is no code in place to prevent this.

It also does not seem to be problematic to visit the same operation
multiple times (once per contained action).

A set that retains iteration order does the job.

Analysis of this bug was done over Zulip, see
<https://radicle.zulipchat.com/#narrow/channel/369873-Support/topic/radicle-node.201.2E10.20segfaults/with/616991470>.

`Update::Reviewed::review` is boxed due to:

    error: large size difference between variants
       --> crates/radicle-cli/src/terminal/patch/timeline.rs:158:1
        |
    158 | /  enum Update<'a> {
    159 | |      /// A revision of the patch was reviewed.
    160 | |      Reviewed { review: Review },
        | |      --------------------------- the largest variant contains at least 352 bytes
    161 | |      /// A revision of the patch was merged.
    162 | |/     Merged {
    163 | ||         author: Author<'a>,
    164 | ||         /// If the merge is none, this means that it was a fast-forward merge.
    165 | ||         merge: Option<Merge>,
    166 | ||     },
        | ||_____- the second-largest variant contains at least 120 bytes
    167 | |  }
        | |__^ the entire enum is at least 352 bytes
2026-08-23 19:15:09 +02:00
Lars WirzeniusandShawn Webb 52ac5d3b3e cli/debug: Add hardenedBsd detection
This is conditional on the target operating system being FreeBSDs.
HardenedBSD is FreeBSD but with changes. We determine which one it is,
by running 'sysctl --values hardening.version'.

Co-authored-by: Shawn Webb <shawn.webb@hardenedbsd.org>
2026-08-12 16:42:48 +02:00
Lars Wirzenius 9f05038234 cli/debug: Output /etc/os-release if available 2026-08-12 16:42:18 +02:00
Lorenz Leutgeb d18293c6ad cli/test: Do not accidentally test rad debug
The tests `rad-warn-ipv6.md` and `rad-warn-old-nodes.md` are meant to
primarily test the output of warnings. They test the output twice, via
`rad debug` and via `rad node status`.

Testing the output via one command should be sufficient.
2026-08-12 16:14:34 +02:00
Lorenz Leutgeb 4e3c274468 crypto, node: Randomly generate ephemeral keys 2026-08-12 15:28:40 +02:00
Lorenz Leutgeb a2eb756887 cli/id: Introduce rad id cache
Similar to `rad [issue|patch] cache`, this will re-compute cached state
about the identity document. The identity COB does not cache to SQLite,
but there is `refs/rad/id`, which can become stale.
2026-08-04 19:42:13 +02:00
Adrian Duke ca1b4fa7bc cli/id: Add verbose output to show and list 2026-08-04 19:34:56 +02:00
Adrian Duke c830053e32 cli/id: Incorporate reason for rejection 2026-08-04 19:34:34 +02:00
Lorenz Leutgeb 71a91042d9 cargo/workspace: Bump crate versions
In topological order:

 - radicle-git-metadata     0.2.0 →  0.2.1
 - radicle-git-ref-format   0.1.0 →  0.2.0
 - radicle-oid              0.2.1 →  0.2.2
 - radicle-crypto          0.18.0 → 0.19.0
 - radicle-surf            0.28.0 → 0.29.0
 - radicle-cob             0.21.0 → 0.21.1
 - radicle-core             0.4.0 →  0.4.1
 - radicle                 0.25.0 → 0.25.1
 - radicle-signals         0.12.0 → 0.12.1
 - radicle-fetch           0.21.0 → 0.21.1
 - radicle-term            0.19.0 → 0.19.1
 - radicle-protocol         0.9.0 →  0.9.1
 - radicle-cli-test        0.14.0 → 0.14.1
 - radicle-node            0.21.0 → 0.21.1
 - radicle-cli             0.22.0 → 0.23.0
 - radicle-schemars         0.9.0 →  0.9.1
 - radicle-remote-helper   0.18.0 → 0.18.1
2026-07-24 21:37:41 +02:00
Lorenz Leutgeb 36fc031da2 surf: Switch to crate in workspace
Now that `radicle-surf` lives in this workspace, use it.
2026-07-24 16:27:02 +02:00
Lorenz Leutgeb e373f80d08 cargo/workspace: Add repository metadata
Some `/crates/*/Cargo.toml` were missing to inherit repository package
metadata from `/Cargo.toml`.
2026-07-22 16:44:59 +02:00
Lorenz Leutgeb a0551416f9 cargo/workspace: Remove homepage
In `/Cargo.toml` and all `/crates/*/Cargo.toml`, remove homepage package
metadata. This field is inteded to carry the *homepage of the crate*. In
our case, no crate has an actual homepage on its own.
2026-07-22 16:44:58 +02:00
Lorenz Leutgeb 69a4da6ffb cargo/workspace: Reorder package metadata
In all `/crates/*/Cargo.toml`, split package metadata into two or three
blocks:

 1. name, version, and description (in this order)
 2. Further metadata defined per crate.
 3. References to the workspace.

Lines in blocks (2.) and (3.) are sorted lexicographically, and blocks
are separated by empty lines.
2026-07-22 16:44:58 +02:00
Lorenz Leutgeb 024006297d cargo/workspace: Remove package.authors metadata
This field is deprecated, see
<https://doc.rust-lang.org/cargo/reference/manifest.html#the-authors-field>.
2026-07-22 16:44:58 +02:00
Lorenz Leutgeb caf45f1525 cli: Tighten visibility and minimize pub use
In `radicle-cli`, which is a binary crate (!) a few `pub use`s can be
removed. This forces `radicle-remote-helper` to depend on the library
crate `radicle-term` to access some of the types that were re-exported
from `radicle-cli`, making the dependency more obvious, and minimizing
the public symbols on `radicle-cli`.

The dependency on `radicle-cli` cannot be removed from
`radicle-remote-helper` easily, so is kept.
2026-07-22 16:43:34 +02:00
Lorenz Leutgeb 2ae6301f86 cargo/workspace: Bump crate versions
In topological order:

 - radicle-crypto         0.17.0 → 0.18.0
 - radicle-oid             0.2.0 →  0.2.1
 - radicle-cob            0.20.0 → 0.21.0
 - radicle-core            0.3.0 →  0.4.0
 - radicle                0.24.0 → 0.25.0
 - radicle-signals        0.11.0 → 0.12.0
 - radicle-fetch          0.20.0 → 0.21.0
 - radicle-log             0.1.0 →  0.2.0
 - radicle-term           0.18.0 → 0.19.0
 - radicle-protocol        0.8.0 →  0.9.0
 - radicle-cli-test       0.13.0 → 0.14.0
 - radicle-node           0.20.0 → 0.21.0
 - radicle-cli            0.21.0 → 0.22.0
 - radicle-schemars        0.8.0 →  0.9.0
 - radicle-remote-helper  0.17.0 → 0.18.0
2026-07-22 13:12:19 +02:00
Lorenz Leutgeb 9eeecacf28 node: Remove re-export …::node::PROTOCOL_VERSION
It appears that `radicle_node::PROTOCOL_VERSION` (which is a re-export
of `radicle::node::PROTOCOL_VERSION` is the only symbol exported from
`radicle-node` that is used in `radicle-cli` (except tests).

Since `radicle-cli` depends on `radicle` anyway, it is questionable how
much sense that re-export and use from a binary crate (!) makes.

Remove the re-export.
2026-07-21 12:28:10 +02:00
Lorenz LeutgebandFintan Halpenny df6524e7e2 crypto: Rewrite
Reasons for the rewrite:
 - Migrate away from `ec25519` as our implementation of Ed25519,
   because that crate is unmaintained.
   Instead of `ec25519` we use `ed25519-dalek` which is the most popular
   implementation of Ed25519 in Rust.
 - Migrate away from `amplify`, because we make very little use of its
   features. Here, we only use `amplify::Bytes32`, which is just a thin
   wrapper of `[u8; 32]`.
   Instead of `amplify::Bytes32` we use `type PublicKeyBytes = [u8; 32]`.

The realization that `ExtendedSignature` is not really tied to SSH, but
is merely a representation of a key together with a signature, allows to
relax the bounds on traits in `radicle-cob`.

Separating out uses of "public key" (a rather simple model of a key,
just 32 bytes) and "verifying key" (an actual point on the Edwards
curve, ready to verify signatures, using more memory than just 32 bytes)
allows a more sensible definition of `crypto::Signer`, which propagates
to `radicle-cob`, `radicle`, `radicle-cli`, `radicle-node` and
simplifies trait bounds.

In `radicle-node`, make the fact clearer that actually the secret key
itself is required (for our implementation of Diffie-Hellman) not
"just" signing. This results in removal of the generic argument
(usually called `G`) of multiple types.

Concretizing the types in `radicle-node` this way, i.e. by (morally)
setting `G = radicle_crypto::SigningKey`, leads to removal of
`MemorySigner` and `MockSigner`, as they really just wrap a signing
key.

Re-exporting `ed25519::Signature` (via re-export in `ed25519-dalek`)
is hopefully more future-proof than using our own type for signatures.
However, the fact that `ed25519::Signature` is not serializable and
does not implement `std::hash::Hash` means that we have to resort to
ad-hoc solutions in `radicle`:
 1. The Identity COB requires serialization of signatures. These are
    generally questionable, since the security of the Identity COB
    should rely on the security of Signed References. In the medium
    term we might even want to consider ignoring signatures in actions.
 2. When reading Signed References, detection of Replay Attacks uses
    a `HashMap` keyed by signatures. This detection only exists for
    backwards compatibility.
These two use cases are exotic enough to warrant ad-hoc implementations.
By not wrapping `ed25519::Signature`, we encourage writing more widely
compatible code in the future.

Co-authored-by: Fintan Halpenny <fintan.halpenny@gmail.com>
2026-07-21 09:19:01 +02:00
Lorenz Leutgeb 0fd0104e87 radicle, cli/auth: Let binary crate generate seed
In preparation of a rewrite of `radicle-crypto`, move the
responsibility for generating a cryptographically secure
seed from `radicle` (transitively via dependency on
`radicle-crypto` and `ec25519`) to the dependent of `radicle`.

Applications should decide how to obtain randomness, not `radicle` via
some far-removed dependency.

Within the workspace, the only dependent using `Profile::seed` is
`radicle-cli`, in particular for the `rad auth` subcommand. To obtain
random bytes, `radicle-cli` depends on `getrandom` and uses
`getrandom::fill`.
2026-07-17 16:52:33 +01:00
zebus 66ab7f35c9 treewide: Add configurable per-stream fetch timeout
This introduces a `fetch_timeout` setting to the node configuration,
replacing the hardcoded constant. It defines the duration a fetch stream
is allowed to stall before being aborted. The default remains 30s, but
users on anonymizing transports like Tor can now increase it to avoid
spurious timeouts during network congestion.
2026-07-17 17:05:11 +02:00
Lorenz Leutgeb f31fbf40ce rust: 1.95 → 1.97.1
The update to `flake.lock` is a simple

    nix flake update rust-overlay

to be able to reach 1.97.1.

The changes to `**/*.rs` files are improvements suggested by Clippy.
2026-07-17 10:29:56 +02:00
Lorenz Leutgeb 564c167de1 git2: 0.20 → 0.21
Update `git2` due to
 - https://rustsec.org/advisories/RUSTSEC-2026-0008.html
 - https://rustsec.org/advisories/RUSTSEC-2026-0183.html
 - https://rustsec.org/advisories/RUSTSEC-2026-0184.html
2026-07-16 14:37:32 +02:00
Fintan Halpenny bdbe1e407b cli: Remove unused dependencies
`tree-sitter` and `pretty-assertions` are no longer used.
2026-07-15 13:05:46 +02:00
Fintan Halpenny b6f07074d9 radicle/cob/identity: Guard IdentityMut::accept against sibling accepts
Ensure that the `IdentityMut::accept` API returns an error when it encounters an
active, sibling revision by the same delegate.
2026-07-08 15:31:45 +01:00
Fintan Halpenny 7daeb3135b radicle/cob/identity: Add SiblingAccepted error variant
Add an `ApplyError` for variant, `SiblingAccepted`, to use to enforce the new
invariant: delegates must not accept active, sibling revisions.
2026-07-08 15:31:45 +01:00