17 lines
854 B
Python
17 lines
854 B
Python
"""Malformed optional telemetry must not break the business/health response."""
|
|
import json
|
|
import sys
|
|
from pathlib import Path
|
|
import urllib.request
|
|
ROOT=Path(__file__).resolve().parents[1]
|
|
sys.path.insert(0,str(ROOT/'student-tests'))
|
|
from security import context,check,save
|
|
results=[]
|
|
for name in ('traceparent','tracestate'):
|
|
req=urllib.request.Request('https://api1:8443/health/live',headers={name:'\xff'})
|
|
with urllib.request.urlopen(req,context=context('lb'),timeout=10) as response:
|
|
check(response.status==200 and response.headers['X-Request-Id'],'telemetry header caused API failure')
|
|
results.append({'header':name,'invalid_byte':'ff','status':response.status})
|
|
save('malformed-telemetry-headers.json',{'result':'PASS','probes':results})
|
|
print('PASS: non-ASCII optional trace headers ignored safely on verified mTLS API')
|