test_no_command_valued_option_survives_a_hostile_doxyfile

Tests › tests/test_doxyfile_injection.py

passed Passed in the packaged run.

What this test is for

Why it exists

TABLE-DRIVEN ON PURPOSE. The previous fix forced INPUT_FILTER, FILTER_PATTERNS and FILTER_SOURCE_FILES and its docstring declared the path closed. `QHG_LOCATION` then executed anyway — doxygen runs qhelpgenerator, and `HTML_EXTRA_FILES` copies a repo file into the output tree with its exec bit intact to supply the path. Verified against 1.9.8.

Verifies REQ-DDB-PIPE-014

Given

  1. doxyfile = tmp_path / "Doxyfile"
  2. doxyfile.write_text( "PROJECT_NAME = probe\nINPUT = .\n" + "".join(f"{k} = /bin/sh\n" for k in _EXEC_VALUED) + "GENERATE_QHP = YES\nGENERATE_HTML = YES\nHTML_EXTRA_FILES = ./pwn.sh\n", encoding="utf-8", )
→

When

  1. text = _build_doxyfile_content(doxyfile, None, None, False, tmp_path, "")
  2. for key in _EXEC_VALUED: values = _assignments(text, key) assert values, f"{key} is never assigned, so the repo's value stands" assert not values[-1], ( f"the LAST {key} assignment is {values[-1]!r}; doxygen takes the last one, so the " f"repo's command still runs" )
  3. for key in _UNUSED_GENERATORS: values = _assignments(text, key) assert values and values[-1].upper() == "NO", ( f"{key} ends as {values[-1:]!r}; clew reads only the sqlite3 database, so every " f"other generator is surface it does not need" )
→

Then

  1. ✓ _assignments(text, "HTML_EXTRA_FILES")[-1] equals ""

tests/test_doxyfile_injection.py:185 · its file's page

What it checks (4)

  1. assert values, f"{key} is never assigned, so the repo's value stands" observes _assignments via values
  2. assert not values[-1], ( f"the LAST {key} assignment is {values[-1]!r}; doxygen takes the last one, so the " f"repo's command still runs" ) observes _assignments via values
  3. assert values and values[-1].upper() == "NO", ( f"{key} ends as {values[-1:]!r}; clew reads only the sqlite3 database, so every " f"other generator is surface it does not need" ) observes _assignments via values
  4. assert _assignments(text, "HTML_EXTRA_FILES")[-1] == "", ( "HTML_EXTRA_FILES still copies a repo-chosen file into the output tree with its exec " "bit preserved, which is what supplies an attacker a runnable path" ) observes _assignments

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_no_command_valued_option_survives_a_hostile_doxyfile→_build_doxyfile_content→_assignments

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_no_command_valued_option_survives_a_hostile_doxyfile · 4 checks_build_doxyfile_contentREQ-DDB-INDEX-001 · measured_build_doxyfile_contentextra_input_clears_excludeREQ-DDB-PIPE-003 · measured

Requirements it verifies (1)

requirementlinked byimplementers exercised
REQ-DDB-PIPE-014catalogunknown
Also reaches 2 requirements

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