mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-26 23:30:53 +01:00
[PR #1607] shader_stats: reject traversal shader names, support UTF-8 BOM, and harden CLI/number guards (SHADER-STATS-VALIDATION-AND-CLI) #1622
Labels
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
starred/leonida#1622
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
📋 Pull Request Information
Original PR: https://github.com/ubiquitarianism/leonida/pull/1607
Author: @IlyassRS3
Created: 11/25/2026
Status: 🔄 Open
Base:
main← Head:fix/shader-stats-validation-and-cli📝 Commits (1)
ec6dffdshader_stats: reject traversal shader names, support UTF-8 BOM, and harden CLI/number guards📊 Changes
2 files changed (+113 additions, -9 deletions)
View changed files
📝
scripts/shader_stats.py(+25 -9)📝
tests/test_shader_stats.py(+88 -0)📄 Description
Item ID:
SHADER-STATS-VALIDATION-AND-CLI(unlisted; coordination issue #14 is at GitHub's 2,500-comment cap with no open successor at submission time, and no open PR touchesscripts/shader_stats.py).What changed
scripts/shader_stats.py,_safe_shader_name,load_stats): previouslyos.path.join(disasm, name + ".s")allowed absolute paths or../entries instats.csvto read.sfiles outside<disasm dir>. Nowload_stats()validates that each row'snameis a single non-empty filename stem with no path separators, drive prefix, NUL byte,.or...load_stats): decodestats.csvwithutf-8-sigso BOM-prefixed CSVs do not fail withmissing required header column(s): name.<disasm dir>before matching listings (main): report<disasm dir>: not a directoryinstead of silently skipping every shader and exiting with"no shader is in both...".boolinnumber()and emptyvlistinoriginal():number(True)previously crashed insideDecimal(True)with an uncaughtTypeError, and an emptyvlistcrashedmax().main(argv=None)option and path parsing: accept optionalargv, check"--details" in argvinstead ofsys.argv, reject unknown single-dash flags (e.g.-d) asunknown optioninstead of misparsing them as positional arguments, and reject whitespace-only<stats.csv>/<disasm dir>.tests/test_shader_stats.py): 6 new test methods covering all of the above (no game files, no GPU).Verification
python3 -W error -I tests/test_shader_stats.py -v: 29 passedpython3 -W error -I tests/test_text_write_line_endings.py: passedpython3 -I scripts/check_no_game_data.py scripts/shader_stats.py tests/test_shader_stats.py: cleanpython3 -m compileall -q scripts/shader_stats.py tests/test_shader_stats.py: cleantests/test_shader_stats.pyagainst unpatchedmain:scripts/shader_stats.py): 11 failures, 1 error across the 29 tests (all 6 new tests fail on unpatchedmain).🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.