95 lines
3.8 KiB
Python
95 lines
3.8 KiB
Python
import json
|
|
import re
|
|
|
|
def get_ids_and_failures(file_path):
|
|
with open(file_path, 'r', encoding='utf-8') as f:
|
|
har_data = json.load(f)
|
|
|
|
entries = har_data['log']['entries']
|
|
|
|
instance_ids = set()
|
|
operation_ids = set()
|
|
dates = set()
|
|
|
|
# Try to find UUIDs that look like instance or operation IDs
|
|
# Usually in URLs or body
|
|
for entry in entries:
|
|
req = entry['request']
|
|
resp = entry['response']
|
|
|
|
# Check Date header
|
|
for header in resp.get('headers', []):
|
|
if header['name'].lower() == 'date':
|
|
dates.add(header['value'])
|
|
|
|
url = req.get('url', '')
|
|
# Pattern for UUID
|
|
uuids = re.findall(r'[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}', url)
|
|
for u in uuids:
|
|
instance_ids.add(u)
|
|
|
|
resp_text = ""
|
|
if 'content' in resp and 'text' in resp['content']:
|
|
resp_text = resp['content']['text']
|
|
# Look for instanceOperation or similar
|
|
if 'instanceOperation' in resp_text:
|
|
op_uuids = re.findall(r'"id":"([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})"', resp_text)
|
|
for u in op_uuids:
|
|
operation_ids.add(u)
|
|
|
|
# Look for instance id
|
|
inst_uuids = re.findall(r'"instanceId":"([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})"', resp_text)
|
|
for u in inst_uuids:
|
|
instance_ids.add(u)
|
|
|
|
print(f"File: {file_path}")
|
|
print(f"Possible Instance IDs: {instance_ids}")
|
|
print(f"Possible Operation IDs: {operation_ids}")
|
|
|
|
# Analyze flow
|
|
print("\nFlow analysis (Status 400+ or instanceOperation):")
|
|
for entry in entries:
|
|
req = entry['request']
|
|
resp = entry['response']
|
|
status = resp['status']
|
|
url = req['url']
|
|
time = entry['startedDateTime']
|
|
|
|
if status >= 400:
|
|
print(f"[{time}] ERROR {status} {req['method']} {url}")
|
|
if 'content' in resp and 'text' in resp['content']:
|
|
print(f" Response: {resp['content']['text'][:500]}")
|
|
|
|
if 'instanceOperation' in url or ('content' in resp and 'text' in resp['content'] and 'instanceOperation' in resp['content']['text']):
|
|
print(f"[{time}] OP_POLL {status} {url}")
|
|
if 'content' in resp and 'text' in resp['content']:
|
|
try:
|
|
data = json.loads(resp['content']['text'])
|
|
if isinstance(data, dict):
|
|
op = data.get('instanceOperation', data)
|
|
if isinstance(op, dict):
|
|
success = op.get('isSuccessful')
|
|
if success is False:
|
|
# Print summary of stages
|
|
stages = op.get('stages', [])
|
|
print(f" FAILED OP STAGES:")
|
|
for s in stages:
|
|
print(f" - {s.get('displayName')} Status: {s.get('isSuccessful')} Msg: {s.get('message')}")
|
|
print(f" FULL ERROR LOG: {op.get('errorLog')}")
|
|
else:
|
|
print(f" Op: {op.get('operation')} Success: {success} Progress: {op.get('isInProgress')} Msg: {op.get('message')}")
|
|
except:
|
|
pass
|
|
|
|
print("\n--- Date headers summary ---")
|
|
sun_mon = [d for d in dates if "Sun" in d or "Mon" in d]
|
|
if sun_mon:
|
|
print(f"Found Sun/Mon dates: {sun_mon[:5]}")
|
|
else:
|
|
print("No Sun/Mon dates found in headers.")
|
|
|
|
if __name__ == "__main__":
|
|
import sys
|
|
if len(sys.argv) > 1:
|
|
get_ids_and_failures(sys.argv[1])
|