test_a_symlinked_doc_outside_the_repository_is_not_ingested

Tests › tests/test_external_provenance.py

passed Passed in the packaged run.

What this test is for

Why it exists

H2, 1.1.0 SECURITY AUDIT. `glob` FOLLOWS SYMLINKS, and git tracks symlinks, so a repository could commit `README.md -> /etc/passwd` (or `/proc/self/environ`, which carries the indexing user's `ANTHROPIC_API_KEY`) and clew would read it, chunk it into `supplementary_docs`, and serve it to a model labelled with an in-repo path — the worst combination: exfiltration plus a false provenance an agent has no way to doubt.

Given

  1. secret = tmp_path / "outside" / "secret.md"
  2. secret.parent.mkdir(parents=True)
7 more
  1. secret.write_text("# Secret\n\nSENTINEL-PROSE-LEAK\n", encoding="utf-8")
  2. repo = tmp_path / "repo"
  3. (repo / "docs").mkdir(parents=True)
  4. (repo / "README.md").symlink_to(secret)
  5. (repo / "docs" / "guide.md").symlink_to(secret)
  6. (repo / "docs" / "real.md").write_text("# Real\n\nin-repo content\n", encoding="utf-8")
  7. db = tmp_path / "clew.db"
→

When

  1. ingest_supplementary_docs(db, repo)
  2. conn = sqlite3.connect(str(db))
  3. rows = conn.execute("SELECT file_path, content FROM supplementary_docs").fetchall()
  4. conn.close()
→

Then

  1. ✓ any("SENTINEL-PROSE-LEAK" in content for _, content in rows) is false
  2. ✓ any(path == "docs/real.md" for path, _ in rows) holds

tests/test_external_provenance.py:521 · its file's page

What it checks (2)

  1. assert not any("SENTINEL-PROSE-LEAK" in content for _, content in rows), ( f"a file outside the repository was ingested as repo prose: {rows}" ) not attributed
  2. assert any(path == "docs/real.md" for path, _ in rows), ( "the containment check must not cost the ordinary in-repo document" ) not attributed

Where the product reaches it

No product flow reaches this code: no product entry point's flow calls any of the functions this test calls.

Call flow

test_a_symlinked_doc_outside_the_repository_is_not_ingested→ingest_supplementary_docs

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.

test_a_symlinked_doc_outside_the_repository_is_not_ingested · 2 checksingest_supplementary_docs_ingest_one_doc_filememoizedREQ-DDB-INDEX-002 · measuredingest_supplementary_docsREQ-DDB-PIPE-001 · measuredingest_supplementary_docswithin_repoREQ-DDB-PIPE-014 · measured
Also reaches 3 requirements

Its run touches their code; that is reach, not proof.