Associate security_scans with vulnerability_scanners

What does this MR do?

Implements the first 3 steps of the implementation plan from #371642:

  1. Adds a new scanner_id column to the security_scans table
  2. Adjusts the Security::StoreScanService to set this column when creating security scans
  3. Adds comprehensive test coverage for the implementation

This change establishes the relationship between security_scans and vulnerability_scanners, which will support the metric gathering described in !212779.

Database changes

  • Adds scanner_id bigint column to security_scans table
  • Adds index on scanner_id column
  • Foreign key will be added after background migration backfills existing records

Implementation details

  • Updates Security::Scan model to include belongs_to :vulnerability_scanner association
  • Modifies Security::StoreScanService to set scanner_id when creating scans
  • Updates scanner method to use the association when available, falling back to existing lookup logic
  • Adds comprehensive specs for model associations and service behavior

Related issues

Closes #371642 (partial - steps 1-3) Related to !212779

Merge request reports

Loading