skinned_glb: validate GLB chunks, accessor bounds, skeleton cycles, skin streams, and indices (SKINNED-GLB-VALIDATION-HARDENING) #1512
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1512"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from ubiquitarianism/leonida. Originally posted by IlyassRS3 on 2026-11-25T02:57:12Z.
Claimed in the coordination issue as: SKINNED-GLB-VALIDATION-HARDENING (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7151315288)
What and why
Hardens
tools/skinned_glb.pyagainst malformed GLB containers, out-of-bounds accessors, cyclic skeletons, short skin headers,bool-as-intbugs, and invalid glTF primitive indices/attributes:read_glb):total_lengthagainst file size,CHUNK_JSON/CHUNK_BINchunk types, and JSON/BIN chunk bounds (plusRecursionErroron malformed JSON), raisingSkinErrorinstead of accepting truncated or non-BIN chunks.accessor_bytes):boolindices, counts, strides, and byte offsets, validatesbufferView.byteLengthagainstbin_data, and ensures the accessor span does not extend past itsbufferView._finite_matrix,_bone_name_map,JointSet,PaletteResolver,own_parent_name):_finite_matrixchecksisinstance(m, (list, tuple))and rejectsboolelements instead of raising rawTypeErrorwhenbind_matrixisNone.JointSet.__init__rejects non-dict bone entries, ignoresboolparentvalues, and rejects self-parenting and multi-bone parent cycles withSkinErrorinstead of producing cyclic glTF node graphs;JointSet.addrejectsboolparent.PaletteResolverandown_parent_nameguard against non-dict/non-listdrawable/skeleton/stringsfields andboolparent indices.read_skin_streams,normalise_weights):base + 92 > len(blob)) withSkinErrorbefore reading the 23-word section header (previously raised uncaughtstruct.erroron CLI).boolgeometry/model/vertex_bufferindices,boolbone_palette/vertex_count/gfx_off/mesh_blob.sectionsentries, non-stringbuffer_filesentries, andboolarguments innormalise_weights(and removes a duplicate zeroing line in the NumPy path).build_skinned_glb,_validate_indices):NORMAL,TANGENT,TEXCOORD_*,COLOR_0) matchesstreams["count"], not justPOSITION.SCALARwith integercomponentType(UNSIGNED_BYTE/UNSIGNED_SHORT/UNSIGNED_INT), positive multiple-of-3 count, and all indices< vertex_count.OverflowErrorwhen packinginverseBindMatricesand converts it toSkinError.main):sys.path.insert.Tested
python3 -I tests/test_skinned_glb.py -v(stdlib path): 38/38 OK (30 existing + 8 new tests inValidationHardeningTests).python3 tests/test_skinned_glb.py(with NumPy installed): 38/38 OK.main:tools/skinned_glb.py: all 8 new tests inValidationHardeningTestsfail (FAILED (failures=17, errors=4)).python3 -I tests/test_text_write_line_endings.py: 3/3 OK.python3 -I scripts/check_no_game_data.py tools/skinned_glb.py tests/test_skinned_glb.py: clean.python3 -m compileall -q tools/skinned_glb.py tests/test_skinned_glb.py: clean.GPUs tested: n/a (Python tool, synthetic unit tests only, no GPU or game data)
AI-assisted: yes
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed. (n/a — no translator rule changes)Imported from ubiquitarianism/leonida. Originally posted by copilot-pull-request-reviewer[bot] on 2026-11-25T02:57:21Z.
Review: COMMENTED
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
Imported from ubiquitarianism/leonida. Originally posted by ytsodacan on 2026-11-25T03:34:06Z.
[KEEP]
tools/skinned_glb.pyandtests/test_skinned_glb.py(+447/-46), mergeable, and no other open or closed PR touchesskinned_glb.change-scopeandno-game-dataare still pending, so there is no green signal yet.Imported from ubiquitarianism/leonida. Originally posted by whoalin1 on 2026-11-25T07:45:18Z.
Independent verification (native Windows, Python 3.11.9, NumPy path exercised): diff vs merge-base reviewed; GLB version/length/chunk/bounds validation + RecursionError, accessor bufferView bounds + bool/negative rejection, JointSet parent-cycle detection, skin-stream index/gfx_off/sections/buffer_files validation,
normalise_weightsbool guards,_validate_indices(SCALAR/int/multiple-of-3/max<vertex_count), IBM OverflowError→SkinError, CLI output-dir check all present. Tests:test_skinned_glb.py38/38 (matches claim),test_report_paths.py22 OK, line-endings 3/3, compileall +check_no_game_data.pyclean. AI-assisted verification.Imported from ubiquitarianism/leonida. Originally posted by TheGeogeo on 2026-11-29T00:17:18Z.
Tested
530d8eb4emerged (no commit) withmain829530dbd: Python 3.12.4, Windows 11 10.0.26300, CPU only.check_no_game_data.pyis clean.tests/test_skinned_glb.py, 40 tests pass.tools/skinned_glb.pyback tomain, 18 failures and 3 errors (SkinError not raised).No blocker from my side.
AI-assisted (Claude Code).
Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-29T00:43:54Z.
Merged after TheGeogeo's red/green check (check) (Windows, Python tests, no GPU needed) and a local re-check here. Merged after local re-verification: this PR merged onto
main61b28f3b4without conflict, and its test file(s) (tests/test_bcpack_tool.py,tests/test_skinned_glb.py) pass there. Earlier today the same tests failed onmainwithout the PR (red/green) and a bundle with other open PRs showed no new failures.check_no_game_data.pyis clean. Windows 11, Python 3.14; no GPU needed for these tests.AI-assisted (Claude Code, Claude Opus 5.5), merged for MoonEyes.