import json,sys,platform import json from urllib.parse import unquote # All strings are newly authored synthetic fixtures. No production logs are read. fixtures=[ {'id':'top-level','record':{'event':'open','status':200,'durationMs':12,'email':'user0@example.test','authorization':'Bearer TEST_TOKEN_00'},'markers':['user0@example.test','TEST_TOKEN_00']}, {'id':'nested-context','record':{'event':'fetch','status':401,'durationMs':8,'context':{'email':'user1@example.test','session':{'token':'TEST_TOKEN_01'}}},'markers':['user1@example.test','TEST_TOKEN_01']}, {'id':'case-variant','record':{'event':'auth','status':403,'Email':'user2@example.test','Authorization':'Bearer TEST_TOKEN_02'},'markers':['user2@example.test','TEST_TOKEN_02']}, {'id':'encoded-query','record':{'event':'request','status':200,'url':'https://example.test/?token=TEST%5FTOKEN%5F03&email=user3%40example.test'},'markers':['TEST_TOKEN_03','user3@example.test']}, {'id':'freeform-message','record':{'event':'error','status':500,'message':'TEST_PERSON_04 pasted TEST_TOKEN_04 while opening user4@example.test'},'markers':['TEST_PERSON_04','TEST_TOKEN_04','user4@example.test']}, {'id':'unknown-field','record':{'event':'job','status':202,'durationMs':33,'custom_blob':['TEST_SECRET_05',{'note':'TEST_PERSON_05'}]},'markers':['TEST_SECRET_05','TEST_PERSON_05']} ] def limited_keys(record):return {k:('[REDACTED]' if k in {'email','authorization'} else v) for k,v in record.items()} EVENTS={'open','fetch','auth','request','error','job'} def bounded_allowlist(record): # Deliberately drop all freeform/nested/URL data; preserve bounded diagnostics. out={'event':record.get('event') if record.get('event') in EVENTS else 'unknown-event'} if type(record.get('status')) is int and 100<=record['status']<=599:out['status']=record['status'] if type(record.get('durationMs')) in (int,float) and 0<=record['durationMs']<=3600000:out['durationMs']=record['durationMs'] return out def known_markers_removed(record,markers): text=unquote(json.dumps(record,ensure_ascii=False)) return all(marker not in text for marker in markers) rows=[] for fixture in fixtures: a=limited_keys(fixture['record']);b=bounded_allowlist(fixture['record']) rows.append({'id':fixture['id'],'input':fixture['record'],'knownMarkers':fixture['markers'],'limitedKeyOutput':a,'allowlistOutput':b,'limitedKeyKnownMarkersRemoved':known_markers_removed(a,fixture['markers']),'allowlistKnownMarkersRemoved':known_markers_removed(b,fixture['markers']),'eventAndStatusPreserved':all(b[k]==fixture['record'][k] for k in ['event','status']),'durationPreserved':('durationMs' not in fixture['record'] or b.get('durationMs')==fixture['record']['durationMs']),'freeformContentDropped':any(k not in {'event','status','durationMs'} for k in fixture['record'])}) result={'cases':rows,'limitedKeyPasses':sum(r['limitedKeyKnownMarkersRemoved'] for r in rows),'allowlistPasses':sum(r['allowlistKnownMarkersRemoved'] for r in rows),'caseCount':len(rows),'knownMarkersOnly':True,'unknownSensitiveDataGuaranteedAbsent':False,'diagnosticTradeoff':'Arbitrary messages, URLs and nested context are intentionally dropped. Only enumerated event, bounded numeric status and duration are retained. This is a fixture-specific publishing view, not universal anonymization.'} assert result['limitedKeyPasses']==1 and result['allowlistPasses']==6 assert all(r['eventAndStatusPreserved'] and r['durationPreserved'] for r in rows) from datetime import datetime as _runtime_datetime, timezone as _runtime_timezone result.update({'fixtureCreatedOn':'2026-10-15','executedAt':_runtime_datetime.now(_runtime_timezone.utc).isoformat(),'runtime':platform.python_version(),'synthetic':True}) print(json.dumps(result,ensure_ascii=False,indent=2))