"""Authorized anonymous GET-only inspection; never persist diagnostic contents.""" from pathlib import Path from urllib.request import Request, build_opener, HTTPRedirectHandler from urllib.error import HTTPError from urllib.parse import urlparse from datetime import datetime, timezone import hashlib, json, re ROOT=Path(__file__).resolve().parents[2] OUT=Path(__file__).resolve().parent BASE='https://portal-investidor.test' FILES=['config/inertia.php','public/build/manifest.json'] before={p:hashlib.sha256((ROOT/p).read_bytes()).hexdigest() for p in FILES} class NoRedirect(HTTPRedirectHandler): def redirect_request(self,req,fp,code,msg,headers,newurl): return None client=build_opener(NoRedirect()) # No cookie jar, authorization or TLS bypass. def get(path): assert path.startswith('/_inertia/devtools/entries') req=Request(BASE+path,headers={'Accept':'application/json','Accept-Encoding':'identity'},method='GET') assert not any(k.lower() in ['cookie','authorization','x-xsrf-token'] for k in req.headers) try: res=client.open(req,timeout=25) except HTTPError as err: res=err with res: status=res.code content_type=res.headers.get('Content-Type','') body=res.read(20*1024*1024) return status, content_type, json.loads(body) if 'json' in content_type and status==200 else None proof={'at':datetime.now(timezone.utc).isoformat(),'case':'C132','environment':'active', 'base':BASE,'target_from_existing_read_only_receipt':'investemoz:5432', 'request_methods':['GET'],'authenticated':False,'cookies_or_tokens_sent':False, 'TLS_bypass':False,'response_bodies_saved':False,'personal_values_saved':False, 'application_code_config_or_business_data_mutations':0, 'incidental_server_logging_or_guest_session_metadata':'Normal effects of GET are possible; not counted as business writes.'} status,ctype,entries=get('/_inertia/devtools/entries') proof['index']={'status':status,'json_array':isinstance(entries,list)} if status==200 and isinstance(entries,list): proof['index']['entries_exposed']=len(entries) proof['index']['metadata_keys']=sorted({k for entry in entries if isinstance(entry,dict) for k in entry}) families={} samples=[] for entry in entries: if not isinstance(entry,dict): continue path=urlparse(str(entry.get('url',''))).path family=next((name for prefix,name in [('/management/','management'),('/minhas-oportunidades','opportunity_editor'),('/investimentos','private_dossier'),('/dashboard','dashboard'),('/two-factor','MFA'),('/login','login')] if path.startswith(prefix)),'other') families[family]=families.get(family,0)+1 if family in ['management','opportunity_editor','dashboard','private_dossier'] and re.fullmatch(r'[0-9A-HJKMNP-TV-Z]{26}',str(entry.get('id',''))): samples.append(entry) proof['index']['route_family_counts']=families proof['index']['post_requests_metadata']=sum(1 for e in entries if isinstance(e,dict) and e.get('method')=='POST') # One retained operational entry suffices to verify access to contents, not just metadata. chosen=samples[0] if samples else next((e for e in entries if isinstance(e,dict) and re.fullmatch(r'[0-9A-HJKMNP-TV-Z]{26}',str(e.get('id','')))),None) if chosen: status,ctype,detail=get('/_inertia/devtools/entries/'+chosen['id']) detail_proof={'status':status,'entry_identifier_saved':False} if status==200 and isinstance(detail,dict): detail_proof['top_level_fields']=sorted(detail) http=detail.get('http') or {} headers=http.get('requestHeaders') or {} header_names={str(k).lower() for k in headers} if isinstance(headers,dict) else set() props=detail.get('propValues') or {} detail_proof.update( request_headers_present=bool(headers), cookie_header_present='cookie' in header_names, xsrf_header_present='x-xsrf-token' in header_names, request_body_present=http.get('requestBody') is not None, response_body_present=http.get('responseBody') is not None, prop_values_present=bool(props), authenticated_user_object_present=isinstance(props,dict) and isinstance(props.get('auth'),dict) and bool(props['auth'].get('user')), source_paths_present=bool(detail.get('renderSource') or detail.get('componentPath')), no_values_exported=True) proof['detail']=detail_proof proof['result']='exposure_confirmed' if proof.get('detail',{}).get('status')==200 else 'metadata_exposure_confirmed' else: proof['result']='not_reproduced_or_unavailable' after={p:hashlib.sha256((ROOT/p).read_bytes()).hexdigest() for p in FILES} assert before==after proof['active_source_and_bundle_unchanged']=True proof['source_hashes']=after (OUT/'C132-active-readonly.json').write_text(json.dumps(proof,ensure_ascii=False,indent=2),encoding='utf-8') print(json.dumps(proof,ensure_ascii=True))