Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
6633d17
fix(node): bound REST blob reads
Sep 7, 2026
95d295c
test(node): cover blob authorization denials.
Sep 7, 2026
d824cfa
fix(node): Hide Git diagnostics from blob error responses.
Sep 9, 2026
3d7032b
fix(node): close REST blob admission and error gaps
Sep 9, 2026
fc2d043
fix(node): acquire blob permits pre-DB and cover route/fallback arms
Sep 10, 2026
c63527c
fix(node): confirm blob absence against a readable store
Sep 12, 2026
8977ed4
fix(node): bound REST blob response delivery
Sep 12, 2026
e1fe66e
test(git): distinguish every bounded ref fallback
Sep 12, 2026
4344b77
docs(node): describe the cat-file blob read path
Sep 12, 2026
49aebb2
fix(node): prevent caching of authorized blob content
Sep 12, 2026
c566455
fix(node): pin non-blob denial and map unreadable store to 503
Sep 12, 2026
df5a283
style(repos): simplify blob semaphore permit assertion for clippy
Sep 13, 2026
f0d0025
fix(git): classify unreadable store with ProbeError and tighten blob …
Sep 13, 2026
eb1222d
test(node): assert full blob admission release after read errors
Sep 14, 2026
c15acf5
test(git): require probe completion before reprobe budget denial
Sep 14, 2026
77e9b76
test(node): make Windows regression fixtures portable
Sep 14, 2026
5d238ca
fix(sync): use a supported Windows promisor blob filter
Sep 14, 2026
2c7f60a
test(git): route write-then-exec fixtures through write_blob_probe_fi…
Sep 15, 2026
2bb398e
test(sync): assert configured partialclonefilter and pin platform con…
Sep 15, 2026
bbab52e
test(api,git): close write-fd window in exec'd fixtures
Sep 17, 2026
ad003b3
fix(api): clamp authorize_repo_read with acquire timeout in get_blob
Sep 18, 2026
a2c996a
docs(config): describe the blob authorization deadline
Sep 20, 2026
5f588c1
test(api): bound the blob authorization timeout regression
Sep 20, 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
test(node): make Windows regression fixtures portable
Gate Unix-only helpers with their callers, replace shell timing shims
with native Rust fixtures, and normalize rooted fixture paths without a
drive prefix. Distinguish admission rejection from a closed database by
error code, since both correctly return HTTP 503.

Refs #407
  • Loading branch information
