Skip to content

fix(search): show one total on the Simple Search Tagged tab - #17132

Merged
Maffooch merged 2 commits into
DefectDojo:devfrom
skywalke34:fix/simple-search-tagged-counts
Dec 3, 2026
Merged

Maffooch merged 2 commits into
DefectDojo:devfrom
skywalke34:fix/simple-search-tagged-counts

Conversation

@skywalke34

Copy link
Copy Markdown
Contributor

Description

Fixes #17129.

On Simple Search, a tag: query shows a Tagged tab whose title is a bare list of six numbers, for example "Tagged (0, 2, 12, 0, 0, 0)". Nothing says which number counts which type. The table inside also listed the types in a different order from that list, and "Tagged" was not translatable.

  • Tab title: the view now passes tagged_count, the total of the six tagged result lists, so the tab reads "Tagged (14)" like every other result tab. The per-type breakdown is the table's Type column. The lists are already evaluated (and capped at max_results) by the time the total is taken, so this adds no queries.
  • Table order: rows now follow the page's own tab order: findings, products, engagements, tests, endpoints, finding templates. Before, the order was tests, findings, finding templates, products, endpoints, engagements.
  • Translation: "Tagged" is wrapped in {% trans %} and added to every catalog. The translations are machine-produced (one word, aligned with each catalog's existing translation of "Tags") and would benefit from a native speaker's review.

This touches the same template as #17127 but not the same lines; the two branches merge cleanly in either order.

Before After
before after

Test results

  • New unittests/test_simple_search_tagged_tab.py (3 tests). All 3 fail on current dev and pass with this change:
    • The tab title is a single number equal to the total of the tagged results ("Tagged (1, 1, 1, 1, 0, 0)" before).
    • The table rows of a tagged finding, product, engagement and test appear in tab order.
    • Every catalog has a non-fuzzy translation of "Tagged" (the English source keeps an empty msgstr).
  • Existing simple-search suites still pass (test_simple_search_tab_panes, test_simple_search_scoping, test_simple_search_bad_input): 11 tests OK in total.
  • All 28 catalogs compile with msgfmt.
  • Verified live: tag:compliance shows "Tagged (14)" next to "Products (2)" and "Engagements (12)", with 14 rows in the table.
  • ruff check passes.

Documentation

None needed (bug fix).

Checklist

  • Rebased against the latest dev.
  • Submitted against the dev branch.
  • Meaningful PR name.
  • Ruff compliant.
  • Python 3.13 compliant.
  • New feature documentation: n/a, bug fix.
  • Migrations: n/a, no model changes.
  • Unit tests added.
  • Labels and milestone applied.

Generated with Claude Code under the direction of T. Walker (skywalke34) - DefectDojo

The Tagged tab title was a bare positional list, "Tagged (0, 2, 12, 0, 0, 0)",
with nothing saying which number counted which type. The table inside listed
the types in a different order from that list, and "Tagged" was not
translatable.

- The view passes tagged_count, the total of the tagged result lists, and the
  tab reads "Tagged (14)", like every other result tab.
- The table rows follow the page's tab order: findings, products,
  engagements, tests, endpoints, finding templates.
- "Tagged" is wrapped in {% trans %} and translated in every catalog.

Closes DefectDojo#17129

Authored by T. Walker - DefectDojo
@dryrunsecurity

dryrunsecurity Bot commented Dec 1, 2026 •

Copy link
Copy Markdown

DryRun Security

This pull request contains critical findings where the user 'skywalke34' modified sensitive codepaths in dojo/templates/dojo/simple_search.html and dojo/search/views.py without being on the allowed authors list.

🔴 Configured Sensitive Codepath Modified by Non-Allowed Author in dojo/templates/dojo/simple_search.html (drs_088cccbe)
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 e45de83) who is not in the allowed authors list.
🔴 Configured Sensitive Codepath Modified by Non-Allowed Author in dojo/search/views.py (drs_d41110a1)
Vulnerability Configured Sensitive Codepath Modified by Non-Allowed Author
Description File 'dojo/search/views.py' matches configured sensitive codepath pattern 'dojo/search/*.py' and was modified by 'skywalke34' (commit e45de83) 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.

Appending it at the end of every catalog collided with other PRs that also
append there. Same entries, new position.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@Maffooch Maffooch left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review: #17132 fix(search): show one total on the Simple Search Tagged tab

Verdict: approve
Head SHA reviewed: e0d3ade
Base: dev (milestone 3.6.0, correct)
Profile: code change (view + template + 28 .po catalogs + tests)

Summary

The Tagged tab now reads "Tagged (N)", where N is the sum of the six capped result lists. The rows follow the page's tab order, and "Tagged" is translatable. I confirmed live that the total matches the row count, the order is right, the query count is unchanged, and the translation renders.

Attempts

# What I did Expected Got Result
1 Reverted simple_search.html, dojo/search/views.py and dojo/locale to origin/dev, ran unittests.test_simple_search_tagged_tab fail on dev, pass on PR dev: tab and order tests fail plus the catalog test for all 28 languages; PR: 3/3 pass no break
2 Live tag:revtag with 60 findings, 3 products, 1 engagement, 1 test one total equal to the rows PR: "Tagged (65)", 65 rows. Dev: "Tagged (60, 3, 1, 1, 0, 0)" no break
3 Row order in the Tagged table Finding, Asset, Engagement, Test PR: Finding, Asset, Engagement, Test. Dev: Test, Finding, Product, Engagement no break
4 Query count for the same search, PR vs dev files (CaptureQueriesContext) no extra queries from the new sum(len(...)) 91 vs 91 no break
5 tagged_* are None on non-tag searches sum skips None guarded by if tagged (dojo/search/views.py:411-413); non-tag searches return 200 no break
6 msgfmt --check-format on all catalogs (PR alone and all five PRs merged), plus de/fr rendered no duplicate msgid; translated 0 errors; "Getaggt (65)", "Étiquetés (65)" no break
7 Merged with #17127 in both orders clean, Product row keeps the label from #17127 clean, identical trees, correct label on the moved row no break
8 Hostile tag input (markup, 3000 chars) 200, nothing reflected 200, not reflected no break

Nice to have

  • The comment on dojo/search/views.py:410 says each list is "already evaluated". They are sliced querysets. The if tagged in the generator is what evaluates them, and the template then reuses the cached results. The behavior is right (attempt 4), but the comment could say that.
  • "Tagged" translations are machine-produced, as the PR notes.

Verified hands-on

Own compose stack with seeded tagged objects. Server-side renders in en/de/fr. Query counts measured on PR and dev files. New tests on the PR and with the fixed files reverted. Existing simple-search suites pass on the merged tree. ruff clean. CI green.

Static only / not reproduced

The V3_FEATURE_LOCATIONS=True path for tagged_endpoints (dojo/search/views.py:243) was not exercised. It is unchanged by this PR apart from being counted.

@Maffooch
Maffooch added this pull request to the merge queue Dec 3, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Dec 3, 2026
@Maffooch
Maffooch added this pull request to the merge queue Dec 3, 2026
Merged via the queue into DefectDojo:dev with commit 09b8307 Dec 3, 2026
43 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Simple Search "Tagged" tab shows unlabelled counts, e.g. "Tagged (0, 2, 12, 0, 0, 0)"

4 participants