fix(tags): keep user-set tags when creating a finding under product tag inheritance#15097
Merged
rossops merged 1 commit intoJun 29, 2026
Conversation
…ag inheritance
When a product has tag inheritance enabled, creating a finding with its own
tags via the UI ('add finding' flow: finding.tags = [...]; finding.save())
silently dropped the user's tags — only the inherited product tags survived.
Editing the finding afterwards worked, confirming the loss was on create.
Root cause is signal-handler ordering. tagulous holds tags assigned to an
unsaved instance in an in-memory manager and only writes them from its own
post_save handler, registered in tagulous' AppConfig.ready(). Because 'dojo'
precedes 'tagulous' in INSTALLED_APPS, dojo's inheritance post_save handler
runs first; reading instance.tags on the freshly-saved row loads an empty,
DB-backed manager and discards the pending pre-save tags before tagulous can
persist them.
Fix: before computing/merging inherited tags, flush the instance's own
tag fields (tagulous manager.post_save_handler()) so the user's tags are
committed first. This makes inheritance independent of signal-handler
ordering. Findings created without own tags still inherit correctly.
Fixes DefectDojo#15092
Maffooch
approved these changes
Jun 29, 2026
Jino-T
approved these changes
Jun 29, 2026
paulOsinski
approved these changes
Jun 29, 2026
rossops
approved these changes
Jun 29, 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.
Fixes #15092
Problem
When a product has tag inheritance enabled, creating a finding with its own tag via the UI ("add finding" flow) silently drops the user's tag — only the inherited product tags survive. Editing the finding afterwards and adding a tag works, which is what made the loss look specific to creation.
Reproduced exactly:
finding.tags = [...]; finding.save())['producttag']— user tag gone['myrandomtag', 'producttag']Root cause — signal-handler ordering
The
post_savedispatch order forFindingis:dojo.tags.signals.inherit_tags_on_instance→ 4. tagulous's flush (PostSaveHandler)Tagulous holds tags assigned to an unsaved instance in an in-memory manager and only writes them to the through table from its own
post_savehandler, which is registered in tagulous'AppConfig.ready(). Because"dojo"precedes"tagulous"inINSTALLED_APPS, dojo's inheritance handler runs first: readinginstance.tagson the freshly-saved row loads an empty, DB-backed manager and discards the pending pre-save tags before tagulous can persist them.Fix
Before computing/merging inherited tags, flush the instance's own tag fields (tagulous
manager.post_save_handler()) so the user's tags are committed first. This makes inheritance independent of signal-handler ordering — findings created with or without their own tags now end up correct.dojo/tags/signals.py— new_flush_pending_tag_fields()helper, called at the top ofauto_inherit_product_tags().unittests/test_tag_inheritance.py— two regression tests (create-with-own-tag, create-without-tag). The first fails without the fix and passes with it.Testing
test_tag_inheritance(39),test_tags(26),test_tag_inheritance_perf(24) — all green.