Skip to content

test(node): cover the component walk in validated_repo_disk_path (#411) - #441

Open
beardthelion wants to merge 1 commit into
mainfrom
test/issue-411-component-walk-coverage
Open

test(node): cover the component walk in validated_repo_disk_path (#411)#441
beardthelion wants to merge 1 commit into
mainfrom
test/issue-411-component-walk-coverage

Conversation

@beardthelion

@beardthelion beardthelion commented Sep 11, 2026

Copy link
Copy Markdown
Collaborator

Summary

Closes #411. validated_repo_disk_path has three layers and the existing tests only exercised the first: every traversal input goes through owner_did/repo_name, which validate_path_components refuses before the starts_with check and the Component walk run. The walk was unfalsifiable; the issue demonstrated that emptying the ParentDir arm left the suite green.

The walk is reachable through repos_dir itself: the allowlist never sees it, PathBuf::join does not normalize it, and the component-wise starts_with still matches the unnormalized prefix, so ParentDir/CurDir land on the walk. Three tests: repos_dir containing .. is rejected by the ParentDir arm, a relative repos_dir starting with . is rejected by the CurDir arm (interior . segments are dropped by components() and never reach the walk, so the leading-dot relative path is the shape that covers it), and a clean repos_dir resolves.

Test plan

  • cargo test -p gitlawb-node repo_store passes, including the three new tests.
  • Load-bearing check: with both walk arms emptied, the two reject tests fail while the clean-dir control still passes; restored, all three pass.
  • cargo test --workspace green (one unrelated coalesced-push announce test flaked under concurrent-suite load and passed on an isolated rerun). cargo clippy --workspace --all-targets -- -D warnings clean via the pre-push gate.

Notes

Summary by CodeRabbit

  • Tests
    • Added coverage verifying that repository directory paths with unsafe path components are rejected.
    • Added coverage confirming that clean directory paths are accepted.

@beardthelion
beardthelion requested a review from jatmn September 11, 2026 14:32
@coderabbitai

coderabbitai Bot commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Essentials

Run ID: a8ea2ee9-1080-4210-80af-073372a28ee5

📥 Commits

Reviewing files that changed from the base of the PR and between bfc44f9 and 4485f07.

📒 Files selected for processing (1)
  • crates/gitlawb-node/src/git/repo_store.rs

Included review availability: 3 reviews are currently available. Your included PR review attempts over the past 7 days set your current allowance at 5 reviews per hour.


📝 Walkthrough

Walkthrough

The change adds tests for validated_repo_disk_path. The tests cover rejection of .. and surviving leading . components in repos_dir, plus acceptance of a clean path.

Changes

Repository path validation

Layer / File(s) Summary
Component-walk validation tests
crates/gitlawb-node/src/git/repo_store.rs
Tests cover unsafe parent-directory and current-directory components in repos_dir, along with a valid clean path.

Priority: ⬇️ Low

Estimated code review effort: 1 (Trivial) | ~5 minutes

Change: Other

Suggested reviewers: gravirei

Merge Risk: ⚪ Minimal · up to 4485f

The tests provide the intended component-walk coverage, including current-directory rejection, parent-directory rejection, and clean-path acceptance.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the change: adding tests for the component walk in validated_repo_disk_path. It is concise and uses a Conventional Commit format.
Description check ✅ Passed The description explains the motivation, changed tests, verification commands, issue link, scope, and overlap risks. It does not reproduce every template heading or checklist, but it provides the requ…
Linked Issues check ✅ Passed The PR meets the coding requirement in issue #411. It adds tests in crates/gitlawb-node/src/git/repo_store.rs that pass a repos_dir containing .. and assert rejection. It also tests a leading-do…
Out of Scope Changes check ✅ Passed The change is limited to 33 added test lines in repo_store.rs. The tests directly support issue #411. The PR does not modify exported declarations or add unrelated implementation changes.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 1 files.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch test/issue-411-component-walk-coverage

Comment @coderabbitai help to get the list of available commands.

@beardthelion beardthelion added crate:node gitlawb-node — the serving node and REST API kind:test Test coverage or harness labels Sep 11, 2026
@greptile-apps

greptile-apps Bot commented Sep 11, 2026

Copy link
Copy Markdown

Greptile Summary

This PR adds focused regression coverage for the component walk in validated_repo_disk_path.

  • Verifies that parent-directory components introduced through repos_dir are rejected.
  • Verifies that a leading current-directory component in a relative repos_dir is rejected.
  • Adds a clean-directory control confirming valid paths remain accepted.

Confidence Score: 5/5

The PR appears safe to merge; the added tests directly cover the intended component-walk branches without changing production behavior.

Both malformed repos_dir inputs pass earlier validation and fail specifically in their targeted component-walk arms, while the clean control confirms valid paths still resolve.

Important Files Changed

Filename Overview
crates/gitlawb-node/src/git/repo_store.rs Adds sound positive and negative tests that directly exercise the previously uncovered Component::ParentDir and Component::CurDir validation branches.

Reviews (1): Last reviewed commit: "test(node): cover the component walk in ..." | Re-trigger Greptile

@jatmn jatmn left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

crate:node gitlawb-node — the serving node and REST API kind:test Test coverage or harness

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Only the allowlist layer of validated_repo_disk_path is covered: the component walk has no test that reaches it

2 participants