Skip to content

Commit 65c5f36

Browse files
stevewalloneclaude
andauthored
fix: relabel finding Asset-tag (AND) filter to v3 Asset vocabulary (#15136)
The v3 Product->Asset relabel (#13155) centralises filter copy in dojo/asset/labels.py, gated by ENABLE_V3_ORGANIZATION_ASSET_RELABEL (default on). The Asset-level AND tag filter on the finding list (test__engagement__product__tags_and) was left with a hardcoded "Product Tags (AND)" label and help text, so it kept the legacy wording even with the relabel enabled -- inconsistent with its siblings "Test Tags (AND)" / "Engagement Tags (AND)" and with the OR variant, whose label is already set dynamically to "Tags (Asset)". Wire it to the edition-aware labels by adding ASSET_FILTERS_TAGS_ASSET_AND_LABEL and ASSET_FILTERS_TAGS_ASSET_AND_HELP to both vocabulary branches, so the field reads "Asset Tags (AND)" in v3 and remains "Product Tags (AND)" in the legacy edition. Adds a regression test asserting the rendered FindingFilter form field. Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 6a2018a commit 65c5f36

3 files changed

Lines changed: 46 additions & 2 deletions

File tree

dojo/asset/labels.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ class AssetLabelsKeys:
6868
ASSET_FILTERS_CSV_TAGS_NOT_HELP = "asset.filters.csv_tags_not_help"
6969
ASSET_FILTERS_CSV_LIFECYCLES_LABEL = "asset.filters.csv_lifecycles_label"
7070
ASSET_FILTERS_TAGS_ASSET_LABEL = "asset.filters.tags_asset_label"
71+
ASSET_FILTERS_TAGS_ASSET_AND_LABEL = "asset.filters.tags_asset_and_label"
72+
ASSET_FILTERS_TAGS_ASSET_AND_HELP = "asset.filters.tags_asset_and_help"
7173
ASSET_FILTERS_TAG_ASSET_LABEL = "asset.filters.tag_asset_label"
7274
ASSET_FILTERS_TAG_ASSET_HELP = "asset.filters.tag_asset_help"
7375
ASSET_FILTERS_NOT_TAGS_ASSET_LABEL = "asset.filters.not_tags_asset_label"
@@ -175,6 +177,8 @@ class AssetLabelsKeys:
175177
AssetLabelsKeys.ASSET_FILTERS_CSV_TAGS_NOT_HELP: _("Comma separated list of exact tags not present on Asset"),
176178
AssetLabelsKeys.ASSET_FILTERS_CSV_LIFECYCLES_LABEL: _("Comma separated list of exact Asset lifecycles"),
177179
AssetLabelsKeys.ASSET_FILTERS_TAGS_ASSET_LABEL: _("Asset Tags"),
180+
AssetLabelsKeys.ASSET_FILTERS_TAGS_ASSET_AND_LABEL: _("Asset Tags (AND)"),
181+
AssetLabelsKeys.ASSET_FILTERS_TAGS_ASSET_AND_HELP: _("Filter Findings by the selected Asset tags (AND logic)"),
178182
AssetLabelsKeys.ASSET_FILTERS_TAG_ASSET_LABEL: _("Asset Tag"),
179183
AssetLabelsKeys.ASSET_FILTERS_TAG_ASSET_HELP: _("Search for tags on an Asset that are an exact match"),
180184
AssetLabelsKeys.ASSET_FILTERS_NOT_TAGS_ASSET_LABEL: _("Not Asset Tags"),
@@ -281,6 +285,8 @@ class AssetLabelsKeys:
281285
AssetLabelsKeys.ASSET_FILTERS_CSV_TAGS_NOT_HELP: _("Comma separated list of exact tags not present on Product"),
282286
AssetLabelsKeys.ASSET_FILTERS_CSV_LIFECYCLES_LABEL: _("Comma separated list of exact Product lifecycles"),
283287
AssetLabelsKeys.ASSET_FILTERS_TAGS_ASSET_LABEL: _("Product Tags"),
288+
AssetLabelsKeys.ASSET_FILTERS_TAGS_ASSET_AND_LABEL: _("Product Tags (AND)"),
289+
AssetLabelsKeys.ASSET_FILTERS_TAGS_ASSET_AND_HELP: _("Filter Findings by the selected Product tags (AND logic)"),
284290
AssetLabelsKeys.ASSET_FILTERS_TAG_ASSET_LABEL: _("Product Tag"),
285291
AssetLabelsKeys.ASSET_FILTERS_TAG_ASSET_HELP: _("Search for tags on an Product that are an exact match"),
286292
AssetLabelsKeys.ASSET_FILTERS_NOT_TAGS_ASSET_LABEL: _("Not Product Tags"),

dojo/filters.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -616,8 +616,8 @@ class FindingTagFilter(DojoFilter):
616616
field_name="test__engagement__product__tags__name",
617617
to_field_name="name",
618618
queryset=Product.tags.tag_model.objects.all().order_by("name"),
619-
help_text="Filter Findings by the selected Product tags (AND logic)",
620-
label="Product Tags (AND)",
619+
help_text=labels.ASSET_FILTERS_TAGS_ASSET_AND_HELP,
620+
label=labels.ASSET_FILTERS_TAGS_ASSET_AND_LABEL,
621621
conjoined=True,
622622
)
623623

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
from dojo.filters import FindingFilter
2+
from dojo.models import Finding
3+
from unittests.dojo_test_case import DojoTestCase
4+
5+
6+
class FindingTagFilterAssetLabelTest(DojoTestCase):
7+
8+
"""
9+
Regression test for the v3 Product->Asset relabel of the Asset-level AND tag
10+
filter on the finding list.
11+
12+
The relabel (#13155, gated by ENABLE_V3_ORGANIZATION_ASSET_RELABEL, default on)
13+
moves filter copy into dojo/asset/labels.py. The OR variant
14+
(test__engagement__product__tags) gets its label set dynamically at render time
15+
by get_tags_label_from_model() -> "Tags (Asset)", so it was always fine. But the
16+
AND variant (test__engagement__product__tags_and) is static and was left
17+
hardcoded "Product Tags (AND)", so it rendered the legacy wording even with the
18+
relabel enabled - inconsistent with its siblings "Test Tags (AND)" /
19+
"Engagement Tags (AND)".
20+
21+
These assert the RENDERED FindingFilter form field (not the static declared
22+
label, which the dynamic setter can override) carries the Asset vocabulary,
23+
which is the default in the test environment.
24+
"""
25+
26+
def _and_field(self):
27+
# Unscoped finding filter keeps every tag field (the scoped views delete the
28+
# OR field; the AND field is always present).
29+
return FindingFilter(queryset=Finding.objects.none()).form.fields["test__engagement__product__tags_and"]
30+
31+
def test_asset_and_tag_filter_label_uses_asset_vocabulary(self):
32+
self.assertEqual(str(self._and_field().label), "Asset Tags (AND)")
33+
34+
def test_asset_and_tag_filter_help_uses_asset_vocabulary(self):
35+
self.assertEqual(
36+
str(self._and_field().help_text),
37+
"Filter Findings by the selected Asset tags (AND logic)",
38+
)

0 commit comments

Comments
 (0)