Лаб7: mTLS, Argon2id, OpenBao и исследование отзыва worker
Майорова Софья, БВТ2301, на 5. Трек1. HTTPS/TLS/ACL,18 API tests,13 pipeline groups,3 compromise runs,clean clone,persistence. Original tests/API contract preserved; residual CVE triage in REPORT/security.
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
"""Independent local Git clone, empty project volumes and new CA/secrets; disposable project only."""
|
||||
from pathlib import Path
|
||||
import subprocess,os,json,time,uuid,shutil
|
||||
ROOT=Path(__file__).resolve().parents[1]
|
||||
name='mtusi-lab7-clean-'+uuid.uuid4().hex[:8]
|
||||
clone=ROOT/'build'/name
|
||||
version=subprocess.check_output(['git','rev-parse','HEAD'],cwd=ROOT,text=True).strip()
|
||||
subprocess.run(['git','clone','--no-hardlinks',str(ROOT),str(clone)],check=True,stdout=subprocess.DEVNULL)
|
||||
env=dict(os.environ,COMPOSE_PROJECT_NAME=name,APP_PORT='18444',GRAFANA_PORT='13408',BAO_PORT='18208',
|
||||
BAO_OPERATOR_URL='https://localhost:18208',BASE_URL='https://localhost:18444',
|
||||
CA_FILE=str(clone/'pki/lb/ca.crt'),GRAFANA_URL='https://localhost:13408')
|
||||
started=time.monotonic()
|
||||
results={}
|
||||
proof=None
|
||||
with (ROOT/'evidence/clean-clone.txt').open('w') as out:
|
||||
def run(label,args,extract=None):
|
||||
begin=time.monotonic()
|
||||
proc=subprocess.run(args,cwd=clone,env=env,stdout=subprocess.PIPE,stderr=subprocess.STDOUT,text=True)
|
||||
out.write('\n$ '+label+'\n'+proc.stdout);out.flush()
|
||||
if proc.returncode:raise RuntimeError(label+' failed; see clean-clone log')
|
||||
results[label]={'pass':True,'seconds':round(time.monotonic()-begin,3)}
|
||||
if extract:
|
||||
text=proc.stdout
|
||||
data=json.loads(text[text.index('{'):])
|
||||
(clone/'evidence'/extract).write_text(json.dumps(data,indent=2)+'\n')
|
||||
try:
|
||||
assert not (clone/'operator').exists() and not (clone/'pki').exists()
|
||||
run('fresh bootstrap, build, migrations and verified HTTPS ready',['python3','scripts/start.py'])
|
||||
run('check + public HTTPS smoke + untrusted CA +18 API/image tests',
|
||||
['make','check','test','test-security','test-student','BASE_URL='+env['BASE_URL'],'CA_FILE='+env['CA_FILE']])
|
||||
run('internal TLS/identity/raw-port/ACL audit',
|
||||
['docker','compose','--profile','tools','run','--rm','--no-deps','audit','/app/student-tests/tls_audit.py'],'tls-audit.json')
|
||||
run('Argon/rehash/expiry/rate limit/S3 ACL/real trace canaries',
|
||||
['docker','compose','--profile','tools','run','--rm','--no-deps','audit','/app/student-tests/auth_and_signals.py'],'auth-signals.json')
|
||||
run('full business + historical telemetry + existing Bao store restart',['python3','student-tests/persistence_tls.py'])
|
||||
run('Grafana HTTPS/mTLS datasources and21 panels',['python3','student-tests/grafana_tls.py'])
|
||||
run('effective hardening and actual listeners',['python3','student-tests/hardening.py'])
|
||||
proof={'pass':True,'commit_tested':version,'project':name,'fresh_secrets_pki_and_volumes':True,
|
||||
'independent_ports':[18444,13408,18208],'results':results,'seconds':round(time.monotonic()-started,3),
|
||||
'main_lab7_data_reset':False}
|
||||
finally:
|
||||
cleanup=subprocess.run(['docker','compose','down','-v','--remove-orphans'],cwd=clone,env=env,
|
||||
stdout=subprocess.PIPE,stderr=subprocess.STDOUT,text=True)
|
||||
out.write('\n$ cleanup ONLY disposable project '+name+'\n'+cleanup.stdout)
|
||||
assert cleanup.returncode==0
|
||||
assert clone.parent==ROOT/'build' and clone.name.startswith('mtusi-lab7-clean-')
|
||||
shutil.rmtree(clone)
|
||||
if proof:
|
||||
proof['only_disposable_project_volumes_deleted']=True
|
||||
(ROOT/'evidence/clean-clone.json').write_text(json.dumps(proof,indent=2)+'\n')
|
||||
print('PASS independent clean clone, new secrets and empty volumes; only disposable project removed.')
|
||||
Reference in New Issue
Block a user