Skip to content
代码片段 群组 项目
未验证 提交 7a1f3679 编辑于 作者: Mehmet Emin INAC's avatar Mehmet Emin INAC 提交者: GitLab
浏览文件

Merge branch 'bwill/set-traversal-ids-and-archived-on-sbom-ingestion' into 'master'

Set `traversal_ids` and `archived` during Sbom ingestion

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



Merged-by: default avatarMehmet Emin INAC <minac@gitlab.com>
Approved-by: default avatarZamir Martins <zfilho@gitlab.com>
Approved-by: default avatarMehmet Emin INAC <minac@gitlab.com>
Reviewed-by: default avatarZamir Martins <zfilho@gitlab.com>
Co-authored-by: default avatarBrian Williams <bwilliams@gitlab.com>
No related branches found
No related tags found
无相关合并请求
......@@ -20,6 +20,8 @@ def execute
private
attr_reader :pipeline, :occurrence_maps
delegate :project, to: :pipeline, private: true
end
end
end
......
......@@ -23,7 +23,7 @@ def attributes
occurrence_maps.uniq! { |occurrence_map| uuid(occurrence_map) }
occurrence_maps.map do |occurrence_map|
{
project_id: pipeline.project.id,
project_id: project.id,
pipeline_id: pipeline.id,
component_id: occurrence_map.component_id,
component_version_id: occurrence_map.component_version_id,
......@@ -36,9 +36,11 @@ def attributes
licenses: licenses.fetch(occurrence_map.report_component, []),
component_name: occurrence_map.name,
highest_severity: occurrence_map.highest_severity,
vulnerability_count: occurrence_map.vulnerability_count
vulnerability_count: occurrence_map.vulnerability_count,
traversal_ids: project.namespace.traversal_ids,
archived: project.archived
}.tap do |attrs|
if Feature.disabled?(:sbom_occurrences_vulnerabilities, pipeline.project)
if Feature.disabled?(:sbom_occurrences_vulnerabilities, project)
attrs.except!(:vulnerability_count, :highest_severity)
end
end
......@@ -50,13 +52,13 @@ def uuid(occurrence_map)
:component_id,
:component_version_id,
:source_id
).merge(project_id: pipeline.project.id)
).merge(project_id: project.id)
::Sbom::OccurrenceUUID.generate(**uuid_attributes)
end
def licenses
Licenses.new(pipeline.project, occurrence_maps)
Licenses.new(project, occurrence_maps)
end
strong_memoize_attr :licenses
......
......@@ -6,6 +6,7 @@
describe '#execute' do
let_it_be(:pipeline) { build(:ci_pipeline) }
let(:project) { pipeline.project }
let(:occurrence_maps) { create_list(:sbom_occurrence_map, 4, :for_occurrence_ingestion) }
subject(:ingest_occurrences) { described_class.execute(pipeline, occurrence_maps) }
......@@ -41,7 +42,7 @@
it 'sets the correct attributes for the occurrence' do
ingest_occurrences
expect(ingested_occurrence.attributes).to include(
'project_id' => pipeline.project.id,
'project_id' => project.id,
'pipeline_id' => pipeline.id,
'component_id' => occurrence_map.component_id,
'component_version_id' => occurrence_map.component_version_id,
......@@ -64,7 +65,9 @@
],
'component_name' => occurrence_map.name,
'vulnerability_count' => 1,
'highest_severity' => 'high'
'highest_severity' => 'high',
'traversal_ids' => project.namespace.traversal_ids,
'archived' => project.archived
)
end
......@@ -109,7 +112,7 @@
ingest_occurrences
expect(ingested_occurrence.attributes).to include(
'project_id' => pipeline.project.id,
'project_id' => project.id,
'pipeline_id' => pipeline.id,
'component_id' => occurrence_map.component_id,
'component_version_id' => occurrence_map.component_version_id,
......@@ -131,7 +134,9 @@
],
'component_name' => occurrence_map.name,
'vulnerability_count' => 1,
'highest_severity' => 'high'
'highest_severity' => 'high',
'traversal_ids' => project.namespace.traversal_ids,
'archived' => project.archived
)
end
end
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册