Skip to content

steam/vdf: reject truncated maps and trailing data; add edge-case tests#5

Merged
astrovm merged 1 commit intomainfrom
codex/improve-test-coverage-and-clean-code
Mar 26, 2026
Merged

steam/vdf: reject truncated maps and trailing data; add edge-case tests#5
astrovm merged 1 commit intomainfrom
codex/improve-test-coverage-and-clean-code

Conversation

@astrovm
Copy link
Copy Markdown
Owner

@astrovm astrovm commented Mar 26, 2026

Motivation

  • The VDF parser accepted truncated maps or allowed trailing tokens after a valid root, which can hide malformed Steam VDF files and produce ambiguous detection results.

Description

  • Make parse_map in src/steam/vdf.rs fail (return None) when a closing } is not found instead of silently accepting EOF.
  • Tighten top-level parsing in parse to call skip_whitespace() and reject the input if any non-whitespace remains after a parsed root object.
  • Update tests in src/steam/vdf.rs to assert strict behavior: change the unclosed-brace test to expect failure and add test_parse_rejects_trailing_non_whitespace_text and test_parse_rejects_second_root_object to cover trailing garbage and multiple top-level objects.
  • Minor formatting adjustments to keep code tidy.

Testing

  • Ran cargo fmt --all successfully.
  • Attempted PKG_CONFIG_PATH=/usr/lib/x86_64-linux-gnu/pkgconfig:/usr/share/pkgconfig cargo test -q steam::vdf::tests, but the test run cannot complete in this environment due to missing system GNOME/GLib pkg-config metadata (glib-2.0.pc), so unit tests should be validated in a developer environment or CI where the native glib-2.0 dev package is installed.

Codex Task

@astrovm astrovm merged commit 1098a09 into main Mar 26, 2026
@astrovm astrovm deleted the codex/improve-test-coverage-and-clean-code branch March 26, 2026 13:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant