Skip to content

Refactor vulns and vuln events tables#1804

Merged
timbastin merged 32 commits into
mainfrom
refactor-vuln-events-table
Apr 7, 2026
Merged

Refactor vulns and vuln events tables#1804
timbastin merged 32 commits into
mainfrom
refactor-vuln-events-table

Conversation

@Hubtrick-Git

@Hubtrick-Git Hubtrick-Git commented Mar 23, 2026

Copy link
Copy Markdown
Collaborator

Vulnerability table changes

  • Migrate the id columns of the 3 vuln tables dependency_vulns, first_party_vulnerabilities and license_risk.
  • Previously the id was a 256 bit hash stored as a text -> Now its only a 128 bit hash stored as a uuid
  • This leads to 1/4 of the disk space required and performance improvements regarding internal processing of UUIDs in comparison to text

VulnEvent table changes

  • Drop updated_at column to reduce space
  • Use 3 foreign key columns, 1 for each vuln instead of the current single column

Now we need to refactor the existing code regarding the affected columns

Frontend

Database

  • rebuild indexes

Queries

  • Change all queries using vuln_events
  • Change all queries using vuln_ids

Go Code

  • Change vuln event model and refactor affected code
  • Change the vulnerability model and refactor affected code

Copilot AI review requested due to automatic review settings March 23, 2026 13:30

This comment was marked as resolved.

@Hubtrick-Git

Copy link
Copy Markdown
Collaborator Author

Closed co pilot suggestions since this is still a work in porgress but was missing such classification.

@Hubtrick-Git
Hubtrick-Git marked this pull request as draft March 26, 2026 16:25

Copilot AI 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.

Pull request overview

Copilot reviewed 69 out of 71 changed files in this pull request and generated 8 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread database/repositories/vulnevent_repository.go
Comment thread database/repositories/vulnevent_repository.go
Comment thread database/repositories/vulnevent_repository.go
Comment thread database/models/vulnevent_model.go
Comment thread tests/scan_integration_test.go
Comment thread tests/scan_integration_test.go
Comment thread tests/scan_integration_test.go
Comment thread tests/scan_integration_test.go
@Hubtrick-Git
Hubtrick-Git marked this pull request as ready for review April 2, 2026 14:31

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

How about we put this in the regular readme?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I think it is a very specific command only useful for developers. Having it in the migrations folder directly helps those who are confused on how to create migrations and directly helps them in this case.

Comment thread database/migrations/20260323134661_refactor_vuln_ids.up.sql Outdated
Comment thread database/models/vulnevent_model.go
Comment thread database/repositories/artifact_repository.go Outdated
Comment thread database/repositories/gorm_repository.go
@timbastin
timbastin merged commit 21ec60b into main Apr 7, 2026
44 checks passed
@timbastin
timbastin deleted the refactor-vuln-events-table branch April 7, 2026 16:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants