test_a_traversing_db_path_is_not_followed_into_an_rmtree

Tests › tests/test_registry_hygiene.py

passed Passed in the packaged run.

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

  1. home = tmp_path / "state"
  2. (home / "targets").mkdir(parents=True)
4 more
  1. victim = tmp_path / "victim"
  2. victim.mkdir()
  3. (victim / "keep.txt").write_text("precious", encoding="utf-8")
  4. (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

  1. —
→

Then

  1. ✓ TargetRegistry(home).drop(str(tmp_path / "repo")) is True
  2. ✓ victim.is_dir() holds
  3. ✓ (victim / "keep.txt").exists() holds

tests/test_registry_hygiene.py:187 · its file's page

What it checks (2)

  1. assert TargetRegistry(home).drop(str(tmp_path / "repo")) is True not attributed
  2. assert 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.