Answer security round 1: 1 🔴, 0 🟡 (0 misread); pass over a data source whose script writes a .git, and test the script's failures
CI / tests (pull_request) Successful in 3m45s

This commit is contained in:
2026-11-23 19:18:26 +01:00
parent 82a03e9a1b
commit 2ffa4908c9
3 changed files with 53 additions and 4 deletions
+5 -1
View File
@@ -1,6 +1,7 @@
"""The register a data-source task hands Haiku: the files the task's `generate-register` writes into the tree Haiku starts in.
The script is seeded, so it writes the same register at the base and at the head, byte for byte; a task whose script doesn't is
passed over."""
import os
import pathlib
import shutil
@@ -46,7 +47,7 @@ def registered_trees(bench: Bench, name: str, script: str) -> dict[Side, str] |
def generated(containers: Containers, tree: str, script: str) -> dict[str, bytes] | Failure:
"""The register script writes when run at the top of tree, in the bench's image with no network: each file new to the tree,
by its path from the top. NotGenerated where the script runs out of time, fails or writes no new file."""
by its path from the top. NotGenerated where the script runs out of time, fails, writes a `.git` or writes no new file."""
before = set(entries(tree))
ran = run_in_image(containers, ["--network", "none", *in_tree(containers, tree), "--volume", f"{script}:{MOUNTED}:ro", containers.image, MOUNTED])
if isinstance(ran, TimedOut):
@@ -55,5 +56,8 @@ def generated(containers: Containers, tree: str, script: str) -> dict[str, bytes
return ran
if ran.code:
return NotGenerated(f"its {GENERATE} exits {ran.code}")
# git runs on the host in this tree next, and would run what a `.git/config` there names, outside the container.
if os.path.lexists(os.path.join(tree, ".git")):
return NotGenerated(f"its {GENERATE} writes a `.git`")
register = on_disk(f"read the register in {tree}", lambda: {path: pathlib.Path(tree, path).read_bytes() for path in entries(tree) if path not in before})
return register or NotGenerated(f"its {GENERATE} doesn't write any new file")