fix: [website/history] use identity check for session node index - #875
Open
elhoim wants to merge 1 commit into
Open
fix: [website/history] use identity check for session node index#875elhoim wants to merge 1 commit into
elhoim wants to merge 1 commit into
Conversation
remove_node_session locates a matching node's index in the session key
list and stores it in loc, then guards the delete with `if loc:`. When
the match is the very first key, loc is 0, which is falsy in Python, so
the truthiness check skips the deletion entirely while the calling route
still reports success ("Node deleted"). The node silently remains in the
session-stored history tree.
Verified with the full misp-modules test suite against a live modules
server on port 6767: 161 passed, 4 skipped, 5 subtests passed, matching
the documented baseline.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018dfYpyaSZd1nxSRLr8suj8
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.
The session history "remove node" flow silently no-ops when the matched node is the very first entry in the session's ordered key list:
locholds the index of the matched node, and index0is falsy in Python, soif loc:skips the delete precisely when the match is at position 0 — even thoughlocwas correctly set (as opposed to itsNoneinitial value meaning "no match").Impact on an analyst: deleting the first node/session shown in the MISP-modules history tree appears to succeed (the UI reports "Node deleted") but the entry is never actually removed from the underlying session dict, leaving stale/duplicate history state.
Fix: check identity against the sentinel instead of truthiness —
if loc is not None:— so index0is correctly treated as a valid match whileNone("no match found") still skips the delete.This is a pure bug fix with no behaviour change for any non-zero match.
Verification
python -m py_compile website/app/history/history_core.py— clean.website/has no automated test coverage in this repository; verification was py_compile plus running the module test suite, which still passes: 161 passed, 4 skipped, 5 subtests passed in 35.18s.Found during a review of the repository; other findings are being submitted as separate PRs.
🤖 Generated with Claude Code
https://claude.ai/code/session_018dfYpyaSZd1nxSRLr8suj8