Commit 679ebf13 authored by Jonathan Schafer's avatar Jonathan Schafer Committed by Michael Kozono

Add jsonb field for Finding Evidence

Changelog: changed
parent c2ecd08e
# frozen_string_literal: true
class AddDataToVulnerabilityFindingEvidence < Gitlab::Database::Migration[1.0]
def change
add_column :vulnerability_finding_evidences, :data, :jsonb, default: {}, null: false
end
end
1ad794ac96f6297203046562c2ec422fbb4d1818a65266bb92179096040f7d82
\ No newline at end of file
...@@ -20340,6 +20340,7 @@ CREATE TABLE vulnerability_finding_evidences ( ...@@ -20340,6 +20340,7 @@ CREATE TABLE vulnerability_finding_evidences (
updated_at timestamp with time zone NOT NULL, updated_at timestamp with time zone NOT NULL,
vulnerability_occurrence_id bigint NOT NULL, vulnerability_occurrence_id bigint NOT NULL,
summary text, summary text,
data jsonb DEFAULT '{}'::jsonb NOT NULL,
CONSTRAINT check_5773b236fb CHECK ((char_length(summary) <= 8000000)) CONSTRAINT check_5773b236fb CHECK ((char_length(summary) <= 8000000))
); );
...@@ -33,6 +33,7 @@ module Vulnerabilities ...@@ -33,6 +33,7 @@ module Vulnerabilities
foreign_key: 'vulnerability_finding_evidence_id' foreign_key: 'vulnerability_finding_evidence_id'
validates :summary, length: { maximum: 8_000_000 } validates :summary, length: { maximum: 8_000_000 }
validates :data, length: { maximum: 16_000_000 }, presence: true
end end
end end
end end
...@@ -46,4 +46,6 @@ RSpec.describe Vulnerabilities::Finding::Evidence do ...@@ -46,4 +46,6 @@ RSpec.describe Vulnerabilities::Finding::Evidence do
} }
it { is_expected.to validate_length_of(:summary).is_at_most(8_000_000) } it { is_expected.to validate_length_of(:summary).is_at_most(8_000_000) }
it { is_expected.to validate_presence_of(:data) }
it { is_expected.to validate_length_of(:data).is_at_most(16_000_000) }
end end
...@@ -204,7 +204,8 @@ RSpec.describe 'Database schema' do ...@@ -204,7 +204,8 @@ RSpec.describe 'Database schema' do
"Operations::FeatureFlags::Strategy" => %w[parameters], "Operations::FeatureFlags::Strategy" => %w[parameters],
"Packages::Composer::Metadatum" => %w[composer_json], "Packages::Composer::Metadatum" => %w[composer_json],
"RawUsageData" => %w[payload], # Usage data payload changes often, we cannot use one schema "RawUsageData" => %w[payload], # Usage data payload changes often, we cannot use one schema
"Releases::Evidence" => %w[summary] "Releases::Evidence" => %w[summary],
"Vulnerabilities::Finding::Evidence" => %w[data] # Validation work in progress
}.freeze }.freeze
# We are skipping GEO models for now as it adds up complexity # We are skipping GEO models for now as it adds up complexity
......
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