From 086f6368aade4b2385bfc11f9e0bc6041ba4e476 Mon Sep 17 00:00:00 2001 From: Joseph Magly <1159087+jmagly@users.noreply.github.com> Date: Thu, 29 Oct 2026 10:01:54 -0400 Subject: [PATCH] test: set explicit permissions for unsafe evidence fixtures --- tests/test_distributed_evidence.py | 3 +++ tests/test_distributed_model_contracts.py | 3 +++ 2 files changed, 6 insertions(+) diff --git a/tests/test_distributed_evidence.py b/tests/test_distributed_evidence.py index 6e459a9b..17a023e4 100644 --- a/tests/test_distributed_evidence.py +++ b/tests/test_distributed_evidence.py @@ -125,6 +125,9 @@ def test_evidence_parent_must_be_private_and_cannot_be_a_symlink(tmp_path): ) public = tmp_path / "public" public.mkdir(mode=0o755) + # mkdir's mode is filtered by the caller's umask; this fixture must be public. + public.chmod(0o755) + assert public.stat().st_mode & 0o777 == 0o755 with pytest.raises(ContractError, match="private"): write_evidence(public / "evidence.json", evidence) private = tmp_path / "private" diff --git a/tests/test_distributed_model_contracts.py b/tests/test_distributed_model_contracts.py index 18cdb3f8..c1b3ca73 100644 --- a/tests/test_distributed_model_contracts.py +++ b/tests/test_distributed_model_contracts.py @@ -343,6 +343,9 @@ def test_private_load_evidence_refuses_unsafe_destination(tmp_path, unsafe_sink) directory = tmp_path / "evidence" if unsafe_sink == "world_readable": directory.mkdir(mode=0o755) + # Exercise the unsafe mode even when the test runner uses umask 077. + directory.chmod(0o755) + assert directory.stat().st_mode & 0o777 == 0o755 else: target = tmp_path / "target" target.mkdir(mode=0o700)