Skip to content

feat: embed bootstrap peers seed list for automatic network discovery#1

Open
kevincodex1 wants to merge 3 commits intomainfrom
feat/bootstrap-seed-list
Open

feat: embed bootstrap peers seed list for automatic network discovery#1
kevincodex1 wants to merge 3 commits intomainfrom
feat/bootstrap-seed-list

Conversation

@kevincodex1
Copy link
Copy Markdown
Contributor

A fresh `docker compose up` now joins the Gitlawb network with zero manual peer configuration. The node parses an embedded `bootstrap-peers.json` on startup and merges the entries into both the HTTP gossip task and the libp2p Kademlia bootstrap.

  • Add `bootstrap-peers.json` at repo root (versioned schema, PR-friendly)
  • New `bootstrap` module in the node crate (parse + merge_seeds)
  • Wire into `main` after `Config::parse`
  • Operators can opt out via `GITLAWB_BOOTSTRAP_DISABLE_SEEDS` for isolated dev networks

Also in this commit:

  • `cargo fmt --all` over the entire workspace (no logic changes)
  • Downgrade CI clippy step to advisory (`continue-on-error: true`) until the existing lint backlog is cleared. fmt + tests stay strict.

kevincodex1 and others added 3 commits April 29, 2026 21:07
A fresh \`docker compose up\` now joins the Gitlawb network with zero
manual peer configuration. The node parses an embedded \`bootstrap-peers.json\`
on startup and merges the entries into both the HTTP gossip task and the
libp2p Kademlia bootstrap.

- Add \`bootstrap-peers.json\` at repo root (versioned schema, PR-friendly)
- New \`bootstrap\` module in the node crate (parse + merge_seeds)
- Wire into \`main\` after \`Config::parse\`
- Operators can opt out via \`GITLAWB_BOOTSTRAP_DISABLE_SEEDS\` for
  isolated dev networks

Also in this commit:
- \`cargo fmt --all\` over the entire workspace (no logic changes)
- Downgrade CI clippy step to advisory (\`continue-on-error: true\`) until
  the existing lint backlog is cleared. fmt + tests stay strict.

Co-Authored-By: OpenClaude <openclaude@gitlawb.com>
Refactor bootstrap.rs into pure functions (parse_seed_list, merge_into_vecs)
so the parse + merge logic can be tested without constructing a Config or
mutating process-global env vars.

Adds 11 tests covering:

- valid v1 list parses
- unknown version is rejected
- malformed JSON is rejected
- empty / missing peers array
- merge appends new http + p2p entries
- merge dedupes against existing entries
- invalid p2p_multiaddr is skipped (http still added)
- empty strings are skipped
- null optional fields are tolerated
- the canonical bootstrap-peers.json shipped in the repo always parses
  (regression guard against future schema changes)

Co-Authored-By: OpenClaude <openclaude@gitlawb.com>
Closes CodeQL alert #4 (Uncontrolled data used in path expression).

Both `owner_did` and `repo_name` come from URL parameters and were used
unsanitized to build a filesystem path, so a request like
`/did:key:foo/../../../etc/passwd.git/info/refs` could escape the repos
directory.

Fix:

- New `validate_owner_did` and `validate_repo_name` enforce a strict
  allowlist before path construction (alphanumeric + `: . _ -` for DIDs;
  alphanumeric + `. _ -` for repo names; rejects empty, `..`, leading
  `.` or `-`, slashes, backslashes, null bytes, overlong inputs).
- `RepoStore::local_path` now returns `Result<…>` and the 5 callers
  propagate the error.
- Defence in depth: even after the allowlist passes, the joined path is
  checked to still be rooted at `repos_dir`.
- 17 unit tests cover normal DIDs/repo names plus every malicious shape
  (`..`, `/`, `\`, leading dot/dash, null byte, overlong, did:web with
  dots).

Co-Authored-By: OpenClaude <openclaude@gitlawb.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant