Fix SARIF parser: unwrap BlackDuck nested fingerprint dict values#15080
Open
Jino-T wants to merge 2 commits into
Open
Fix SARIF parser: unwrap BlackDuck nested fingerprint dict values#15080Jino-T wants to merge 2 commits into
Jino-T wants to merge 2 commits into
Conversation
BlackDuck SARIF output uses {"value": "<hash>"} objects as fingerprint
values instead of plain strings as the SARIF 2.1.0 spec requires.
get_fingerprints_hashes() was storing these dicts directly into
unique_id_from_tool. Django's CharField silently coerces them to their
str() repr on save, but they arrive as actual dict objects in memory.
On second reimport the reimporter calls update_candidates_with_saved_finding()
which uses unique_id_from_tool as a Python dict key:
candidates_by_uid.setdefault(finding.unique_id_from_tool, [])
Dicts are not hashable, so this raises:
TypeError: cannot use 'dict' as a set element (unhashable type: 'dict')
This crash happens for ALL reimport deduplication algorithms because
update_candidates_with_saved_finding() runs unconditionally after each
finding is saved. Changing the deduplication algorithm is not a workaround.
Fix: unwrap the nested dict at parse time. If the value is a dict, extract
its "value" key (empty string fallback if missing). This produces the
correct plain-string unique_id_from_tool the rest of the pipeline expects.
Adds two unit test cases to test_get_fingerprints_hashes and a new
integration test test_blackduck_nested_fingerprints with a sanitized
5-finding SARIF fixture covering all severity levels.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
valentijnscholten
approved these changes
Jun 24, 2026
Maffooch
approved these changes
Jun 24, 2026
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.
Summary
{"value": "<hash>"}objects instead of the plain strings the SARIF 2.1.0 spec requiresget_fingerprints_hashes()stored these dicts directly intounique_id_from_tool, which Django's CharField silently coerced tostr(dict)on save — but the objects arrive as actual dicts in memoryupdate_candidates_with_saved_finding()usesunique_id_from_toolas a Python dict key (candidates_by_uid.setdefault(finding.unique_id_from_tool, [])) — dicts are not hashable, raisingTypeError: cannot use 'dict' as a set element (unhashable type: 'dict')Fix
Unwrap the nested dict at parse time in
get_fingerprints_hashes():Test plan
manage.py test unittests.tools.test_sarif_parser— all 25 tests passtest_get_fingerprints_hashescovering nested dict withvaluekey and nested dict with missingvaluekey (empty-string fallback)test_blackduck_nested_fingerprintsintegration test with a sanitized 5-finding SARIF fixture covering Medium/High/Info/Critical severity levels — verifiesunique_id_from_toolis a plain string and not a dict representationNote on existing findings in affected customer databases
Findings created before this fix will have
unique_id_from_toolstored as"{'value': 'abc123...'}"(thestr()repr of the dict). After deploying the fix, new reimports will produce the correct hash string — these will not match the old str-repr values, causing the old findings to be closed and new ones opened on the next reimport. Customers should be warned if they care about finding continuity.🤖 Generated with Claude Code