Skip to content

snapshot() Method Returns Shallow Copies #138

Description

@CyberSecDef

Problem

novelforge/progress.py lines 184-190: snapshot() returns shallow copies while get() returns deep copies. Nested structures in returned entries are shared references to the internal store.

Why It Matters

Code using snapshot() could inadvertently mutate the internal store by modifying nested data, contradicting the safety guarantee established by get().

Recommended Fix

def snapshot(self) -> dict[str, ProgressState]:
    with self._lock:
        return {k: copy.deepcopy(v) for k, v in self._store.items()}

Activity

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

Metadata

Metadata

Labels

bugSomething isn't workingpriority:mediumMedium priority

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions