367 files, from working commit b1a079a. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
45 lines
4.6 KiB
Python
45 lines
4.6 KiB
Python
"""Exact captured source icon filenames with bounded printable spaces.
|
|
|
|
This explicit opt-in path never changes the global icon normalizer or strips a
|
|
source character. Publication uses the established content-addressed asset path.
|
|
"""
|
|
import hashlib,re
|
|
from copy import deepcopy
|
|
from pathlib import Path
|
|
from octo_client_data import canonical_sha256
|
|
POLICY='verified-exact-captured-source-icon-member-v1'
|
|
|
|
def member(token):
|
|
if not isinstance(token,str)or not 1<=len(token)<=128 or '\0'in token:raise ValueError('Bounded captured icon token required')
|
|
text=token.replace('\\','/').lower()
|
|
if not text.startswith('interface/icons/'):text='interface/icons/'+text
|
|
if not text.endswith('.blp'):text+='.blp'
|
|
if not re.fullmatch(r'interface/icons/[a-z0-9_ .-]{1,128}\.blp',text)or any(p in text for p in ('../','/..','//')):raise ValueError('Exact printable source icon member required')
|
|
return text
|
|
|
|
def evidence(proto,source_display,source_icon,source_display_sha256,source_match,asset,root_bytes,payload):
|
|
from octo_icon_assets import decode_blp
|
|
from casc_asset_package import root_controls,root_groups
|
|
ident=proto['entry'];display=proto['display_id'];path=member(source_icon)
|
|
if source_display[0]!=display or len(source_display)!=23:raise ValueError('Captured item display identity differs')
|
|
if not isinstance(source_display_sha256,str)or not re.fullmatch('[a-f0-9]{64}',source_display_sha256):raise ValueError('Pinned source display bytes required')
|
|
if (source_match.get('member')!=path or not any(r==dict(entry=ident,display_id=display,captured_source_icon=source_icon)for r in source_match.get('users',[]))or source_match.get('sha256')!=hashlib.sha256(payload).hexdigest()or source_match.get('bytes')!=len(payload)):
|
|
raise ValueError('Exact source archive/member/item proof differs')
|
|
decode_blp(payload);digest=hashlib.sha256(payload).hexdigest();key=hashlib.md5(payload).hexdigest();safe='wowhybrid/source-equipment/'+digest+'.blp'
|
|
if (asset.get('path')!=safe or asset.get('source_path')!=path or asset.get('sha256')!=digest or asset.get('content_key')!=key or asset.get('bytes')!=len(payload)or type(asset.get('file_data_id'))is not int or asset['file_data_id']<=0):raise ValueError('Exact source icon registered asset differs')
|
|
controls=root_controls(root_bytes,root_groups(root_bytes),{asset['file_data_id']})
|
|
if set(controls)!={asset['file_data_id']}or{r['content_key']for r in controls[asset['file_data_id']]}!={key}:raise ValueError('Registered exact source icon ROOT identity differs')
|
|
proof=dict(policy=POLICY,entry=ident,source_display_id=display,source_record_sha256=canonical_sha256(proto),source_icon=source_icon,exact_source_member=path,source_display_row_sha256=canonical_sha256(list(source_display)),source_display_sha256=source_display_sha256,source_archive=source_match['archive'],source_artwork_sha256=digest,source_artwork_content_key=key,source_artwork_bytes=len(payload),source_artwork_path=safe,native_icon_file_data_id=asset['file_data_id'],registered_root_sha256=hashlib.sha256(root_bytes).hexdigest(),registered_root_md5=hashlib.md5(root_bytes).hexdigest(),exact_member_bytes_verified=True,pixel_decode_verified=True,source_character_rewrites=False)
|
|
verify(proto,proof);return proof
|
|
|
|
def verify(proto,proof):
|
|
if not isinstance(proof,dict)or proof.get('policy')!=POLICY or proof.get('entry')!=proto.get('entry')or proof.get('source_display_id')!=proto.get('display_id')or proof.get('source_record_sha256')!=canonical_sha256(proto):raise ValueError('Exact source icon item identity differs')
|
|
if proof.get('exact_source_member')!=member(proof.get('source_icon')):raise ValueError('Source icon member was rewritten')
|
|
for k in ('source_artwork_sha256','source_display_row_sha256','source_display_sha256','registered_root_sha256'):
|
|
if not isinstance(proof.get(k),str)or not re.fullmatch('[a-f0-9]{64}',proof[k]):raise ValueError('Exact source icon SHA proof missing')
|
|
for k in ('source_artwork_content_key','registered_root_md5'):
|
|
if not isinstance(proof.get(k),str)or not re.fullmatch('[a-f0-9]{32}',proof[k]):raise ValueError('Exact source icon content proof missing')
|
|
if proof.get('source_artwork_path')!='wowhybrid/source-equipment/'+proof['source_artwork_sha256']+'.blp'or type(proof.get('native_icon_file_data_id'))is not int or proof['native_icon_file_data_id']<=0 or type(proof.get('source_artwork_bytes'))is not int or not 20<=proof['source_artwork_bytes']<=4194304 or proof.get('exact_member_bytes_verified')is not True or proof.get('pixel_decode_verified')is not True or proof.get('source_character_rewrites')is not False:
|
|
raise ValueError('Complete decoded and registered exact source icon proof required')
|
|
return proof['native_icon_file_data_id']
|