Secure messenger with TLS identities, scoped OpenBao secrets and worker compromise experiments
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Committed lab7, truly new clone/CA/credentials/volumes, explicit operator restart."""
|
||||
import json,os,socket,subprocess,tempfile,uuid
|
||||
from pathlib import Path
|
||||
ROOT=Path(__file__).resolve().parents[1]
|
||||
def free():
|
||||
with socket.socket() as s:s.bind(('127.0.0.1',0));return str(s.getsockname()[1])
|
||||
project='verify-lab7-'+uuid.uuid4().hex[:10]
|
||||
with tempfile.TemporaryDirectory(prefix=project+'-') as directory:
|
||||
clone=Path(directory)/'repo';subprocess.run(['git','clone','--no-hardlinks',str(ROOT),str(clone)],check=True)
|
||||
env=dict(os.environ,COMPOSE_PROJECT_NAME=project,APP_PORT=free(),GRAFANA_PORT=free(),BAO_PORT=free(),SESSION_TTL_SECONDS='3600')
|
||||
base='https://localhost:'+env['APP_PORT'];ca=str(clone/'certs/ca.crt')
|
||||
def run(*args):subprocess.run(args,cwd=clone,env=env,check=True)
|
||||
def dc(*args):return subprocess.check_output(['docker','compose',*args],cwd=clone,env=env,text=True).strip()
|
||||
def snapshot():
|
||||
result={}
|
||||
for id in dc('ps','-q').splitlines():
|
||||
v=json.loads(subprocess.check_output(['docker','inspect',id],text=True))[0];result[v['Name']]={'service':v['Config']['Labels']['com.docker.compose.service'],'started_at':v['State']['StartedAt'],'user':v['Config']['User'],'image_id':v['Image'],'pid1':v['Path']}
|
||||
return result
|
||||
try:
|
||||
run('make','up');run('make','check');run('make','test','BASE_URL='+base,'CA_FILE='+ca);run('make','test-security','BASE_URL='+base,'CA_FILE='+ca)
|
||||
before=snapshot();run('make','test-persistence','ACTION_SCRIPT=scripts/restart.sh','BASE_URL='+base,'CA_FILE='+ca);after=snapshot()
|
||||
for name,item in before.items():assert after[name]['started_at']!=item['started_at'],name+' not restarted'
|
||||
for item in after.values():
|
||||
if item['service'] in ['api','worker','dispatcher','housekeeping']:assert item['user']=='10001:10001' and item['pid1']=='/usr/local/bin/messenger'
|
||||
request=json.dumps({'Kind':'http','Cert':'operator','URL':'https://grafana:3000/api/dashboards/uid/messenger-lab7','Auth':'grafana','ReturnBody':True})
|
||||
probe=subprocess.run(['docker','compose','--profile','verify','run','--rm','--no-deps','-T','probe'],cwd=clone,env=env,input=request,capture_output=True,text=True,check=True)
|
||||
dashboard=json.loads(probe.stdout);assert dashboard['ok'];dashboard=json.loads(dashboard['body'])['dashboard'];assert len(dashboard['panels'])==24
|
||||
(ROOT/'evidence/persistence-processes.json').write_text(json.dumps({'scope':'disposable real clean clone; fresh CA, secrets and every volume','before':before,'after':after,'fresh_grafana_panels':len(dashboard['panels'])},indent=2)+'\n')
|
||||
print('PASS: real clean clone, independent CA/secrets/volumes, verified HTTPS, full store/API restart, same session/file, non-root PID1, fresh Grafana provisioning')
|
||||
finally:
|
||||
# This unique synthetic project only. Working lab7 and unrelated volumes survive.
|
||||
run('docker','compose','down','-v','--remove-orphans')
|
||||
Reference in New Issue
Block a user