Skip to content

Add case-insensitive expression index on Vulnerability_Id.vulnerability_id - #15218

Merged
Maffooch merged 1 commit into
DefectDojo:bugfixfrom
devGregA:feature/threat-intel-vulnid
Jul 24, 2026
Merged

Add case-insensitive expression index on Vulnerability_Id.vulnerability_id#15218
Maffooch merged 1 commit into
DefectDojo:bugfixfrom
devGregA:feature/threat-intel-vulnid

Conversation

@devGregA

@devGregA devGregA commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Add a case-insensitive expression index on Vulnerability_Id.vulnerability_id

Adds an index on UPPER(vulnerability_id), finding_id to dojo_vulnerability_id.

Why

Vulnerability-id → finding lookups (CVE-keyed enrichment, exploit/threat-intel matching, dedupe helpers) currently sequentially scan dojo_vulnerability_id — the string column has no index today, and scanner-supplied ids aren't case-normalized, so any correct lookup must fold with UPPER(). This adds the matching functional index; including finding_id makes the changed-CVE → finding fan-out an index-only scan.

What

  • Vulnerability_Id.Meta.indexes gains Index(Upper("vulnerability_id"), "finding", name="dojo_vulnid_upper_idx").
  • Migration 0280 builds it CREATE INDEX CONCURRENTLY IF NOT EXISTS (non-atomic) so it doesn't lock the table on large instances, with SeparateDatabaseAndState keeping Django's model state in sync. IF NOT EXISTS makes it idempotent and safe to co-exist with any downstream migration that created the same-named index first.

Notes

  • ~250–350 MB on a 5M-finding instance; concurrent build, no lock.
  • Verify build time on a large clone before release.

🤖 Generated with Claude Code

@github-actions github-actions Bot added New Migration Adding a new migration file. Take care when merging. conflicts-detected labels Jul 10, 2026
@github-actions

Copy link
Copy Markdown
Contributor

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@devGregA
devGregA marked this pull request as ready for review July 23, 2026 03:06
@dryrunsecurity

dryrunsecurity Bot commented Jul 23, 2026

Copy link
Copy Markdown

DryRun Security

This pull request contains critical security findings because two sensitive files were modified by an author not on the allowed list. Specifically, the changes to dojo/db_migrations/0280_vulnerability_id_upper_index.py and dojo/finding/models.py violate configured codepath policies.

🔴 Configured Sensitive Codepath Modified by Non-Allowed Author in dojo/db_migrations/0280_vulnerability_id_upper_index.py (drs_90a1da57)
Vulnerability Configured Sensitive Codepath Modified by Non-Allowed Author
Description File 'dojo/db_migrations/0280_vulnerability_id_upper_index.py' matches configured sensitive codepath pattern 'dojo/db_migrations/*.py' and was modified by '' (commit 05536c9) who is not in the allowed authors list.
🔴 Configured Sensitive Codepath Modified by Non-Allowed Author in dojo/finding/models.py (drs_0fa1e9a9)
Vulnerability Configured Sensitive Codepath Modified by Non-Allowed Author
Description File 'dojo/finding/models.py' matches configured sensitive codepath pattern 'dojo/finding/*.py' and was modified by '' (commit 05536c9) 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.

@devGregA
devGregA force-pushed the feature/threat-intel-vulnid branch from ebb9334 to fedb331 Compare July 23, 2026 03:39
@github-actions

Copy link
Copy Markdown
Contributor

Conflicts have been resolved. A maintainer will review the pull request shortly.

@devGregA
devGregA force-pushed the feature/threat-intel-vulnid branch from fedb331 to 9bd75b6 Compare July 23, 2026 04:03
@devGregA
devGregA changed the base branch from master to bugfix July 23, 2026 04:03
@github-actions

Copy link
Copy Markdown
Contributor

This pull request has conflicts, please resolve those before we can evaluate the pull request.

…ty_id

Index UPPER(vulnerability_id), finding_id on dojo_vulnerability_id so CVE-keyed
lookups (enrichment, exploit/threat-intel matching, dedupe helpers) stop
sequentially scanning the table; scanner-supplied ids are not case-normalized, so
the index and any query both fold with UPPER(). finding_id is included so
changed-CVE -> finding fan-out is an index-only scan. Built CONCURRENTLY IF NOT
EXISTS (non-atomic migration) via SeparateDatabaseAndState so it does not lock the
table on large instances and is idempotent.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@devGregA
devGregA force-pushed the feature/threat-intel-vulnid branch from 9bd75b6 to 05536c9 Compare July 23, 2026 04:10
@github-actions

Copy link
Copy Markdown
Contributor

Conflicts have been resolved. A maintainer will review the pull request shortly.

@devGregA devGregA added this to the 3.1.300 milestone Jul 23, 2026
@Maffooch
Maffooch merged commit 542bc88 into DefectDojo:bugfix Jul 24, 2026
148 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

New Migration Adding a new migration file. Take care when merging.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants