Answer principles round 1: 0 🔴, 4 🟡 (0 misread); exempt only a bare docker under run-heavy with no PATH of its own, drop the stale item citation, unit-test the slot share in MiB, place the limits by the subcommand's index; also a named Option, exit 126, clearer names and the launcher's import order
This commit is contained in:
@@ -32,7 +32,7 @@ RULES: dict[RuleName, Rule] = {
|
||||
),
|
||||
"docker-run-memory": Rule(
|
||||
"a container made with docker run or docker create has a memory limit and a swap limit, as large as its work needs, such as `--memory 4g --memory-swap 4g`, so a runaway container fails alone instead of starving the machine; a swap limit equal to the memory limit keeps it out of swap",
|
||||
"docker run, docker create, docker container run and docker container create, whether direct or through a launcher such as nice or timeout. A container a script or docker compose starts is not checked",
|
||||
"docker run, docker create, docker container run and docker container create, whether direct or through a launcher such as nice or timeout. One under run-heavy passes, as run-heavy's docker adds the limits, unless it names docker by its path or sets its own PATH. A container a script or docker compose starts is not checked",
|
||||
),
|
||||
"ignorefile-sorted": Rule(
|
||||
"each block of an ignore file is sorted in code-point order, as LC_ALL=C sort does, since its order carries no meaning; where order matters, such as a re-include after its exclude, split the block with a blank line or a comment",
|
||||
@@ -154,8 +154,11 @@ def command_breaches(command: str, simples: list[Simple], home: str) -> list[Bre
|
||||
def unlimited_container(words: list[str]) -> bool:
|
||||
"""Whether the simple command, directly or through a launcher, starts a container that lacks a memory limit or a swap limit."""
|
||||
docker = launched(words, {"docker"})
|
||||
# Under run-heavy, its docker adds the limits a container lacks.
|
||||
return docker is not None and "run-heavy" not in docker.launchers and unlimited(docker.arguments)
|
||||
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 no PATH of the command's own.
|
||||
capped = "run-heavy" in docker.launchers and words[len(words) - len(docker.arguments) - 1] == "docker" and not any(word.startswith("PATH=") for word in words)
|
||||
return not capped
|
||||
|
||||
|
||||
def file_breaches(path: str, before: str, added: str, after: str) -> list[Breach]:
|
||||
|
||||
Reference in New Issue
Block a user