test_a_traversing_db_path_is_not_followed_into_an_rmtree¶
Tests › tests/test_registry_hygiene.py
What this test is for
Why it exists
M3, 1.1.0 SECURITY AUDIT — in code this session shipped, so the record is straight. `_discard` tested containment with `is_relative_to` on the UNRESOLVED path, which is a LEXICAL check: `<home>/targets/../../victim` is textually under `home` and resolves outside it. The registry is a JSON file on disk, so a row is editable by anything running as the user, and `drop`/`cull` then delete a directory of that row's choosing.
Given
home = tmp_path / "state"(home / "targets").mkdir(parents=True)
4 more
victim = tmp_path / "victim"victim.mkdir()(victim / "keep.txt").write_text("precious", encoding="utf-8")(home / REGISTRY_NAME).write_text( json.dumps( { "traversing": { "slug": "traversing", "db_path": str(home / "targets" / ".." / ".." / "victim" / "clew.db"), "repo_path": str(tmp_path / "repo"), } } ), encoding="utf-8", )
When
- —
Then
- ✓ TargetRegistry(home).drop(str(tmp_path / "repo")) is True
- ✓ victim.is_dir() holds
- ✓ (victim / "keep.txt").exists() holds
tests/test_registry_hygiene.py:187 · its file's page
What it checks (2)
assert TargetRegistry(home).drop(str(tmp_path / "repo")) is Truenot attributedassert victim.is_dir() and (victim / "keep.txt").exists(), ( "a registry row walked `drop` out of the state root and deleted a directory outside it" )not attributed
What it reaches
Each row runs from this test, through the calls it makes, to the code a requirement names. If that code breaks, the test's checks are what should catch it. Reaching is not proving: a check only proves what it observes. No mutation records were given, so these rows say what the test REACHES.
Also reaches 1 requirement
Its run touches their code; that is reach, not proof.
- REQ-DDB-MCP-001 measured