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:
@@ -207,6 +207,23 @@ class TestSaveFailureRollback:
|
||||
# Disk still has the entry too — memory and disk stay in sync.
|
||||
assert len(json.loads(path.read_text())) == 1
|
||||
|
||||
def test_failed_write_leaves_existing_file_intact(self, tmp_path, monkeypatch):
|
||||
# The save is atomic (temp file + os.replace): a write that dies
|
||||
# mid-serialization must neither truncate the existing file nor
|
||||
# leave a stray .tmp behind.
|
||||
path = tmp_path / "repos.json"
|
||||
manager = make_manager(path)
|
||||
manager.add("https://github.com/user/repo") # real save
|
||||
before = path.read_text()
|
||||
|
||||
def boom(*args, **kwargs):
|
||||
raise OSError("disk full")
|
||||
monkeypatch.setattr(json, "dump", boom)
|
||||
assert manager.add("https://github.com/user/other") is False
|
||||
|
||||
assert path.read_text() == before
|
||||
assert list(tmp_path.glob("*.tmp")) == []
|
||||
|
||||
|
||||
class TestGetAllCopy:
|
||||
def test_get_all_is_shallow_copy(self, tmp_path):
|
||||
|
||||
Reference in New Issue
Block a user