Skip to content
代码片段 群组 项目
未验证 提交 4abe072e 编辑于 作者: Leaminn Ma's avatar Leaminn Ma 提交者: GitLab
浏览文件

Merge branch '479185/sq/make-file_checksum-column-nullable' into 'master'

Adds ignore_column for file_checksum and a migration to make the column nullable

See merge request https://gitlab.com/gitlab-org/gitlab/-/merge_requests/169920



Merged-by: default avatarLeaminn Ma <lma@gitlab.com>
Approved-by: default avatarLeaminn Ma <lma@gitlab.com>
Approved-by: default avatarOmar Qunsul <oqunsul@gitlab.com>
Reviewed-by: default avatarLeaminn Ma <lma@gitlab.com>
Co-authored-by: default avatarsholaq <squadri@gitlab.com>
No related branches found
No related tags found
无相关合并请求
# frozen_string_literal: true
class AllowNullFileChecksumInXrayReports < Gitlab::Database::Migration[2.2]
milestone '17.6'
def change
change_column_null :xray_reports, :file_checksum, true
end
end
b7dcafc4a5211261d39d17e8879a445297297faa021b739f36435774790d1987
\ No newline at end of file
......@@ -21490,7 +21490,7 @@ CREATE TABLE xray_reports (
updated_at timestamp with time zone NOT NULL,
lang text NOT NULL,
payload jsonb NOT NULL,
file_checksum bytea NOT NULL,
file_checksum bytea,
CONSTRAINT check_6da5a3b473 CHECK ((char_length(lang) <= 255))
);
 
......@@ -3,10 +3,13 @@
module Projects
class XrayReport < ApplicationRecord
include Gitlab::Utils::StrongMemoize
include IgnorableColumns
ignore_column :file_checksum, remove_with: '17.8', remove_after: '2024-12-22'
belongs_to :project
validates :project, :payload, :lang, :file_checksum, presence: true
validates :project, :payload, :lang, presence: true
validates :lang, uniqueness: { scope: :project }
validates :payload, json_schema: { filename: 'xray_report' }
......
......@@ -42,15 +42,12 @@ def process
def save_xray_reports(config_files)
config_files_by_lang = config_files.group_by { |cf| cf.class.lang }
# TODO: `file_checksum` to be removed in https://gitlab.com/gitlab-org/gitlab/-/issues/479185.
file_checksum = config_files.first.payload[:checksum]
reports_array = config_files_by_lang.map do |(lang, config_files)|
{
project_id: project.id,
payload: merge_payloads(config_files),
lang: lang,
file_checksum: file_checksum
lang: lang
}
end
......
......@@ -17,7 +17,7 @@ def execute
content = ::Gitlab::Json.parse(blob)
Projects::XrayReport
.upsert(
{ project_id: pipeline.project_id, payload: content, lang: lang, file_checksum: content['checksum'] },
{ project_id: pipeline.project_id, payload: content, lang: lang },
unique_by: [:project_id, :lang]
)
rescue JSON::ParserError => e
......
......@@ -22,7 +22,7 @@ def execute
}
Projects::XrayReport.upsert(
{ project_id: project.id, payload: payload, lang: language, file_checksum: checksum },
{ project_id: project.id, payload: payload, lang: language },
unique_by: [:project_id, :lang]
)
......
......@@ -4,7 +4,6 @@
factory :xray_report, class: 'Projects::XrayReport' do
project
lang { 'Ruby' }
file_checksum { '53b5964d32d30fc60089fb54cd73538003a487afdd5d6a3b549ae162ce4819cd' }
payload do
{
"scannerVersion" => "0.0.1",
......
......@@ -9,7 +9,6 @@
it { is_expected.to validate_presence_of(:project) }
it { is_expected.to validate_presence_of(:lang) }
it { is_expected.to validate_presence_of(:payload) }
it { is_expected.to validate_presence_of(:file_checksum) }
it 'validates uniqueness of lang and project', :aggregate_failures do
create(:xray_report, project: project, lang: 'Ruby')
......
......@@ -27,7 +27,6 @@
report = project.xray_reports.last!
expect(report.lang).to eq(language)
expect(report.file_checksum).to be_present
expect(report.payload['checksum']).to be_present
expect(report.payload['scannerVersion']).to eq(scanner_version)
expect(report.payload['libs']).to match_array(dependencies_hash)
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册