Repository navigation
fix(config): write only strict JSON configs; add a stored-config check - #323
Merged
Merged
Conversation
Console firmware with the strict-config check (console-fw fix/jsmn-strict, CFW-12/CFW-15) stores a user config only when it is a strict JSON object that fits its page, and parses the stored config in jsmn strict mode at boot. - MotionConfig.to_wire_bytes raises ValueError, naming the key path, for NaN or infinite values (json.dumps used to write NaN / Infinity, which the console now refuses), and for JSON longer than MOTION_CFG_JSON_MAX_LEN (2019 bytes: the 2036-byte page minus the 16-byte header and the NUL). json.dumps runs with allow_nan=False. - strict_json_problem(text) explains why a config text would not pass: NaN / Infinity / -Infinity, out-of-range numbers, malformed JSON, a non-object root, or too long. Python's json.loads accepts NaN and Infinity, so it is not enough on its own. - MotionConsole.write_config logs that the console refused the write and kept the stored config when the reply is OW_ERROR. - scripts/check_console_config.py reads the raw stored config (read-only) and fails when it is not strict JSON or has no positive TEC_TRIP. Run it on each console, on its current firmware, before updating it to the strict firmware. Tests: tests/test_motion_config_strict.py (no hardware). Software suite: no new failures. Bench: - strict firmware: the check passes on the stored config, fails (exit 1) on a config without TEC_TRIP, and passes again after restoring it; - next firmware (5c0dc46): a config with EE_GAIN NaN was stored (RESP), and the check reported "non-JSON constant NaN" (exit 1); config restored. Signed-off-by: George Vigelette <george@openwater.cc>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Console firmware with the strict-config check (console-fw fix/jsmn-strict, CFW-12/CFW-15) stores a user config only when it is a strict JSON object that fits its page, and parses the stored config in jsmn strict mode at boot.
Tests: tests/test_motion_config_strict.py (no hardware). Software suite: no new failures.
Bench:
Summary
Licensing layer
license-manifestchange process (and board approval for anything leaving the core). Link the approval.Checklist
git commit -sSPDX-License-Identifierfor their layerCODEOWNERSreview requestedNotes for reviewers