This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
#!/usr/bin/env python3
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
"""Fail-closed Phase-1.0BA guardrails."""
|
||||
|
||||
import argparse
|
||||
import json
|
||||
from pathlib import Path
|
||||
import unittest
|
||||
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("--root", type=Path, required=True)
|
||||
root = parser.parse_args().root
|
||||
|
||||
|
||||
class Phase10BAGuardrails(unittest.TestCase):
|
||||
@classmethod
|
||||
def setUpClass(cls) -> None:
|
||||
cls.data = json.loads((root / "manifests/retroarch/phase-1.0ba-target-profile-callsite-audit.json").read_text(encoding="utf-8"))
|
||||
|
||||
def test_callsite_is_post_cleanup_pre_exit(self) -> None:
|
||||
call = self.data["callsite_contract"]
|
||||
for key in ("rarch_main_return_required", "s15_before_d14",
|
||||
"d14_before_process_exit", "early_return_initialized_mask_rejected"):
|
||||
self.assertTrue(call[key])
|
||||
self.assertFalse(call["terminal_emit_result_changes_exit_code"])
|
||||
|
||||
def test_profile_is_launcher_independent(self) -> None:
|
||||
profile = self.data["profile_delta"]
|
||||
self.assertEqual(profile["profile_name"], "launch-canary")
|
||||
self.assertTrue(profile["inherits_write_diag_behavior"])
|
||||
self.assertTrue(profile["same_elf_for_both_launch_arms"])
|
||||
self.assertTrue(profile["adds_only_av_target_define"])
|
||||
for key in ("launcher_define_forbidden", "new_socket_or_address_forbidden",
|
||||
"runner_activation_forbidden"):
|
||||
self.assertTrue(profile[key])
|
||||
|
||||
def test_build_and_device_gates_stay_closed(self) -> None:
|
||||
auth = self.data["authorizations"]
|
||||
self.assertTrue(auth["target_source_patch_authorized"])
|
||||
self.assertTrue(auth["target_profile_addition_authorized"])
|
||||
for key, value in auth.items():
|
||||
if key not in ("target_source_patch_authorized", "target_profile_addition_authorized"):
|
||||
self.assertFalse(value, key)
|
||||
self.assertFalse(self.data["decision"]["cross_build_allowed"])
|
||||
self.assertFalse(self.data["decision"]["device_action_allowed"])
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main(argv=[__file__])
|
||||
Reference in New Issue
Block a user