Repository navigation
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
elhoim
force-pushed
the
fix/t33-unboundlocalerror-on-any-non-64-char-has
branch
from
October 1, 2026 07:07
e33e8e8 to
460bcef
Compare
query_hashlookup incremented error_hash_counter, a local that was never assigned and never read, so the first event whose hash field was not 64 characters (e.g. an MD5 in `hash`) raised UnboundLocalError and aborted the whole analyzer. Drop the dead counter so such events are skipped.
elhoim
force-pushed
the
fix/t33-unboundlocalerror-on-any-non-64-char-has
branch
from
October 9, 2026 20:04
460bcef to
099a665
Compare
This branch has not been deployed
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.
BLUF
query_hashlookupincrementserror_hash_counter, a local that is never assigned. The first event whose hash field is not exactly 64 characters (for example an MD5 inhash) raisesUnboundLocalError, and the whole Hashlookup analysis ends in ERROR.continuenow skips the event as intended.TestHashlookup.test_hash_wrong_length_is_skippedmasterwithUnboundLocalErrorand passes with the fix. The module runs 3 passed, 2 skipped (both skips are pre-existing).black --checkandpylint --rcfile=.pylintrcare clean on both changed files.query_hashlookupincrementserror_hash_counter, a local that is never assigned. The first event whose hash field is not exactly 64 characters (for example an MD5 inhash) raisesUnboundLocalError, and the whole Hashlookup analysis ends in ERROR.continuenow skips the event as intended.Details
Root cause. The wrong-length branch of
timesketch/lib/analyzers/contrib/hashlookup_analyzer.pyrunserror_hash_counter += 1, buterror_hash_counteris never assigned anywhere in the module. The analyzer query_exists_:hash OR ...also matches the generichashfield, and that field often holds an MD5 or SHA1. For any such event:len(hash_value) != 64→ warning is logged →UnboundLocalError→run_wrappermarks the analysis as ERROR, and any events after it are never looked up.How to reproduce. Use a timeline with one event where
hashisd41d8cd98f00b204e9800998ecf8427e(an MD5), followed by an event with a valid 64-hexsha256_hash. Before the fix, the analyzer crashes on the first event. After the fix, it skips that event with the existing warning, queries Hashlookup once for the SHA256, and returnsHashlookup Matches: 1. The regression test covers exactly this case.Fix. The change is one line: the dead increment is removed. Behaviour does not change for valid SHA256 values.
Possible follow-ups (left out of this PR to keep it narrow):
isinstance(hash_value, str)guard. A null or non-string field would raiseTypeErroratlen(). This is unlikely, because_exists_does not match nulls.[0-9a-fA-F]{64}check before the value is placed into{hashlookup_url}sha256/{hash_value}, as hardening against path-segment injection. This would change behaviour, because 64-character non-hex values would no longer be sent.I can add either one if you want it.
Checks
Closing issues
No issue is linked to this PR yet.