Repository navigation
fix(search): name assets through the label system on Simple Search - #17127
Conversation
The Simple Search page hard-coded "Products" / "Product", so it read "Products (2)" while the rest of the UI says "Assets". - The result tab uses ASSET_PLURAL_LABEL. - The seven "Product" column headers (vulnerability ids, engagements, tests, endpoints, languages, technologies, experimental) and the Tagged table's type cell use ASSET_LABEL. - The Experimental tab's Type column printed the model class name; a Product now shows ASSET_LABEL. Other types keep their class name. No new strings: both labels already exist and are translated. Authored by T. Walker - DefectDojo
|
This pull request contains a critical finding where a sensitive template file was modified by an author not on the allowed list.
🔴 Configured Sensitive Codepath Modified by Non-Allowed Author in
|
| Vulnerability | Configured Sensitive Codepath Modified by Non-Allowed Author |
|---|---|
| Description | File 'dojo/templates/dojo/simple_search.html' matches configured sensitive codepath pattern 'dojo/templates/**/*.html' and was modified by 'skywalke34' (commit 3de5862) who is not in the allowed authors list. |
We've notified @mtesauro.
Comment to provide feedback on these findings.
Report false positive: @dryrunsecurity fp [FINDING ID] [FEEDBACK]
Report low-impact: @dryrunsecurity nit [FINDING ID] [FEEDBACK]
Example: @dryrunsecurity fp drs_90eda195 This code is not user-facing
All finding details can be found in the DryRun Security Dashboard.
Maffooch
left a comment
There was a problem hiding this comment.
Review: #17127 fix(search): name assets through the label system on Simple Search
Verdict: approve-with-nits
Head SHA reviewed: 3de5862
Base: dev (milestone 3.6.0, correct)
Profile: code change (template + tests)
Summary
The template change is correct and complete for the page: every hard-coded Product header, the result tab, the Tagged type cell, and the Experimental Type column now use the labels. The only product text left is the search-operator help text, which is query syntax and should stay. The one problem is in the test: it only passes when the relabel is on.
Attempts
| # | What I did | Expected | Got | Result |
|---|---|---|---|---|
| 1 | Reverted simple_search.html to origin/dev, ran unittests.test_simple_search_asset_labels |
fail on dev, pass on PR | dev: 2/2 fail; PR: 2/2 pass | no break |
| 2 | Same tests with DD_ENABLE_V3_ORGANIZATION_ASSET_RELABEL=False (a supported setting, settings.dist.py:353) |
pass, since the page then correctly says "Product" | both fail: 'Product' unexpectedly found in [...] and Regex matched: '>Products (1)' |
follow-up (test only, see nit 1) |
| 3 | Merged with #17132, which moves the Tagged rows that this PR relabels, in both orders | clean merge; the product row keeps ASSET_LABEL |
both orders merge cleanly and give identical trees. The Product row (now second) carries {{ labels.ASSET_LABEL }}, and the other rows keep their trans strings |
no break |
| 4 | Live tag:revtag search in de/fr with compiled catalogs |
plural label translated | "Assets (3)" (de), "Actifs (3)" (fr) | no break |
| 5 | Hostile queries: tag:<script>alert(1)</script> and a 3000-character tag |
200, no reflected markup | 200 both, markup not reflected | no break |
| 6 | Checked Experimental-tab model types for other raw class names that would now look inconsistent | only Product had a label | watson registers Product, Test, Finding, Finding_Template, Endpoint, Location, Engagement, App_Analysis (dojo/apps.py:83-121). No Product_Type, so nothing else needs relabeling here |
no break |
| 7 | Existing simple-search suites on the merged tree | pass | pass | no break |
Nice to have
- Make the test independent of the relabel flag, as #17121's test does (
if str(self.labels.ASSET_LABEL) != "Product": ...). TodayassertNotRegex(content, r">\s*Products \(\d+\)"),assertNotIn("<th>Product</th>", ...),assertNotIn("<td>Product</td>", ...)andassertNotIn("Product", type_cells)all fail when an install runs withDD_ENABLE_V3_ORGANIZATION_ASSET_RELABEL=False. CI does not set that flag, so this won't block the queue, but anyone running the suite in legacy mode will see two false failures. - The Experimental-tab comparison
result.object|class_name == "Product"works but is stringly typed. Fine as is.
Verified hands-on
Own compose stack with seeded tagged products, engagements, tests and findings. Server-side renders in en/de/fr. New tests on the PR, on the reverted tree, and with relabel off. Merge test with #17132. ruff clean. CI green.
Static only / not reproduced
The Experimental (watson) tab was checked only by the PR's unit test. My seeded objects were not in the watson index because celery wasn't running in my stack.
With DD_ENABLE_V3_ORGANIZATION_ASSET_RELABEL=False the asset label is "Product", so asserting that "Product" is absent failed on a correct page. Only check for the hard-coded strings when the label differs from them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Maffooch
left a comment
There was a problem hiding this comment.
Review (round 2): #17127 fix(search): name assets through the label system on Simple Search
Verdict: approve-with-nits
Head SHA reviewed: e225596
Base: dev (milestone 3.6.0, the earliest open future milestone, correct). The branch is 4 commits behind origin/dev and merges cleanly.
Profile: code change (template + tests)
Summary
The first review's only issue is resolved. The test failed when DD_ENABLE_V3_ORGANIZATION_ASSET_RELABEL=False. Commit e225596 keeps the positive checks (the label is present) and wraps only the "hard-coded Product is gone" checks in if str(self.labels.ASSET_LABEL) != "Product":. The template is unchanged since round 1. Labels are resolved at import time from the setting (dojo/asset/labels.py:108), so I flipped it per process with the env var and confirmed it took effect: off gives Product/Products, on gives Asset/Assets.
Attempts
| # | What I did | Expected | Got | Result |
|---|---|---|---|---|
| 1 | New tests on the PR head, relabel on (default) and with DD_ENABLE_V3_ORGANIZATION_ASSET_RELABEL=True set explicitly |
pass | 2/2 pass both times | no break |
| 2 | New tests on the PR head with DD_ENABLE_V3_ORGANIZATION_ASSET_RELABEL=False (the round-1 failure) |
pass | 2/2 pass | no break (round-1 issue resolved) |
| 3 | simple_search.html reset to origin/dev, relabel on |
fail | 2/2 fail: 'Asset' not found in ['Product', ...] and Regex didn't match: '>\s*Assets \(1\)\s*</a>' |
no break (tests prove the fix) |
| 4 | simple_search.html reset to origin/dev, relabel off |
for the record | 2/2 pass. With the relabel off, dev already renders the right text, so the tests cannot tell dev from the PR in that mode. That is correct behaviour, not a gap: there is nothing to fix there | no break |
| 5 | All simple-search suites (test_search_parser, test_simple_search_asset_labels, _bad_input, _scoping, _tab_panes, test_watson_search_disabled) with relabel on and off |
pass | 14/14 pass in both modes | no break |
| 6 | Live page, relabel on, seeded assets: tag:rctag and a plain name search |
Asset labels in tab, Tagged type cells, Experimental Type column | tag:rctag: tabs "Assets (2)", Tagged type cells "Asset", "Asset". RC Many: tab "Assets (1)", header "Asset", Experimental Type column "Asset", "Finding" x30, "Engagement", "Test". No Products (, <th>Product</th> or <td>Product</td> anywhere in either page |
no break |
| 7 | Hostile queries: tag:<script>alert(1)</script> and a 3000-character string |
200, nothing reflected | 200 both, markup not reflected | no break |
| 8 | Grepped the template for any other hard-coded Product text | only operator syntax left | only the help popover (simple_search.html:10-13, inside blocktrans), which says "products whose name, tags or description" and lists the product: / product-tags operators |
nit 1 |
Blocking
None.
Nice to have
- The help popover at
dojo/templates/dojo/simple_search.html:11still says "products whose name, tags or description contain the search query". Theproduct:andproduct-tagsoperator names must stay, since they are query syntax. The prose word could use the label, but it sits inside ablocktransand changing it means a new msgid. Fine to leave for a follow-up. - The Experimental-tab check
result.object|class_name == "Product"is string-typed. Fine as is (carried over from round 1).
Verified hands-on
Own compose stack (project reviewc2, ports 38080/38443) on origin/dev merged with both PR heads. Ran the new tests with the relabel on and off, on the PR template and the origin/dev template. Drove /simple_search in Chromium (Playwright) with relabel on, against assets, an engagement, tests and 31 findings seeded through the API. Celery was running, so the Experimental (watson) tab was populated this time. ruff 0.16.10 clean. Migration leaves single. makemigrations --check: no changes. PR CI was still building images and linting the chart when I checked, with no failures so far.
Static only / not reproduced
The live page with the relabel off (the uwsgi process would need a restart with the env var). The unit tests cover that mode. Translations were checked in round 1 and the template has not changed since.
Description
The Simple Search page (
/simple_search) hard-codes "Products" / "Product", so a search shows "Products (2)" while the sidebar and every other page say Assets. This moves the page onto the label system, the same way #17110 and #17121 do for other pages:{% trans "Products" %}now usesASSET_PLURAL_LABEL.{% trans "Product" %}headers (Vulnerability Ids, Engagements, Tests, Endpoints, Languages, Technologies, Experimental) now useASSET_LABEL.ASSET_LABEL.{{ result.object|class_name }}), so products showed as "Product". A product now showsASSET_LABEL. Other types (Finding, Engagement, Test, ...) keep their class name as before.No new strings. Both labels already exist and are translated in both naming modes.
The
product:/product-tagsearch operators in the page's help popover are query syntax and are left alone.tag:searchTest results
unittests/test_simple_search_asset_labels.py(2 tests). Both fail on currentdevand pass with this change:tag:search renders the plural label on the result tab,ASSET_LABELin the column header and the Tagged type cell, and no hard-coded "Products (n)" / "Product".ASSET_LABELin the Experimental tab's Type column for a product, while findings still show "Finding".test_simple_search_tab_panes,test_simple_search_scoping,test_simple_search_bad_input): 10 tests OK in total.ruff checkpasses.Documentation
None needed (bug fix).
Checklist
dev.devbranch.Generated with Claude Code under the direction of T. Walker (skywalke34) - DefectDojo