euxaristia
euxaristia committed Sep 14, 2026
commit 77e9b76e5562f126bf7471fb95db2ab509bc1647
18 changes: 13 additions & 5 deletions crates/gitlawb-node/src/api/ipfs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8338,6 +8338,7 @@ mod tests {
#[tokio::test]
async fn get_by_cid_per_source_cap_sheds_same_source_admits_other() {
let mut state = crate::test_support::test_state_lazy();
state.db.pool().close().await;
// Global pool has room; the per-source cap is 1.
state.git_ipfs_walk_semaphore = Arc::new(Semaphore::new(8));
state.git_ipfs_walk_per_caller = crate::rate_limit::PerCallerConcurrency::new(1, 100);
Expand All @@ -8364,16 +8365,23 @@ mod tests {
"a source at its per-source /ipfs walk cap must shed 503 with global capacity free"
);

let bytes = axum::body::to_bytes(resp.into_body(), 1024).await.unwrap();
let body: serde_json::Value = serde_json::from_slice(&bytes).unwrap();
assert_eq!(body["error"], "overloaded");

// A DIFFERENT source is NOT shed by the per-source cap: it clears admission and
// proceeds (then errors on the lazy DB, which is not a 503).
// proceeds to the closed DB, which has a distinct db_unavailable error code.
let resp = ipfs_router(state)
.oneshot(get_cid(&cid, Some(other)))
.await
.unwrap();
assert_ne!(
resp.status(),
StatusCode::SERVICE_UNAVAILABLE,
"a different source must not be shed by the per-source cap"
assert_eq!(resp.status(), StatusCode::SERVICE_UNAVAILABLE);
let bytes = axum::body::to_bytes(resp.into_body(), 1024).await.unwrap();
let body: serde_json::Value = serde_json::from_slice(&bytes).unwrap();
assert_eq!(
body["error"],
crate::error::DB_UNAVAILABLE_CODE,
"a different source must clear admission and reach the closed database"
);
}

Expand Down
14 changes: 14 additions & 0 deletions crates/gitlawb-node/src/api/repos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7785,6 +7785,7 @@ mod tests {
/// A pkt-line receive-pack body carrying one branch-create ref update, so the
/// handler's post-receive tail resolves a non-empty new-tip set (the delta
/// scan's git stages run).
#[cfg(unix)]
fn ref_update_body(new_sha: &str) -> axum::body::Bytes {
let line = format!("{ZERO_SHA} {new_sha} refs/heads/main");
axum::body::Bytes::from(format!("{:04x}{}0000", line.len() + 4, line))
Expand Down Expand Up @@ -10242,13 +10243,15 @@ mod tests {
)
}

#[cfg(unix)]
fn f2a_log(log: &std::path::Path) -> String {
std::fs::read_to_string(log).unwrap_or_default()
}

/// Withheld-walk children run so far. `ls-tree` is the walk's signature child
/// (`blob_paths` lists every reachable commit's tree); the delta scan and the
/// full-scan fallback use `rev-list` / `cat-file` instead.
#[cfg(unix)]
fn f2a_walks(log: &std::path::Path) -> usize {
f2a_log(log)
.lines()
Expand All @@ -10260,6 +10263,7 @@ mod tests {
/// the withheld walk actually runs rather than taking the no-rule shortcut).
/// The repo's on-disk path is passed to the tail directly, so no repo_store or
/// receive-pack plumbing is involved.
#[cfg(unix)]
async fn f2a_state(
pool: sqlx::PgPool,
git_bin: &str,
Expand Down Expand Up @@ -10291,6 +10295,7 @@ mod tests {
(state, rec)
}

#[cfg(unix)]
fn f2a_update(ref_name: &str, new_sha: &str) -> Vec<RefUpdate> {
vec![RefUpdate {
old_sha: ZERO_SHA.to_string(),
Expand All @@ -10299,6 +10304,7 @@ mod tests {
}]
}

#[cfg(unix)]
const F2A_PUSHER: &str = "did:key:z6MkF2aPusherAAAAAAAAAAAAAAAAAAAAAAAAAA";

/// Scenario 1 (the finding). A second rapid push to the same repo coalesces
Expand Down Expand Up @@ -10372,6 +10378,7 @@ mod tests {
}
/// Poll `cond` until it holds, with a bound so a regression fails the test
/// rather than hanging the suite.
#[cfg(unix)]
async fn f2a_wait_for(mut cond: impl FnMut() -> bool, what: &str) {
let deadline = std::time::Instant::now() + std::time::Duration::from_secs(20);
while !cond() {
Expand All @@ -10386,6 +10393,7 @@ mod tests {
/// A `rev-list --objects` line names the tips a DELTA scan was asked to resolve,
/// so it attributes that scan to one push's tips. The withheld walk's own
/// `rev-list --all` / `ls-tree` lines never carry a tip as an argument this way.
#[cfg(unix)]
fn f2a_delta_scanned(log: &std::path::Path, tip: &str) -> bool {
f2a_log(log)
.lines()
Expand Down Expand Up @@ -10532,6 +10540,7 @@ mod tests {

/// Mount a Pinata upload endpoint that assigns every object the same CID, and
/// point the state at it. Returns the server (kept alive by the caller) and CID.
#[cfg(unix)]
async fn f2a_pinata(state: &mut AppState) -> (mockito::ServerGuard, String) {
let cid = "bafyf2acoalescedmapping".to_string();
let mut server = mockito::Server::new_async().await;
Expand All @@ -10551,6 +10560,7 @@ mod tests {

/// Poll the branch to CID table until the push's mapping lands (the Pinata
/// worker is detached), bounded so a regression fails rather than hangs.
#[cfg(unix)]
async fn f2a_wait_for_branch_cid(
db: &crate::db::Db,
slug: &str,
Expand All @@ -10570,6 +10580,7 @@ mod tests {
}
}

#[cfg(unix)]
fn f2a_slug(rec: &crate::db::RepoRecord) -> String {
format!(
"{}/{}",
Expand Down Expand Up @@ -10703,6 +10714,7 @@ mod tests {
// and `z6p2fail`), and owner-only push is on by default, so the identity has to
// follow the repo each push targets rather than being fixed for both.

#[cfg(unix)]
fn p2_push(
state: &AppState,
owner: &str,
Expand All @@ -10721,6 +10733,7 @@ mod tests {
)
}

#[cfg(unix)]
fn p2_logged(log: &std::path::Path, prefix: &str) -> bool {
f2a_log(log).lines().any(|l| l.starts_with(prefix))
}
Expand Down Expand Up @@ -11020,6 +11033,7 @@ mod tests {
/// runs exactly one `rev-list --all`, so this counts the walks that were attempted
/// (the `ls-tree` counter above cannot: a walk whose enumeration fails never gets
/// to `ls-tree`).
#[cfg(unix)]
fn f2b_walk_attempts(log: &std::path::Path) -> usize {
f2a_log(log)
.lines()
Expand Down
4 changes: 2 additions & 2 deletions crates/gitlawb-node/src/git/repo_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ impl RepoStore {
/// Test-only: every guard from this store parks in `release` right before the
/// `pg_advisory_unlock` await, until `gate` is notified. Dropping the future
/// while it is parked reproduces a client disconnect inside `release`.
#[cfg(test)]
#[cfg(all(test, unix))]
pub fn with_pre_unlock_gate(mut self, gate: Arc<tokio::sync::Notify>) -> Self {
self.pre_unlock_gate = Some(gate);
self
Expand All @@ -107,7 +107,7 @@ impl RepoStore {

/// Test-only: how many write guards from this store have reached the Tigris upload
/// site. See [`RepoStore::upload_site_reached`].
#[cfg(test)]
#[cfg(all(test, unix))]
pub fn tigris_upload_site_reached(&self) -> usize {
self.upload_site_reached
.load(std::sync::atomic::Ordering::SeqCst)
Expand Down
1 change: 1 addition & 0 deletions crates/gitlawb-node/src/ipfs_pin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2534,6 +2534,7 @@ mod tests {
/// type probe carries its oid on stdin rather than in argv, so an oid appears in
/// the log only once an object has already got past its probe, and a healthy
/// object costs two invocations to a faulting one's one.
#[cfg(unix)]
fn objects_attempted(log: &std::path::Path) -> usize {
std::fs::read_to_string(log)
.unwrap_or_default()
Expand Down
1 change: 1 addition & 0 deletions crates/gitlawb-node/src/pinata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -911,6 +911,7 @@ mod tests {
/// probe carries its oid on stdin rather than in argv, so an oid appears in the log only
/// once an object has already got past its probe, and a healthy object costs two
/// invocations to a faulting one's one.
#[cfg(unix)]
fn objects_attempted(log: &std::path::Path) -> usize {
std::fs::read_to_string(log)
.unwrap_or_default()
Expand Down
24 changes: 20 additions & 4 deletions crates/gitlawb-node/src/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1250,6 +1250,18 @@ mod tests {
.await;
}

/// Use a rooted path without a Windows drive prefix in the remote fixture.
/// The destination still resolves on the temp directory's current drive,
/// while the remote's relative path contains no illegal colon component.
fn absolute_slug_path(path: &Path) -> String {
assert!(path.is_absolute());
path.components()
.filter(|part| !matches!(part, std::path::Component::Prefix(_)))
.collect::<std::path::PathBuf>()
.to_string_lossy()
.replace('\\', "/")
}

#[sqlx::test]
async fn process_batch_rejects_slug_escaping_repos_dir(pool: PgPool) {
// The verified escape from #272: `PathBuf::join` discards everything
Expand All @@ -1265,12 +1277,13 @@ mod tests {
// fails on but leaves the parent it created, so assert on both.
let outside = TempDir::new().unwrap();
let escape_dir = outside.path().join("nest");
let slug = format!("a/{}/escape", escape_dir.display());
let escape_path = absolute_slug_path(&escape_dir);
let slug = format!("a/{escape_path}/escape");
let escape_target = escape_dir.join("escape.git");

// Serve the composed URL for real, so a run without the guard genuinely
// clones outside the root rather than merely failing at git.
let rel = format!("a{}/escape", escape_dir.display());
let rel = format!("a{escape_path}/escape");
let (_remote, peer_url) = rooted_remote(&[&rel]);

let did = "did:key:z6MkAttacker";
Expand Down Expand Up @@ -1390,6 +1403,7 @@ mod tests {
// ── canonical containment before the git call (issue #272) ───────────────

/// Every ref in `repo`, as one string, for a before/after comparison.
#[cfg(unix)]
fn refs_of(repo: &Path) -> String {
let out = Command::new("git")
.args(["-C", repo.to_str().unwrap(), "for-each-ref"])
Expand Down Expand Up @@ -1722,6 +1736,7 @@ mod tests {
/// starvation tests is fixed rather than dependent on how fast the loop
/// runs. Two rows enqueued in the same microsecond would otherwise order
/// arbitrarily.
#[cfg(unix)]
async fn enqueue_at(db: &Db, pool: &PgPool, repo: &str, did: &str, enqueued_at: &str) {
enqueue(db, repo, did).await;
sqlx::query("UPDATE sync_queue SET enqueued_at = $1 WHERE repo = $2")
Expand Down Expand Up @@ -1915,7 +1930,8 @@ mod tests {

let outside = TempDir::new().unwrap();
let escape_dir = outside.path().join("nest");
let slug = format!("a/{}/gitlawb-probe", escape_dir.display());
let escape_path = absolute_slug_path(&escape_dir);
let slug = format!("a/{escape_path}/gitlawb-probe");
let escape_target = escape_dir.join("gitlawb-probe.git");

// Two things this fixture must get right or the test is green for the
Expand All @@ -1926,7 +1942,7 @@ mod tests {
// run without the guard genuinely clones outside the root instead of
// just failing at git. Db::upsert_peer cannot seed this row: it gates on
// is_public_http_url, which rejects file://.
let rel = format!("a{}/gitlawb-probe", escape_dir.display());
let rel = format!("a{escape_path}/gitlawb-probe");
let (_remote, peer_url) = rooted_remote(&[&rel]);
let did = "did:key:z6MkAttacker";
seed_local_peer(&pool, did, &peer_url).await;
Expand Down
75 changes: 75 additions & 0 deletions crates/gitlawb-node/src/test_git_shim.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
//! Native Git fixtures shared by timing tests on Unix and Windows.

use std::ops::Deref;
use std::path::{Path, PathBuf};
use std::sync::OnceLock;

/// The fixture delays or hangs in its own process, so the production watchdog
/// can terminate it without depending on a shell or descendant process support.
pub(super) enum Behavior<'a> {
Delay(u64),
Hang,
HangOid(&'a str),
HangRepo(&'a str),
LogTypes(&'a Path),
}

pub(super) struct GitShim {
_directory: tempfile::TempDir,
executable: PathBuf,
}

impl Deref for GitShim {
type Target = Path;

fn deref(&self) -> &Path {
&self.executable
}
}

pub(super) fn create(name: &str, behavior: Behavior<'_>) -> GitShim {
static COMPILED: OnceLock<tempfile::TempDir> = OnceLock::new();
let compiled = COMPILED.get_or_init(|| {
let directory = tempfile::tempdir().expect("native Git fixture directory");
let source = directory.path().join("git_shim.rs");
std::fs::write(&source, include_str!("../tests/fixtures/git_shim.rs"))
.expect("write native Git fixture source");
let executable = directory
.path()
.join(format!("git-shim{}", std::env::consts::EXE_SUFFIX));
let output =
std::process::Command::new(std::env::var_os("RUSTC").unwrap_or_else(|| "rustc".into()))
.arg("--edition=2021")
.arg("-Dwarnings")
.arg(&source)
.arg("-o")
.arg(executable)
.output()
.expect("compile native Git fixture with the installed Rust toolchain");
assert!(
output.status.success(),
"{}",
String::from_utf8_lossy(&output.stderr)
);
directory
});
let directory = tempfile::Builder::new()
.prefix(name)
.tempdir()
.expect("Git fixture instance");
let file_name = format!("git-shim{}", std::env::consts::EXE_SUFFIX);
let executable = directory.path().join(&file_name);
std::fs::copy(compiled.path().join(file_name), &executable).expect("copy native Git fixture");
let config = match behavior {
Behavior::Delay(milliseconds) => format!("delay\n{milliseconds}"),
Behavior::Hang => "hang\n".to_owned(),
Behavior::HangOid(oid) => format!("hang-oid\n{oid}"),
Behavior::HangRepo(repo) => format!("hang-repo\n{repo}"),
Behavior::LogTypes(path) => format!("log-types\n{}", path.display()),
};
std::fs::write(directory.path().join("config"), config).expect("configure native Git fixture");
GitShim {
_directory: directory,
executable,
}
}
Loading