Skip to content

fix: validate LDS fuzzer CLI arguments - #874

Merged
ItsNotRexed merged 1 commit into
ItsNotRexed:mainfrom
Italo-Felipe-dev:fix/lds-fuzz-cli-validation
Nov 22, 2026
Merged

ItsNotRexed merged 1 commit into
ItsNotRexed:mainfrom
Italo-Felipe-dev:fix/lds-fuzz-cli-validation

Conversation

@Italo-Felipe-dev

Copy link
Copy Markdown
Contributor

Claimed in #634: #634 (comment)

What and why

tools/lds_fuzz.py did not validate several CLI arguments.

Two bugs were reproduced on Windows 11:

  • --programs 0 --model-only printed 0 programs generated and modelled and returned exit code 0, falsely indicating success without testing anything.
  • --show invalido raised an unhandled ValueError traceback instead of reporting a CLI argument error.

Changes

  • Reject zero or negative values for --programs and --max-report.
  • Validate --show SEED:INDEX[:WAVE], requiring a non-negative index and wave size 32 or 64.
  • Report invalid arguments through argparse with exit code 2.
  • Preserve valid arguments and normal fuzzer behavior.
  • Add CPU-only regression tests in tests/test_lds_fuzz_cli.py.

Tested

Windows 11, Python 3.14.5.

Before the fix:

  • --programs 0 --model-only returned exit code 0 without running tests.
  • --show invalido raised ValueError with exit code 1.
  • Both initial regression tests reproduced the failures.

After the fix:

python -m pytest -q tests/test_lds_fuzz.py tests/test_lds_fuzz_cli.py

Result: 28 passed, 16 subtests passed in 0.34s.

  • git diff --cached --check: no formatting errors.
  • GPU: not required.
  • No game files, shaders from the game, keys or decryption involved.

Notes

This change is independent of #789 (ds_permute_b32 fuzzing), although both PRs modify tools/lds_fuzz.py.

Checklist

  • Bug reproduced before the fix.
  • Regression tests added.
  • Existing tests pass.
  • No game data used.
  • AI-assisted contribution disclosed.

@kapitche

Copy link
Copy Markdown
Contributor

Tested 307ef01 on Linux (WSL2 Ubuntu), Python 3.12, CPU only: pass

  • pytest tests/test_lds_fuzz_cli.py: 6 passed, 16 subtests
  • Negative control: with tools/lds_fuzz.py from main, 15 fail.
  • Code read: the same checks and messages as valu_fuzz.py (valu_fuzz.py: validate --programs, --max-report, and --show via ap.error #673): --programs/--max-report at least 1, --show SEED:INDEX[:WAVE] with INDEX ≥ 0 and WAVE 32 or 64, all through ap.error (exit 2). The two fuzzers now reject bad arguments the same way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants