fix: isolate private application help publication files

This commit is contained in:
Nick Beckley 2026-11-27 22:40:08 +00:00
parent 15753345bf
commit f556d71e1b
4 changed files with 23 additions and 7 deletions

View File

@ -37,3 +37,12 @@ No Production cutover, TLS/provider change, data reset or SQL migration was perf
Production activation awaits explicit owner approval. The optional external HTTPS Production activation awaits explicit owner approval. The optional external HTTPS
Development website hostname is only a template; the LAN URL above is the actual Development website hostname is only a template; the LAN URL above is the actual
running environment. running environment.
## Administrator help correction
The initial counts above are superseded by the explicit visibility correction:
367 public articles, 42 administrator articles retained only in the application,
406 indexed URLs and 484 public routes. Restricted direct/category/legacy routes
return 404 and are absent from search, recommendations and machine-readable indexes.
See HelpVisibility.md and the application HelpVisibility/Readiness.md report for
current qualification. Do not roll back to legacy unclassified publications.

View File

@ -34,3 +34,5 @@ website defaults to public, while the application requires `--audience applicati
The Production channel still requires explicit Production-compatible approval. The Production channel still requires explicit Production-compatible approval.
Do not roll back to legacy unclassified publications or pre-correction application Do not roll back to legacy unclassified publications or pre-correction application
code: these are not safe public-help rollback targets. code: these are not safe public-help rollback targets.
Application-audience stores use root ownership, runtime-group-only directories/files (0750/0640). The consumer defaults to runtime group plotdirector; --runtime-group allows an explicit alternative. The website runtime cannot read the application store. Media inherits its referencing article visibility, with immutable publication roots retained for safe concurrent publication.

View File

@ -1,4 +1,4 @@
import importlib.util,json,hashlib,tempfile,unittest import importlib.util,json,hashlib,tempfile,unittest,grp,os
from pathlib import Path from pathlib import Path
spec=importlib.util.spec_from_file_location('consume_help',Path(__file__).resolve().parents[1]/'Tools/consume_help.py');module=importlib.util.module_from_spec(spec);spec.loader.exec_module(module) spec=importlib.util.spec_from_file_location('consume_help',Path(__file__).resolve().parents[1]/'Tools/consume_help.py');module=importlib.util.module_from_spec(spec);spec.loader.exec_module(module)
class PublicationVisibilityTests(unittest.TestCase): class PublicationVisibilityTests(unittest.TestCase):
@ -24,7 +24,7 @@ class PublicationVisibilityTests(unittest.TestCase):
source,digest=self.package('administrator','application') source,digest=self.package('administrator','application')
with self.assertRaises(ValueError):module.consume(source,self.root/'store','Development',digest) with self.assertRaises(ValueError):module.consume(source,self.root/'store','Development',digest)
def test_administrator_retained_in_explicit_application_publication(self): def test_administrator_retained_in_explicit_application_publication(self):
source,digest=self.package('administrator','application');module.consume(source,self.root/'store','Development',digest,'application');self.assertEqual(json.loads((self.root/'store/current/articles.json').read_text())[0]['Visibility'],'administrator') source,digest=self.package('administrator','application');module.consume(source,self.root/'store','Development',digest,'application',grp.getgrgid(os.getgid()).gr_name);self.assertEqual(json.loads((self.root/'store/current/articles.json').read_text())[0]['Visibility'],'administrator')
def test_legacy_unclassified_format_refused(self): def test_legacy_unclassified_format_refused(self):
source,digest=self.package(version=1) source,digest=self.package(version=1)
with self.assertRaises(ValueError):module.consume(source,self.root/'store','Development',digest) with self.assertRaises(ValueError):module.consume(source,self.root/'store','Development',digest)

View File

@ -1,16 +1,19 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
"""Verify and install an explicitly published help directory; never contacts the app.""" """Verify and install an explicitly published help directory; never contacts the app."""
import argparse,hashlib,json,os,shutil,tempfile import argparse,hashlib,json,os,shutil,tempfile,grp
from pathlib import Path,PurePosixPath from pathlib import Path,PurePosixPath
def consume(source,store,channel,expected,audience="public"): def consume(source,store,channel,expected,audience="public",runtime_group=None):
source,store=Path(source).resolve(),Path(store).resolve() source,store=Path(source).resolve(),Path(store).resolve()
manifest=(source/'manifest.json').read_bytes() manifest=(source/'manifest.json').read_bytes()
if hashlib.sha256(manifest).hexdigest()!=expected:raise ValueError('Approved manifest digest differs') if hashlib.sha256(manifest).hexdigest()!=expected:raise ValueError('Approved manifest digest differs')
m=json.loads(manifest) m=json.loads(manifest)
if m['format']!=2 or m['channel']!=channel or m.get('audience')!=audience:raise ValueError('Wrong publication format, channel or audience') if m['format']!=2 or m['channel']!=channel or m.get('audience')!=audience:raise ValueError('Wrong publication format, channel or audience')
if not m['files'] or 'articles.json' not in m['files']:raise ValueError('Missing article inventory') if not m['files'] or 'articles.json' not in m['files']:raise ValueError('Missing article inventory')
private_group=grp.getgrnam(runtime_group or 'plotdirector').gr_gid if audience=='application' else None
store.mkdir(parents=True,exist_ok=True) store.mkdir(parents=True,exist_ok=True)
if private_group is not None:
os.chown(store,-1,private_group);store.chmod(0o750)
version=store/expected version=store/expected
if version.exists():raise ValueError('Publication already installed; select its retained directory explicitly') if version.exists():raise ValueError('Publication already installed; select its retained directory explicitly')
with tempfile.TemporaryDirectory(prefix='.incoming-',dir=store) as temp: with tempfile.TemporaryDirectory(prefix='.incoming-',dir=store) as temp:
@ -29,8 +32,10 @@ def consume(source,store,channel,expected,audience="public"):
if len(urls)!=len(set(urls)) or any(a.get('Visibility') not in allowed for a in articles):raise ValueError('Restricted or unclassified article in publication') if len(urls)!=len(set(urls)) or any(a.get('Visibility') not in allowed for a in articles):raise ValueError('Restricted or unclassified article in publication')
(temp/'manifest.json').write_bytes(manifest) (temp/'manifest.json').write_bytes(manifest)
for file in temp.rglob('*'): for file in temp.rglob('*'):
file.chmod(0o755 if file.is_dir() else 0o444) if private_group is not None:os.chown(file,-1,private_group)
temp.chmod(0o755) file.chmod((0o750 if file.is_dir() else 0o640) if private_group is not None else (0o755 if file.is_dir() else 0o444))
if private_group is not None:os.chown(temp,-1,private_group)
temp.chmod(0o750 if private_group is not None else 0o755)
os.rename(temp,version) os.rename(temp,version)
# TemporaryDirectory cleanup tolerates the directory being atomically moved. # TemporaryDirectory cleanup tolerates the directory being atomically moved.
link=store/('.current-'+expected) link=store/('.current-'+expected)
@ -38,4 +43,4 @@ def consume(source,store,channel,expected,audience="public"):
os.replace(link,store/'current') os.replace(link,store/'current')
print(json.dumps({'channel':channel,'audience':audience,'version':m['version'],'manifestSha256':expected,'articles':len(articles)})) print(json.dumps({'channel':channel,'audience':audience,'version':m['version'],'manifestSha256':expected,'articles':len(articles)}))
if __name__=='__main__': if __name__=='__main__':
p=argparse.ArgumentParser();p.add_argument('source');p.add_argument('--store',required=True);p.add_argument('--channel',choices=['Development','Production'],required=True);p.add_argument('--manifest-sha256',required=True);p.add_argument('--audience',choices=['public','application'],default='public');a=p.parse_args();consume(a.source,a.store,a.channel,a.manifest_sha256,a.audience) p=argparse.ArgumentParser();p.add_argument('source');p.add_argument('--store',required=True);p.add_argument('--channel',choices=['Development','Production'],required=True);p.add_argument('--manifest-sha256',required=True);p.add_argument('--audience',choices=['public','application'],default='public');p.add_argument('--runtime-group');a=p.parse_args();consume(a.source,a.store,a.channel,a.manifest_sha256,a.audience,a.runtime_group)