"""Operator internal TLS/policy and runtime hardening audit; no Config.Env dump.""" import subprocess from pipeline_helpers import * def main(): result = json.loads(compose('run', '--rm', '--no-deps', 'audit')) check(result['status'] == 'PASS', 'TLS matrix audit failed') controls = {} for service in ['api1', 'api2', 'worker', 'dispatcher', 'cleanup', 'otel-collector', 'prometheus', 'loki', 'tempo', 'grafana', 'nginx']: container = compose('ps', '-q', service) info = json.loads(subprocess.check_output(['docker', 'inspect', container], text=True))[0] h = info['HostConfig'] check(not h['Privileged'] and h['NetworkMode'] != 'host', 'unsafe container privilege') check(h['ReadonlyRootfs'] and 'ALL' in h['CapDrop'], 'missing read_only/cap_drop') check(any('no-new-privileges' in x for x in h['SecurityOpt']), 'missing no-new-privileges') check(h['Memory'] > 0 and h['NanoCpus'] > 0, 'missing resource limit') check(not any('docker.sock' in m['Source'] for m in info['Mounts']), 'Docker socket exposed') if service in ['api1', 'api2', 'worker', 'dispatcher', 'cleanup']: check(info['Config']['User'].split(':')[0] not in ('', '0', 'root'), 'application runs as root') check(not any('/secrets/operator' in m['Source'] for m in info['Mounts']), 'operator material exposed') controls[service] = 'PASS' result['runtime_hardening'] = controls dump_evidence('tls-matrix-grade4.json', result) print('PASS: TLS/mTLS matrix, denied identities, closed plaintext hops, scoped Bao and runtime hardening') if __name__ == '__main__': run(main)