883 files, from working commit b1a079a. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
48 lines
3.1 KiB
Python
48 lines
3.1 KiB
Python
#!/usr/bin/env python3
|
|
"""Validate bounded, non-executing parsing of both real diagnostic export shapes."""
|
|
from pathlib import Path
|
|
import sys
|
|
sys.path.insert(0,str(Path(__file__).resolve().parents[1]/'ops'))
|
|
from console_report import parse,native_error_summary
|
|
|
|
saved=parse('GatewayDiagnosticsSaved={ ["commands"]={{["command"]="help",["commandType"]=1,},},["escaped"]="a\\010b",["registered"]=true,}')
|
|
assert saved['commands'][0]['command']=='help' and saved['escaped']=='a\nb'
|
|
native=parse('Blizzard_Console_SavedVars={ ["messageHistory"]={{"Commands registered for the category console:",1},}, ["commandHistory"]={"help console"},}', 'Blizzard_Console_SavedVars')
|
|
assert native['messageHistory'][0][1]==1 and native['commandHistory']==['help console']
|
|
assert parse('GatewayDiagnosticsSaved={ ["hp"]=nil --[[ secret value ]], ["ghost"]=true }')=={'hp':None,'ghost':True}
|
|
assert parse('GatewayDiagnosticsSaved={ ["text"]="--[[ secret value ]]" }')['text']=='--[[ secret value ]]'
|
|
for bad in ('GatewayDiagnosticsSaved={nil --[[ other comment ]]}',
|
|
'GatewayDiagnosticsSaved={1 --[[ secret value ]]}',
|
|
'GatewayDiagnosticsSaved={nil --[[ secret value ]] os.execute("bad")}',
|
|
'GatewayDiagnosticsSaved={nil --[[ secret value ]'):
|
|
try:parse(bad)
|
|
except ValueError:pass
|
|
else:raise AssertionError('Non-redaction Lua syntax accepted')
|
|
for bad in ('GatewayDiagnosticsSaved=os.execute("bad")','GatewayDiagnosticsSaved={} while true do end','GatewayDiagnosticsSaved={["x"]=1,["x"]=2}','GatewayDiagnosticsSaved={','GatewayDiagnosticsSaved='+('{1,'*14)+'0'+('}'*14)):
|
|
try:parse(bad)
|
|
except ValueError:pass
|
|
else:raise AssertionError('Executable, ambiguous, truncated or deeply nested Lua accepted')
|
|
print('Console data exports parse without executing Lua; unsafe syntax and bounds are rejected.')
|
|
for bound in (0,-1,500001,True,1.5):
|
|
try:parse('GatewayDiagnosticsSaved={}',max_tokens=bound)
|
|
except ValueError:pass
|
|
else:raise AssertionError('Invalid explicit data token bound accepted')
|
|
try:parse('GatewayDiagnosticsSaved={1,2,3}',max_tokens=4)
|
|
except ValueError:pass
|
|
else:raise AssertionError('Explicit small token ceiling ignored')
|
|
assert parse('GatewayTurtleData={ ["ranks"]={1,2,3}}','GatewayTurtleData',max_tokens=500000)=={'ranks':[1,2,3]}
|
|
try:parse('GatewayTurtleData=os.execute("bad")','GatewayTurtleData',max_tokens=500000)
|
|
except ValueError:pass
|
|
else:raise AssertionError('Larger data bound enabled executable Lua')
|
|
|
|
# Unknown Lua errors may include sensitive user text. Summarize counts only;
|
|
# never export their bodies, while recognizing our two verified probe failures.
|
|
summary=native_error_summary([
|
|
["Lua Error: GWPowerPeak attempt to compare a secret number",1],
|
|
["Lua Error: GW spell cooldown ')' expected near '<eof>'",2],
|
|
["Lua Error: private unrelated contents",3],
|
|
["ordinary private command history"],None])
|
|
assert summary['lua_error_rows']==3 and summary['protected_power_observer_rows']==1 and summary['truncated_cooldown_probe_rows']==1
|
|
assert 'private' not in str(summary) and 'GWPowerPeak' not in str(summary)
|
|
print('Native Lua-error counts exclude arbitrary error bodies and command history.')
|