Files
Investidor-V2/outputs/investmoz-audit-current-20261012/qa21-address-mismatch-readonly-20261013.py
T
nala ba1c0340ea
tests / ci (push) Canceled after 0s
oportunidades 8
2026-10-14 08:25:30 +02:00

31 lines
2.3 KiB
Python

from pathlib import Path
from urllib.request import Request,build_opener,HTTPSHandler,HTTPRedirectHandler
from urllib.error import HTTPError,URLError
from datetime import datetime,timezone
from urllib.parse import urlparse
import ssl,json
OUT=Path(__file__).resolve().parent
dest=OUT/'qa21-address-mismatch-readonly-20261013.json';assert not dest.exists(),'Do not repeat address probe'
class NoRedirect(HTTPRedirectHandler):
def redirect_request(self,*a,**k):return None
client=build_opener(HTTPSHandler(context=ssl.create_default_context()),NoRedirect())
proof={'at':datetime.now(timezone.utc).isoformat(),'reported_URL':'http://127.0.0.1:18445/login','copied_forgot_password_URL':'http://127.0.0.1:18118/forgot-password',
'intended_QA_URL':'https://portal-investidor.test:18445/login','HTTP_read_only':True,'credentials_submitted':False,'TLS_bypass':False,'redirects_followed':False,'active_changes':0,'QA_database_changes':0,'checks':[]}
for url in ['http://127.0.0.1:18445/login','https://portal-investidor.test:18445/_qa/runtime','http://127.0.0.1:18118/login']:
entry={'url':url,'method':'GET'}
try:
try:r=client.open(Request(url,headers={'Accept':'application/json'}),timeout=15)
except HTTPError as e:r=e
body=r.read();entry['status']=r.code;loc=r.headers.get('Location');entry['redirect_origin']=f'{urlparse(loc).scheme}://{urlparse(loc).netloc}'if loc else None;r.close()
if url.endswith('/_qa/runtime'):
d=json.loads(body);entry['target']=d['target'];entry['expected_QA_target_verified']=d['target']['database']=='stability_consumers_20261011_084534_test'and int(d['target']['port'])==55441
if url=='http://127.0.0.1:18445/login':
entry['plaintext_on_TLS_port_message']=b'plain HTTP' in body or b'SSL' in body or b'HTTPS' in body
except (URLError,OSError,ValueError)as e:entry.update(error_type=type(e).__name__)
proof['checks'].append(entry)
proof['intended_server_isolated']=any(e.get('expected_QA_target_verified')for e in proof['checks'])
proof['reported_URL_not_equivalent_to_intended_QA']=True
proof['manual_browser_response_not_inspected']=True
proof['no_password_or_MFA_reset_needed_from_available_evidence']=True
dest.write_text(json.dumps(proof,ensure_ascii=False,indent=2)+'\n',encoding='utf-8');print(json.dumps(proof,ensure_ascii=False))