test_a_newline_in_a_path_cannot_inject_a_directive¶
Tests › tests/test_doxyfile_injection.py
What this test is for
Why it exists
A newline in a file name must not become a Doxyfile directive.
Verifies REQ-DDB-PIPE-014
Given
doxyfile = tmp_path / "Doxyfile"doxyfile.write_text("PROJECT_NAME = probe\nINPUT = .\n", encoding="utf-8")hostile = "/repo/a.c\nINPUT_FILTER = /bin/sh -c 'pwn' #"
When
text = _build_doxyfile_content(doxyfile, [hostile], None, True, tmp_path, "")for directive in ("INPUT_FILTER", "FILTER_PATTERNS"): for value in _assignments(text, directive): assert not value, ( f"a file name injected a non-empty {directive} = {value!r}; doxygen runs that " f"as a command over every input file, so indexing a hostile repo executes it" )for value in _assignments(text, "FILTER_SOURCE_FILES"): assert value.upper() in ("", "NO"), ( f"a file name set FILTER_SOURCE_FILES = {value!r}, re-enabling filtering" )
Then
- ✓ text does not contain "/bin/sh"
tests/test_doxyfile_injection.py:76 · its file's page
What it checks (3)
assert not value, ( f"a file name injected a non-empty {directive} = {value!r}; doxygen runs that " f"as a command over every input file, so indexing a hostile repo executes it" )not attributedassert value.upper() in ("", "NO"), ( f"a file name set FILTER_SOURCE_FILES = {value!r}, re-enabling filtering" )not attributedassert "/bin/sh" not in text, "the injected command survived into the rendered configuration"observes_build_doxyfile_contentviatext
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.
Requirements it verifies (1)
| requirement | linked by | implementers exercised |
|---|---|---|
| REQ-DDB-PIPE-014 | catalog | unknown |
Also reaches 2 requirements
Its run touches their code; that is reach, not proof.
- REQ-DDB-INDEX-001 measured
- REQ-DDB-PIPE-003 measured