Commit 66e8b9af authored by Michał Zając's avatar Michał Zając

Set related fields when setting different states

parent b005d318
...@@ -36,14 +36,30 @@ class Gitlab::Seeder::Vulnerabilities ...@@ -36,14 +36,30 @@ class Gitlab::Seeder::Vulnerabilities
private private
def create_vulnerability def create_vulnerability
project.vulnerabilities.create!( vulnerability = project.vulnerabilities.build(
state: random_state,
author: author, author: author,
title: 'Cypher with no integrity', title: 'Cypher with no integrity',
severity: random_severity_level, severity: random_severity_level,
confidence: random_confidence_level, confidence: random_confidence_level,
report_type: random_report_type report_type: random_report_type
) )
vulnerability = set_random_vulnerability_state(vulnerability)
vulnerability.save!
vulnerability
end
def set_random_vulnerability_state(vulnerability)
state = ::Vulnerability.states.keys.sample
vulnerability.state = state
case state
when "resolved"
vulnerability.resolved_by = vulnerability.author
vulnerability.resolved_at = Time.now
when "dismissed"
vulnerability.closed_by = vulnerability.author
vulnerability.closed_at = Time.now
end
vulnerability
end end
def create_occurrence(vulnerability, rank, primary_identifier) def create_occurrence(vulnerability, rank, primary_identifier)
...@@ -119,10 +135,6 @@ class Gitlab::Seeder::Vulnerabilities ...@@ -119,10 +135,6 @@ class Gitlab::Seeder::Vulnerabilities
::Vulnerabilities::Occurrence::REPORT_TYPES.keys.sample ::Vulnerabilities::Occurrence::REPORT_TYPES.keys.sample
end end
def random_state
::Vulnerability.states.keys.sample
end
def metadata(line) def metadata(line)
{ {
description: "The cipher does not provide data integrity update 1", description: "The cipher does not provide data integrity update 1",
......
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