Skip to content
Closed
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
2a8d64d
feat(core)!: verify_chain returns the proof chain's root issuer
Vasanthdev2004 Aug 14, 2026
13a2424
fix(node): gate two Unix-only tests so the crate compiles on Windows
Vasanthdev2004 Aug 14, 2026
1b1c972
feat(node): carry the verified UCAN and its root into the request
Vasanthdev2004 Aug 14, 2026
f8b9cf1
feat(node): add ucan_grants_push, anchored at the repo owner
Vasanthdev2004 Aug 14, 2026
d27f0be
feat(node): honour a delegated git/push capability on the push path
Vasanthdev2004 Aug 14, 2026
d141e59
feat(gl): gl ucan import stores a delegation for the push helper
Vasanthdev2004 Aug 14, 2026
3d81f57
feat(git-remote): send a delegated push capability as X-Ucan
Vasanthdev2004 Aug 14, 2026
8843c4f
test(git-remote): cover pack-POST URL splitting
Vasanthdev2004 Aug 14, 2026
a9e9c48
build: sync Cargo.lock for the git-remote-gitlawb dependencies
Vasanthdev2004 Aug 14, 2026
f455726
fix(core,gl,git-remote): close two review findings on delegated push
Vasanthdev2004 Aug 14, 2026
a2502fc
fix(core,node,gl,git-remote): close the second review round on delega…
Vasanthdev2004 Aug 14, 2026
d503655
fix(gl): restrict the delegations directory, and state the contract
Vasanthdev2004 Aug 14, 2026
5071524
fix(gl,git-remote): make a delegation issued the documented way actua…
Vasanthdev2004 Aug 15, 2026
5dfd8c5
fix(gl): refuse a relative or non-UTF-8 GITLAWB_KEY when deriving the…
Vasanthdev2004 Aug 15, 2026
e15fa73
fix(identity): one resolver for GITLAWB_KEY across gl and the helper
Vasanthdev2004 Aug 16, 2026
05fc52d
test(git-remote): cover delegation_header end to end
Vasanthdev2004 Aug 16, 2026
75aa1a0
fix(gl): finish the identity-path sweep on the write side
Vasanthdev2004 Aug 16, 2026
fad75a6
fix(gl,core): close round five — lazy home, envelope reads, honest re…
Vasanthdev2004 Aug 18, 2026
82f2484
fix(node,gl,git-remote): enforce repo narrowing at the node, honour t…
Vasanthdev2004 Aug 22, 2026
a47ea93
fix(gl): align the MCP ucan_show tool with gl ucan show
Vasanthdev2004 Aug 22, 2026
ec4399c
fix(gl): drop a needless borrow in quickstart's unix key write
Vasanthdev2004 Aug 22, 2026
1ab55e5
fix(node,gl,git-remote): fix a delegation's scope at issuance
Vasanthdev2004 Aug 22, 2026
89fa647
Merge origin/main into feat/ucan-push-authorization
Vasanthdev2004 Aug 27, 2026
9cf48f5
fix(gl): drop an unused import in the unix-only refresh tests
Vasanthdev2004 Aug 27, 2026
04e7941
fix(node): pass the UCAN extension at the last two receive-pack call …
Vasanthdev2004 Aug 27, 2026
f79309b
fix(core,node,gl,git-remote): one definition of a usable push capability
Vasanthdev2004 Sep 8, 2026
4dc62b2
fix(node): drop repo_capability_matches, orphaned by the shared push …
Vasanthdev2004 Sep 8, 2026
1da4251
fix(core,gl): bound every proof-chain walk and make verify report the…
Vasanthdev2004 Sep 8, 2026
fb831b1
docs: state the two gates a delegated push crosses, and finish the sweep
Vasanthdev2004 Sep 8, 2026
8b91f28
fix(gl): store one repository per imported delegation; pin the two-ga…
Vasanthdev2004 Sep 8, 2026
e3314c6
fix(gl,core): sanitize token-derived output, prove the publish step, …
Vasanthdev2004 Sep 8, 2026
1b5cb7d
test(gl): count the MCP tool list at 41 with ucan_import
Vasanthdev2004 Sep 8, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix(gl): refuse a relative or non-UTF-8 GITLAWB_KEY when deriving the…
… store

Two defects in the previous round's fix, both of which put the delegation
somewhere the helper does not look and end as an unexplained 403.

