Skip to content

fix: reject ingest URIs that name the data root - #374

Merged
kstonekuan merged 1 commit into
Hebbian-Robotics:mainfrom
fafnirkyu:fix/issue-369-reject-data-root-uri
Sep 3, 2026
Merged

fix: reject ingest URIs that name the data root#374
kstonekuan merged 1 commit into
Hebbian-Robotics:mainfrom
fafnirkyu:fix/issue-369-reject-data-root-uri

Conversation

@fafnirkyu

Copy link
Copy Markdown
Contributor

Fixes #369

Summary

  • Reject ingest URIs that normalize to the data root itself, including ., ./, a/.., and a/b/../...
  • Preserve safe internal segments such as a/../b.mcap unchanged.
  • Add regression coverage across the SDK, CLI, and server ingestion boundaries.

Validation

  • uv run ruff check .
  • uv run ruff format --check .
  • uv run ty check
  • uv run pytest -q — 1417 passed, 6 skipped

Signed-off-by: Antonio Carlos Borges Neto <84680581+fafnirkyu@users.noreply.github.com>
@github-actions

github-actions Bot commented Sep 3, 2026

Copy link
Copy Markdown

👋 Hi @fafnirkyu — thank you so much for your first contribution to HFlow!

A maintainer will review your pull request as soon as possible. In the meantime:

💡 Tip: one open pull request per contributor at a time. Issues with an assignee are taken; everything else is fair game.

We are excited to have you here and appreciate your help making the project better! 🙌

@kstonekuan kstonekuan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM, merging. Welcome.

One condition and three parametrize rows is exactly the right size for this, and both directions are held. Removing the condition:

the data-root condition removed  ->  9 failed
  test_ingest_rejects_invalid_uri_before_making_http_requests        (SDK)
  test_ingest_rejects_uris_outside_data_root                         (CLI)
  test_ingest_rejects_absolute_and_escaping_uris_before_any_runtime  (server)

All three boundaries, which is the property #314 built the shared parser for.

The other direction matters just as much here, because the obvious "simplification" of this check is to refuse anything whose normalized form differs from the candidate. That would be wrong, and it is caught:

over-refusal: any normalization difference rejected  ->  test_ingest_accepts_safe_uris_unchanged fails

So the non-goal from #314 about not rewriting a/../b.mcap into a different persisted identity is protected in both directions rather than just documented. Confirmed the behaviour directly:

refused:   '.'  './'  'a/..'  'a/b/../..'  '..'  '../x'  '/abs/x'
accepted:  'a/../b.mcap'      -> 'a/../b.mcap'        (spelling kept, not rewritten to 'b.mcap')
           '  a/../b.mcap  '  -> 'a/../b.mcap'        (trimmed, per DoD 3 on #314)
           'CC:/notadrive.mcap' -> unchanged          (two letters is not a drive)

Gate clean with current main merged in: ruff check, ruff format --check, ty check, 1436 passed / 6 skipped.

One optional thing, not worth a push. normalized == "." or normalized == ".." reads a little easier as normalized in {".", ".."}. Ruff does not flag it and the meaning is identical, so take it or leave it.

Closes #369. If you want another, the starter list is here: https://github.com/Hebbian-Robotics/hflow/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22

@kstonekuan
kstonekuan merged commit 0df29c6 into Hebbian-Robotics:main Sep 3, 2026
9 checks passed
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.

Ingest URIs that name the data root itself are accepted

2 participants