Repository navigation
Support inverted tag matching in policy scope - #7176
Merged
nscuro merged 1 commit intoAug 31, 2026
Merged
Conversation
Policies can be restricted to projects carrying specific tags, but there is no way to express the opposite, applying a policy to everything except projects with a given tag. Doing that today means tagging every project the policy should apply to, and keeping that up to date as projects are added. Add an INVERT_TAG_MATCH flag to POLICY. When set, the policy applies to every project that does not share a tag with it. The existing tag branch of the applicability query is left to non-inverted policies, and inverted policies are selected by a separate branch, so an inverted policy without tags stays out of scope rather than silently applying everywhere. Fixes DependencyTrack#5042 Signed-off-by: Arjav <arjavdongaonkar@gmail.com>
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
Up to standards ✅🟢 Issues
|
| Category | Results |
|---|---|
| Performance | 1 medium |
🟢 Coverage 100.00% diff coverage · -0.01% coverage variation
Metric Results Coverage variation ✅ -0.01% coverage variation (-1.00%) Diff coverage ✅ 100.00% diff coverage (70.00%) Coverage variation details
Coverable lines Covered lines Coverage Common ancestor commit (33923d9) 44404 38791 87.36% Head commit (df611d1) 44409 (+5) 38793 (+2) 87.35% (-0.01%) Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch:
<coverage of head commit> - <coverage of common ancestor commit>Diff coverage details
Coverable lines Covered lines Diff coverage Pull request (#7176) 5 5 100.00% Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified:
<covered lines added or modified>/<coverable lines added or modified> * 100%
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
nscuro
approved these changes
Aug 31, 2026
This was referenced Aug 31, 2026
nscuro
pushed a commit
to DependencyTrack/frontend
that referenced
this pull request
Sep 2, 2026
* Add tag exclusion toggle to policy scope DependencyTrack/dependency-track#7176 added invertTagMatch, which applies a policy to every project that does not carry its tags. Expose it as a switch next to the existing scope switches, and swap the tag list label so it is clear whether the tags include or exclude. Frontend side of DependencyTrack/dependency-track#5042. Signed-off-by: Arjav <arjavdongaonkar@gmail.com> * Add tag exclusion translations for remaining locales The i18n check requires every locale to carry the keys. ko, ru, uk-UA, zh-TW and zh were added after the translations this change reused were written. Signed-off-by: Arjav <arjavdongaonkar@gmail.com> * Trigger a policy update when the tag exclusion toggle changes The other scope toggles each have a watcher calling updatePolicy, this one did not, so flipping it changed nothing until some other field happened to trigger a save. Signed-off-by: Arjav <arjavdongaonkar@gmail.com> --------- Signed-off-by: Arjav <arjavdongaonkar@gmail.com>
nissessenap
pushed a commit
to nissessenap/dt-frontend
that referenced
this pull request
Oct 5, 2026
* Add tag exclusion toggle to policy scope DependencyTrack/dependency-track#7176 added invertTagMatch, which applies a policy to every project that does not carry its tags. Expose it as a switch next to the existing scope switches, and swap the tag list label so it is clear whether the tags include or exclude. Frontend side of DependencyTrack/dependency-track#5042. Signed-off-by: Arjav <arjavdongaonkar@gmail.com> * Add tag exclusion translations for remaining locales The i18n check requires every locale to carry the keys. ko, ru, uk-UA, zh-TW and zh were added after the translations this change reused were written. Signed-off-by: Arjav <arjavdongaonkar@gmail.com> * Trigger a policy update when the tag exclusion toggle changes The other scope toggles each have a watcher calling updatePolicy, this one did not, so flipping it changed nothing until some other field happened to trigger a save. Signed-off-by: Arjav <arjavdongaonkar@gmail.com> --------- Signed-off-by: Arjav <arjavdongaonkar@gmail.com>
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.
Description
Policies can be limited to projects carrying specific tags, but there is no way to express the opposite, applying a policy to everything except projects with a given tag. Doing that today means tagging every project the policy should apply to and keeping that up to date as projects get added.
This adds an INVERT_TAG_MATCH flag on POLICY. When set, the policy applies to every project that does not share a tag with it.
Addressed Issue
Fixes #5042
Additional Details
The applicability query already selects policies through three branches, global policies with no restrictions, project restricted ones, and ones sharing a tag with the project. The existing tag branch now only picks up non-inverted policies, and inverted ones are selected by a separate branch.
Keeping them separate matters for one case. An inverted policy with no tags at all would otherwise match every project, which is not what someone setting up an exclusion would expect, so the inverted branch requires the policy to actually have tags.
This replaces #5041, which was raised against master before the v5 restructure. The frontend side is #1275 on the frontend repo, also against master, I will re-raise that against main once this is agreed.
Checklist
The documentation box is unchecked, the policy docs live in the docs repo. Will raise a PR there once this is agreed.