Майорова Софья, БВТ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.
34 lines
2.0 KiB
Python
34 lines
2.0 KiB
Python
"""Operator probes with the saved compromised cert and old credentials, on fresh connections."""
|
|
import json
|
|
from pathlib import Path
|
|
from security_helpers import *
|
|
from botocore.exceptions import ClientError
|
|
old=json.loads(Path('/operator/revoked-worker-settings.json').read_text())
|
|
results={}
|
|
for host,port,path in [('broker',8443,'/'),('s3',8443,'/messenger-attachments'),('otel-collector',8443,'/v1/traces')]:
|
|
try:raw=probe(host,port,'revoked-worker',path)
|
|
except (OSError,ssl.SSLError):raw=b''
|
|
assert not raw,'Revoked leaf still works at '+host
|
|
results[host]='revoked leaf denied on fresh connection'
|
|
try:db('worker',old['worker'])
|
|
except psycopg.OperationalError as error:assert 'password authentication failed' in str(error)
|
|
else:raise AssertionError('Old database password accepted')
|
|
results['postgres']='old password denied'
|
|
try:
|
|
redis.Redis(host='broker',port=8443,username='worker',password=old['broker_worker'],ssl=True,
|
|
ssl_ca_certs='/tls/ca.crt',ssl_certfile=str(cert('worker')/'tls.crt'),ssl_keyfile=str(cert('worker')/'tls.key'),
|
|
ssl_check_hostname=True,socket_connect_timeout=2,socket_timeout=3).ping()
|
|
except redis.AuthenticationError:results['broker_old_password_with_new_certificate']='AUTH rejected'
|
|
else:raise AssertionError('Old broker password still works')
|
|
try:bao('auth/cert/login','revoked-worker',{'name':'worker'})
|
|
except urllib.error.HTTPError as error:assert error.code in (400,403)
|
|
else:raise AssertionError('Old leaf still authenticates to Bao')
|
|
results['bao']='old exact leaf denied'
|
|
# A valid NEW client cert with the OLD S3 key must still fail, proving secret rotation independently.
|
|
SETTINGS['s3_worker_key']=old['s3_worker_key'];SETTINGS['s3_worker']=old['s3_worker']
|
|
try:s3('worker').head_bucket(Bucket='messenger-attachments')
|
|
except ClientError as error:assert error.response['ResponseMetadata']['HTTPStatusCode']==403
|
|
else:raise AssertionError('Old S3 credential still works')
|
|
results['s3_old_key_with_new_certificate']='403'
|
|
print(json.dumps(results,indent=2))
|