Commit 3ca91553 authored by Michał Zając's avatar Michał Zając

Load EE factories when seeding Vulnerabilities

parent 42a4f238
......@@ -5,6 +5,8 @@ class Gitlab::Seeder::Vulnerabilities
def initialize(project)
@project = project
FactoryBot.definition_file_paths << Rails.root.join('ee', 'spec', 'factories')
FactoryBot.reload # rubocop:disable Cop/ActiveRecordAssociationReload
end
def seed!
......@@ -63,10 +65,12 @@ class Gitlab::Seeder::Vulnerabilities
end
def create_occurrence(vulnerability, rank, primary_identifier)
scanner = FactoryBot.create(:vulnerabilities_scanner, project: vulnerability.project)
FactoryBot.create(
:vulnerabilities_occurrence,
project: project,
vulnerability: vulnerability,
scanner: scanner,
severity: random_severity_level,
confidence: random_confidence_level,
primary_identifier: primary_identifier,
......@@ -78,7 +82,7 @@ class Gitlab::Seeder::Vulnerabilities
def create_identifier(rank)
FactoryBot.create(
:vulnerability_identifier,
:vulnerabilities_identifier,
external_type: "SECURITY_ID",
external_id: "SECURITY_#{rank}",
fingerprint: random_fingerprint,
......
......@@ -2,7 +2,7 @@
FactoryBot.define do
sequence :vulnerability_occurrence_uuid do |n|
Digest::SHA1.hexdigest("uuid-#{n}")[0..35]
SecureRandom.uuid
end
factory :vulnerabilities_occurrence, class: 'Vulnerabilities::Occurrence', aliases: [:vulnerabilities_finding] do
......
# frozen_string_literal: true
FactoryBot.define do
sequence(:vulnerability_scanner_external_id) do |n|
"find_sec_bugs ##{n}"
end
factory :vulnerabilities_scanner, class: 'Vulnerabilities::Scanner' do
external_id { 'find_sec_bugs' }
sequence(:external_id) { generate(:vulnerability_scanner_external_id) }
name { 'Find Security Bugs' }
project
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment