mirror of
https://github.com/ChuckBuilds/LEDMatrix.git
synced 2026-08-08 12:18:06 +00:00
fix: address CodeQL alert and review findings
- config_manager: the "secrets list longer than config list" warning now
interpolates only config-side data (no key name or secrets-derived
values), resolving the CodeQL clear-text-logging alert.
- base_plugin: validate_config rejects bool display_duration, matching
get_display_duration (bool is an int subclass and would otherwise pass
as a positive number).
- config_helper: merge_configs deep-copies override values in the
non-recursive branch so mutating the merged result cannot reach back
into override_config.
- saved_repositories: saves are atomic (temp file + fsync + os.replace),
so a failed write can no longer truncate saved_repositories.json.
- tests: regression cases for each fix, plus a pin that whole-item
array secrets (key[] + key[].field both marked) strip to empty {}
skeletons — no secret values can reach config.json.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NohXi78cwsAKtN1sCfxjUh
This commit is contained in:
@@ -122,3 +122,25 @@ class TestConfigFallback:
|
||||
def test_config_bool_uses_default(self):
|
||||
assert make_plugin({"display_duration": True}).get_display_duration() == 15.0
|
||||
assert make_plugin({"display_duration": False}).get_display_duration() == 15.0
|
||||
|
||||
|
||||
class TestValidateConfigDuration:
|
||||
# validate_config must agree with get_display_duration about what a
|
||||
# valid duration is — a config it accepts must not then be rejected
|
||||
# (or silently defaulted) when the duration is actually read.
|
||||
|
||||
def test_positive_number_valid(self):
|
||||
assert make_plugin({"display_duration": 20}).validate_config() is True
|
||||
|
||||
def test_zero_and_negative_invalid(self):
|
||||
assert make_plugin({"display_duration": 0}).validate_config() is False
|
||||
assert make_plugin({"display_duration": -5}).validate_config() is False
|
||||
|
||||
def test_bool_invalid(self):
|
||||
# bool is an int subclass; True would otherwise pass as "positive
|
||||
# number" here while get_display_duration rejects it.
|
||||
assert make_plugin({"display_duration": True}).validate_config() is False
|
||||
assert make_plugin({"display_duration": False}).validate_config() is False
|
||||
|
||||
def test_missing_duration_valid(self):
|
||||
assert make_plugin({}).validate_config() is True
|
||||
|
||||
Reference in New Issue
Block a user