Keep the rule for which commands reach run-heavy's docker beside that docker in capped_docker.py

This commit is contained in:
2026-11-08 11:09:17 +01:00
parent e2aca90c9c
commit 2321f4930d
6 changed files with 44 additions and 17 deletions
+3 -10
View File
@@ -5,8 +5,9 @@ import typing
from round_titles import CAP, lacks_counts, RELEASE_REVIEW_CAP
from git_command import commits
from run_heavy.capped_docker import finds_this_docker
from rule_hook.heavy_command import heavy
from shell_command import launched, Simple, tool_name
from shell_command import launched, Simple
from review_folder import REPORTS
from docker_command import unlimited
@@ -162,15 +163,7 @@ def unlimited_container(words: list[str]) -> bool:
docker = launched(words, {"docker"})
if docker is None or not unlimited(docker.arguments):
return False
# On Linux, run-heavy's docker adds the limits a container lacks, where PATH finds it: docker named bare, with PATH left as run-heavy set it.
before = words[:len(words) - len(docker.arguments) - 1]
capped = "run-heavy" in docker.launchers and words[len(before)] == "docker" and not any(resets_path(word) for word in before)
return not capped
def resets_path(word: str) -> bool:
"""Whether a word before docker drops the PATH run-heavy set: a PATH= of its own, env's -i or -u, or sudo or doas, which reset it."""
return word.startswith(("PATH=", "--unset")) or word in ("-i", "--ignore-environment", "-u") or tool_name(word) in ("doas", "sudo")
return not ("run-heavy" in docker.launchers and finds_this_docker(docker.word, docker.before))
def file_breaches(path: str, before: str, added: str, after: str) -> list[Breach]: