ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
shell_invocation_references.py
Go to the documentation of this file.
1# SPDX-License-Identifier: MIT
2# Copyright (c) 2026 Brighton Sikarskie
3"""Exact reviewed non-command occurrences for the shell caller authority."""
4
5from __future__ import annotations
6
7from dataclasses import dataclass
8
9PROCESS_CALLS = frozenset(
10 {
11 "asyncio.create_subprocess_exec",
12 "asyncio.create_subprocess_shell",
13 "os.execv",
14 "os.execve",
15 "os.execvp",
16 "os.execvpe",
17 "run_process",
18 "subprocess.Popen",
19 "subprocess.call",
20 "subprocess.check_call",
21 "subprocess.check_output",
22 "subprocess.run",
23 }
24)
25SHELL_FENCE_LANGUAGES = frozenset({"bash", "console", "sh", "shell", "zsh"})
26JSON_FENCE_LANGUAGES = frozenset({"json", "jsonc"})
27YAML_COMMAND_KEYS = frozenset({"cmd", "command", "run", "shell"})
28DOCKER_COMMANDS = frozenset({"CMD", "ENTRYPOINT", "RUN"})
29
30
31@dataclass(frozen=True)
32class ExactReference:
33 """One reviewed non-executable or structurally nested governed occurrence."""
34
35 rel: str
36 target: str
37 logical: str
38 reason: str
39
40
41EXACT_REFERENCES = (
42 ExactReference(
43 "scripts/ci/gates/tests.sh",
44 "scripts/dev/agent_workspace.sh",
45 "/bin/bash -p -n scripts/dev/agent_workspace.sh",
46 "Bash parses this file without executing it; the executable caller is separately checked.",
47 ),
48 ExactReference(
49 "scripts/emu/smoke.sh",
50 "scripts/emu/smoke_run.sh",
51 'if ! grep -q "^$fn() {" "$ROOT/scripts/emu/smoke_run.sh"; then',
52 "The smoke selftest reads function declarations as data and never launches the helper.",
53 ),
54 ExactReference(
55 "scripts/emu/smoke.sh",
56 "scripts/emu/smoke_apps.sh",
57 (
58 "ov_apps=\"$(awk '/^uart_expect_override\\(\\)/{f=1} "
59 'f&&/^}/{f=0} f\' "$ROOT/scripts/emu/smoke_apps.sh" | '
60 "grep -oE '^[[:space:]]+[a-z0-9_]+\\)' | tr -d ' )')\""
61 ),
62 "The smoke selftest parses a case table as data and never launches the helper.",
63 ),
64 ExactReference(
65 "scripts/git/hook-launcher",
66 "scripts/git/pre-commit",
67 (
68 "exec env -u BASH_ENV -u ENV -u PYTHONHOME -u PYTHONPATH "
69 '"$bash_bin" -p "$owner" "${hook_args[@]}"'
70 ),
71 (
72 "The launcher verifies Bash and the immutable hook owner by exact "
73 "path, blob, and inode first."
74 ),
75 ),
76 ExactReference(
77 "scripts/ci/lib/container.sh",
78 "scripts/ci.sh",
79 (
80 'exec "${runtime[@]}" run --rm --init -u 0:0 '
81 "--tmpfs /home/ra8-ci:rw,mode=0700 -e RA8_CI_INNER=1 "
82 '-e RA8_CI_FAST="$fast" -e RA8_CI_GATE="$gate" '
83 "-e HOME=/home/ra8-ci "
84 "-e GIT_CONFIG_COUNT=1 -e GIT_CONFIG_KEY_0=safe.directory "
85 "-e GIT_CONFIG_VALUE_0=/workspace "
86 "-e RA8_MAX_JOBS "
87 '-e CMAKE_BUILD_PARALLEL_LEVEL="${CMAKE_BUILD_PARALLEL_LEVEL:-'
88 '${RA8_MAX_JOBS:-}}" -v "$repo":/workspace:ro '
89 '${extra[@]+"${extra[@]}"} ${worktree[@]+"${worktree[@]}"} '
90 '${ccache[@]+"${ccache[@]}"} ${toolcache[@]+"${toolcache[@]}"} '
91 '"${nofile[@]}" -w /workspace "$image" /bin/bash -p scripts/ci.sh'
92 ),
93 (
94 "The reviewed container-runtime argv executes the exact privileged "
95 "Bash prefix only after the selected pinned image."
96 ),
97 ),
98)