Compare commits

...
2 changed files with 20 additions and 1 deletions

No files matched your search

+7 -1
View File
@@ -6,6 +6,7 @@ Caller must serialize with deployment; never run alongside an editorial runner.
"""
import json
import os
import re
from pathlib import Path
import stat
@@ -20,7 +21,12 @@ def allowed(relative,isdir):
if relative in DIRS if isdir else relative in LEAVES:return True
# Runner-created state is limited to immediate regular files, never subtrees.
p=Path(relative)
return not isdir and str(p.parent) in STATE_ROOTS and p.name in ('lock','proposal.json')
if not isdir and str(p.parent) in STATE_ROOTS and p.name in ('lock','proposal.json'):return True
# Installed runner persists allowlisted timing evidence for task/run/profile.
# Admit only that exact immediate-file grammar, not arbitrary JSON or trees.
profiles='|'.join(re.escape(profile) for profile in PROFILES)
return not isdir and str(p.parent)=='editorial-v4/runner-state' and re.fullmatch(
r'[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12}-[0-9a-f]{32}-(?:'+profiles+r')\.json',p.name) is not None
def scan(home,uid,gid):
if not home.is_absolute() or home.is_symlink():raise ValueError('Canonical home required')
+13
View File
@@ -0,0 +1,13 @@
import importlib.util
from pathlib import Path
import unittest
s=importlib.util.spec_from_file_location('ownership',Path(__file__).with_name('editorial-ownership.py'))
m=importlib.util.module_from_spec(s);s.loader.exec_module(m)
class RuntimeStateTests(unittest.TestCase):
def test_installed_runner_evidence_is_reviewed_but_arbitrary_state_is_not(self):
prefix='editorial-v4/runner-state/'
good='1a00bc08-3ca4-4519-ae1e-9eec7b098756-efcc15cd7b824198abc4f85abcfb0730-canina-competitor-worker.json'
self.assertTrue(m.allowed(prefix+good,False))
for name in ['anything.json',good.replace('canina-competitor-worker','unreviewed'),good+'/nested',good.replace('efcc15cd7b824198abc4f85abcfb0730','oops')]:
self.assertFalse(m.allowed(prefix+name,False))
self.assertFalse(m.allowed(prefix+good,True))