test_a_symlinked_doc_outside_the_repository_is_not_ingested¶
Tests › tests/test_external_provenance.py
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
secret = tmp_path / "outside" / "secret.md"secret.parent.mkdir(parents=True)
7 more
secret.write_text("# Secret\n\nSENTINEL-PROSE-LEAK\n", encoding="utf-8")repo = tmp_path / "repo"(repo / "docs").mkdir(parents=True)(repo / "README.md").symlink_to(secret)(repo / "docs" / "guide.md").symlink_to(secret)(repo / "docs" / "real.md").write_text("# Real\n\nin-repo content\n", encoding="utf-8")db = tmp_path / "clew.db"
When
ingest_supplementary_docs(db, repo)conn = sqlite3.connect(str(db))rows = conn.execute("SELECT file_path, content FROM supplementary_docs").fetchall()conn.close()
Then
- ✓ any("SENTINEL-PROSE-LEAK" in content for _, content in rows) is false
- ✓ any(path == "docs/real.md" for path, _ in rows) holds
tests/test_external_provenance.py:521 · its file's page
What it checks (2)
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 attributedassert 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
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 3 requirements
Its run touches their code; that is reach, not proof.
- REQ-DDB-INDEX-002 measured
- REQ-DDB-PIPE-001 measured
- REQ-DDB-PIPE-014 measured