Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false

- uses: actions/setup-python@v5
with:
Expand Down
2 changes: 1 addition & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ MODULES_DIR="$(cd "$(dirname "$0")" && pwd)"
# colons in the fields we read).
ymv() {
local file="$1" key="$2"
awk -v k="^$key:" 'BEGIN{IGNORECASE=0} $0 ~ k {sub(/^[^:]+:[ \t]*/, ""); gsub(/^["'"'"']|["'"'"']$/, ""); print; exit}' "$file"
awk -v k="^$key:" '$0 ~ k {sub(/^[^:]+:[ \t]*/, ""); gsub(/^["'"'"']|["'"'"']$/, ""); print; exit}' "$file"
}

push_one() {
Expand Down
36 changes: 12 additions & 24 deletions validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@
import json
import os
import re
import shutil
import subprocess
import sys
from dataclasses import dataclass
Expand Down Expand Up @@ -567,10 +568,8 @@ def _steamcmd_shaped(cfg: dict) -> bool:
key = e.split("=", 1)[0].upper()
if "STEAM" in key:
return True
for field in ("WorkingDir",):
v = (cfg.get(field) or "").lower()
if "steamcmd" in v:
return True
if "steamcmd" in (cfg.get("WorkingDir") or "").lower():
return True
for lst in (cfg.get("Entrypoint") or [], cfg.get("Cmd") or []):
for tok in lst:
if "steamcmd" in (tok or "").lower():
Expand Down Expand Up @@ -600,10 +599,8 @@ def rule_no_entrypoint_shell_cmd(spec: dict, cfg: dict, image_ref: str) -> list[
cmd = cfg.get("Cmd") or []
if entrypoint or not cmd:
return []
shell_names = {"bash", "sh", "/bin/bash", "/bin/sh"}
base = cmd[0] or ""
basename = base.rsplit("/", 1)[-1]
if len(cmd) == 1 and (base in shell_names or basename in ("bash", "sh")):
basename = (cmd[0] or "").rsplit("/", 1)[-1]
if len(cmd) == 1 and basename in ("bash", "sh"):
if not spec.get("command"):
return [
Finding(
Expand Down Expand Up @@ -651,13 +648,11 @@ def rule_nonroot_requires_runasuser(spec: dict, cfg: dict, image_ref: str) -> li
"Project Zomboid uid-1000-vs-10000 bug).",
)
]
if img_uid is None:
# A bare name (e.g. "steam") — we cannot resolve the real numeric uid
# without reading /etc/passwd out of the image's filesystem layers,
# which this validator deliberately does not do (too expensive for a
# preflight check). Presence of *some* runAsUser is verified above;
# the exact value can't be cross-checked statically here.
pass
# img_uid is None for a bare name (e.g. "steam"): the real numeric uid
# cannot be resolved without reading /etc/passwd out of the image's
# filesystem layers, which this validator deliberately does not do (too
# expensive for a preflight check). Presence of *some* runAsUser is
# verified above; the exact value can't be cross-checked statically here.
return []


Expand Down Expand Up @@ -1357,7 +1352,6 @@ def discover_modules(root: Path, names: list[str] | None) -> list[Path]:


def find_gp_module_bin(root: Path) -> str | None:
import shutil
gp_bin = shutil.which("gp-module")
if gp_bin:
return gp_bin
Expand Down Expand Up @@ -1406,16 +1400,10 @@ def main(argv: list[str]) -> int:
if not gp_bin:
sys.stderr.write("error: gp-module binary not found; required for --offline validation\n")
return 2
cmd = [gp_bin, "validate"]
if "--json" in args:
cmd.append("--json")
if "--strict" in args:
cmd.append("--strict")
cmd.extend([str(d) for d in module_dirs])
return subprocess.run(cmd).returncode
return subprocess.run([gp_bin, "validate"] + [str(d) for d in module_dirs]).returncode

offline_findings: dict[str, list[Finding]] = {}
if gp_bin and "--skip-offline" not in args:
if gp_bin:
try:
res = subprocess.run(
[gp_bin, "validate", "--json"] + [str(d) for d in module_dirs],
Expand Down
Loading