A relative GITLAWB_KEY resolved differently in each half. `gl ucan import` and
`git-remote-gitlawb` do not share a working directory, so `keys/identity.pem`
sends the import to one `delegations` directory and the lookup to another. A
one-component value is worse: `parent()` yields "", so the store becomes
`./delegations` relative to whatever directory happened to be current. It is now
refused with a message that says why, rather than silently resolved.

`std::env::var` returns Err for a non-UTF-8 value, which the code treated as
unset — indistinguishable from having no GITLAWB_KEY at all, and silently
selecting ~/.gitlawb instead of the operator's real key directory. `var_os`
keeps the OsString, so a valid non-UTF-8 path now works and an empty one is
still treated as unset.
  • Loading branch information
Vasanthdev2004 committed Aug 16, 2026
commit 5dfd8c5874a46cd501b3b2a6d566271415fc82a0
83 changes: 76 additions & 7 deletions crates/gl/src/identity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,33 @@ pub fn gitlawb_dir(override_dir: Option<PathBuf>) -> Result<PathBuf> {
if let Some(d) = override_dir {
return Ok(d);
}
if let Ok(key) = std::env::var("GITLAWB_KEY") {
if !key.trim().is_empty() {
let path = if let Some(rest) = key.strip_prefix("~/") {
dirs::home_dir()
// `var_os`, not `var`: a non-UTF-8 value makes `var` return Err, which would be
// indistinguishable from unset and would silently select ~/.gitlawb instead of
// the operator's actual key directory.
if let Some(raw) = std::env::var_os("GITLAWB_KEY") {
let key = PathBuf::from(&raw);
if !key.as_os_str().is_empty() {
let path = match key.strip_prefix("~") {
Ok(rest) => dirs::home_dir()
.context("could not determine home directory")?
.join(rest)
} else {
PathBuf::from(key)
.join(rest),
Err(_) => key,
};
// A relative GITLAWB_KEY is refused rather than resolved. `gl` and
// `git-remote-gitlawb` run with different working directories, so a
// relative path makes them derive different delegation stores — the
// import lands somewhere the helper never looks, and the push is refused
// with nothing to indicate why. A one-component value is worse still:
// `parent()` yields "", so the store becomes `./delegations`.
if !path.is_absolute() {
anyhow::bail!(
"GITLAWB_KEY must be an absolute path (got {}). It determines where \
delegations are stored, and `gl` and `git-remote-gitlawb` do not \
share a working directory, so a relative path sends them to \
different places.",
path.display()
);
}
if let Some(parent) = path.parent() {
return Ok(parent.to_path_buf());
}
Expand Down Expand Up @@ -532,3 +550,54 @@ mod tests {
assert_eq!(original_did, dst_kp.did());
}
}

#[cfg(test)]
mod gitlawb_dir_tests {
use super::gitlawb_dir;
use std::path::PathBuf;

/// An explicit --dir always wins and is never validated against GITLAWB_KEY.
#[test]
fn explicit_override_wins() {
let d = PathBuf::from("/tmp/explicit");
assert_eq!(gitlawb_dir(Some(d.clone())).unwrap(), d);
}

/// A relative GITLAWB_KEY must fail loudly. `gl` and `git-remote-gitlawb` run
/// from different working directories, so resolving one relatively sends the
/// import and the lookup to different stores; a one-component value yields an
/// empty parent and puts the store in `./delegations`.
///
/// Serialised with the other env-touching case: the process environment is
/// global and these would otherwise race.
#[test]
fn relative_and_nonunicode_key_paths() {
use std::sync::Mutex;
static LOCK: Mutex<()> = Mutex::new(());
let _guard = LOCK.lock().unwrap_or_else(|e| e.into_inner());

let restore = std::env::var_os("GITLAWB_KEY");

std::env::set_var("GITLAWB_KEY", "identity.pem");
let one_component = gitlawb_dir(None);
std::env::set_var("GITLAWB_KEY", "keys/identity.pem");
let relative = gitlawb_dir(None);
std::env::set_var("GITLAWB_KEY", "");
let empty = gitlawb_dir(None);

match restore {
Some(v) => std::env::set_var("GITLAWB_KEY", v),
None => std::env::remove_var("GITLAWB_KEY"),
}

assert!(
one_component.is_err(),
"a one-component key path yields an empty parent and must be refused"
);
assert!(relative.is_err(), "a relative key path must be refused");
assert!(
empty.is_ok(),
"an empty value is treated as unset, not as an error"
);
}
}