Commit 15bdf636 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge branch 'dz-sast-container' into 'master'

Rename clair and sast:image references to sast:container

Closes #4359

See merge request gitlab-org/gitlab-ee!3850
parents d54c81fe 5b5d1818
...@@ -41,7 +41,7 @@ export default { ...@@ -41,7 +41,7 @@ export default {
return this.mr.sast; return this.mr.sast;
}, },
shouldRenderDockerReport() { shouldRenderDockerReport() {
return this.mr.clair; return this.mr.sastContainer;
}, },
codequalityText() { codequalityText() {
const { newIssues, resolvedIssues } = this.mr.codeclimateMetrics; const { newIssues, resolvedIssues } = this.mr.codeclimateMetrics;
...@@ -245,7 +245,7 @@ export default { ...@@ -245,7 +245,7 @@ export default {
}, },
fetchDockerReport() { fetchDockerReport() {
const { path } = this.mr.clair; const { path } = this.mr.sastContainer;
this.isLoadingDocker = true; this.isLoadingDocker = true;
this.service.fetchReport(path) this.service.fetchReport(path)
...@@ -340,8 +340,8 @@ export default { ...@@ -340,8 +340,8 @@ export default {
v-if="shouldRenderDockerReport" v-if="shouldRenderDockerReport"
type="docker" type="docker"
:status="dockerStatus" :status="dockerStatus"
:loading-text="translateText('clair').loading" :loading-text="translateText('sast:container').loading"
:error-text="translateText('clair').error" :error-text="translateText('sast:container').error"
:success-text="dockerText" :success-text="dockerText"
:unresolved-issues="mr.dockerReport.unapproved" :unresolved-issues="mr.dockerReport.unapproved"
:neutral-issues="mr.dockerReport.approved" :neutral-issues="mr.dockerReport.approved"
......
...@@ -73,7 +73,7 @@ export default class MergeRequestStore extends CEMergeRequestStore { ...@@ -73,7 +73,7 @@ export default class MergeRequestStore extends CEMergeRequestStore {
} }
initDockerReport(data) { initDockerReport(data) {
this.clair = data.clair; this.sastContainer = data.sast_container;
this.dockerReport = { this.dockerReport = {
approved: [], approved: [],
unapproved: [], unapproved: [],
......
...@@ -10,13 +10,13 @@ module EE ...@@ -10,13 +10,13 @@ module EE
CODEQUALITY_FILE = 'codeclimate.json'.freeze CODEQUALITY_FILE = 'codeclimate.json'.freeze
SAST_FILE = 'gl-sast-report.json'.freeze SAST_FILE = 'gl-sast-report.json'.freeze
PERFORMANCE_FILE = 'performance.json'.freeze PERFORMANCE_FILE = 'performance.json'.freeze
CLAIR_FILE = 'gl-sast-image-report.json'.freeze SAST_CONTAINER_FILE = 'gl-sast-container-report.json'.freeze
included do included do
scope :codequality, ->() { where(name: %w[codequality codeclimate]) } scope :codequality, ->() { where(name: %w[codequality codeclimate]) }
scope :performance, ->() { where(name: %w[performance deploy]) } scope :performance, ->() { where(name: %w[performance deploy]) }
scope :sast, ->() { where(name: 'sast') } scope :sast, ->() { where(name: 'sast') }
scope :clair, ->() { where(name: 'sast:image') } scope :sast_container, ->() { where(name: 'sast:container') }
after_save :stick_build_if_status_changed after_save :stick_build_if_status_changed
end end
...@@ -44,8 +44,8 @@ module EE ...@@ -44,8 +44,8 @@ module EE
has_artifact?(SAST_FILE) has_artifact?(SAST_FILE)
end end
def has_clair_json? def has_sast_container_json?
has_artifact?(CLAIR_FILE) has_artifact?(SAST_CONTAINER_FILE)
end end
private private
......
...@@ -25,8 +25,8 @@ module EE ...@@ -25,8 +25,8 @@ module EE
artifacts.sast.find(&:has_sast_json?) artifacts.sast.find(&:has_sast_json?)
end end
def clair_artifact def sast_container_artifact
artifacts.clair.find(&:has_clair_json?) artifacts.sast_container.find(&:has_sast_container_json?)
end end
end end
end end
......
...@@ -14,7 +14,7 @@ module EE ...@@ -14,7 +14,7 @@ module EE
delegate :performance_artifact, to: :head_pipeline, prefix: :head, allow_nil: true delegate :performance_artifact, to: :head_pipeline, prefix: :head, allow_nil: true
delegate :performance_artifact, to: :base_pipeline, prefix: :base, allow_nil: true delegate :performance_artifact, to: :base_pipeline, prefix: :base, allow_nil: true
delegate :sast_artifact, to: :head_pipeline, allow_nil: true delegate :sast_artifact, to: :head_pipeline, allow_nil: true
delegate :clair_artifact, to: :head_pipeline, allow_nil: true delegate :sast_container_artifact, to: :head_pipeline, allow_nil: true
delegate :sha, to: :head_pipeline, prefix: :head_pipeline, allow_nil: true delegate :sha, to: :head_pipeline, prefix: :head_pipeline, allow_nil: true
delegate :sha, to: :base_pipeline, prefix: :base_pipeline, allow_nil: true delegate :sha, to: :base_pipeline, prefix: :base_pipeline, allow_nil: true
end end
...@@ -56,8 +56,8 @@ module EE ...@@ -56,8 +56,8 @@ module EE
sast_artifact&.success? sast_artifact&.success?
end end
def has_clair_data? def has_sast_container_data?
clair_artifact&.success? sast_container_artifact&.success?
end end
end end
end end
...@@ -55,7 +55,7 @@ class License < ActiveRecord::Base ...@@ -55,7 +55,7 @@ class License < ActiveRecord::Base
EEU_FEATURES = EEP_FEATURES + %i[ EEU_FEATURES = EEP_FEATURES + %i[
sast sast
sast_image sast_container
epics epics
].freeze ].freeze
......
...@@ -51,11 +51,11 @@ module EE ...@@ -51,11 +51,11 @@ module EE
end end
end end
expose :clair, if: -> (mr, _) { expose_clair_data?(mr, current_user) } do expose :sast_container, if: -> (mr, _) { expose_sast_container_data?(mr, current_user) } do
expose :path do |merge_request| expose :path do |merge_request|
raw_project_build_artifacts_url(merge_request.source_project, raw_project_build_artifacts_url(merge_request.source_project,
merge_request.clair_artifact, merge_request.sast_container_artifact,
path: Ci::Build::CLAIR_FILE) path: Ci::Build::SAST_CONTAINER_FILE)
end end
expose :blob_path, if: -> (mr, _) { mr.head_pipeline_sha } do |merge_request| expose :blob_path, if: -> (mr, _) { mr.head_pipeline_sha } do |merge_request|
...@@ -77,10 +77,10 @@ module EE ...@@ -77,10 +77,10 @@ module EE
mr.has_performance_data? mr.has_performance_data?
end end
def expose_clair_data?(mr, current_user) def expose_sast_container_data?(mr, current_user)
mr.project.feature_available?(:sast_image) && mr.project.feature_available?(:sast_container) &&
mr.has_clair_data? && mr.has_sast_container_data? &&
can?(current_user, :read_build, mr.clair_artifact) can?(current_user, :read_build, mr.sast_container_artifact)
end end
end end
end end
...@@ -132,7 +132,7 @@ describe Ci::Build do ...@@ -132,7 +132,7 @@ describe Ci::Build do
has_codeclimate_json?: Ci::Build::CODEQUALITY_FILE, has_codeclimate_json?: Ci::Build::CODEQUALITY_FILE,
has_performance_json?: Ci::Build::PERFORMANCE_FILE, has_performance_json?: Ci::Build::PERFORMANCE_FILE,
has_sast_json?: Ci::Build::SAST_FILE, has_sast_json?: Ci::Build::SAST_FILE,
has_clair_json?: Ci::Build::CLAIR_FILE has_sast_container_json?: Ci::Build::SAST_CONTAINER_FILE
}.freeze }.freeze
ARTIFACTS_METHODS.each do |method, filename| ARTIFACTS_METHODS.each do |method, filename|
......
...@@ -18,8 +18,8 @@ describe Ci::Pipeline do ...@@ -18,8 +18,8 @@ describe Ci::Pipeline do
ARTIFACTS_METHODS = { ARTIFACTS_METHODS = {
codeclimate_artifact: [Ci::Build::CODEQUALITY_FILE, 'codequality'], codeclimate_artifact: [Ci::Build::CODEQUALITY_FILE, 'codequality'],
performance_artifact: [Ci::Build::PERFORMANCE_FILE, 'performance'], performance_artifact: [Ci::Build::PERFORMANCE_FILE, 'performance'],
sast_artifact: [Ci::Build::SAST_FILE, 'sast'], sast_artifact: [Ci::Build::SAST_FILE, 'sast'],
clair_artifact: [Ci::Build::CLAIR_FILE, 'sast:image'] sast_container_artifact: [Ci::Build::SAST_CONTAINER_FILE, 'sast:container']
}.freeze }.freeze
ARTIFACTS_METHODS.each do |method, options| ARTIFACTS_METHODS.each do |method, options|
......
...@@ -247,7 +247,7 @@ describe MergeRequest do ...@@ -247,7 +247,7 @@ describe MergeRequest do
it { expect(merge_request.has_sast_data?).to be_truthy } it { expect(merge_request.has_sast_data?).to be_truthy }
end end
describe '#clair_artifact' do describe '#sast_container_artifact' do
it { is_expected.to delegate_method(:clair_artifact).to(:head_pipeline) } it { is_expected.to delegate_method(:sast_container_artifact).to(:head_pipeline) }
end end
end end
...@@ -29,12 +29,12 @@ describe MergeRequestWidgetEntity do ...@@ -29,12 +29,12 @@ describe MergeRequestWidgetEntity do
expect(subject.as_json).to include(:sast) expect(subject.as_json).to include(:sast)
end end
it 'has clair data' do it 'has sast_container data' do
build = create(:ci_build, name: 'sast:image') build = create(:ci_build, name: 'sast:image')
allow(subject).to receive(:expose_clair_data?).and_return(true) allow(subject).to receive(:expose_sast_container_data?).and_return(true)
allow(merge_request).to receive(:clair_artifact).and_return(build) allow(merge_request).to receive(:sast_container_artifact).and_return(build)
expect(subject.as_json).to include(:clair) expect(subject.as_json).to include(:sast_container)
end end
end end
...@@ -369,8 +369,8 @@ describe('ee merge request widget options', () => { ...@@ -369,8 +369,8 @@ describe('ee merge request widget options', () => {
beforeEach(() => { beforeEach(() => {
gl.mrWidgetData = { gl.mrWidgetData = {
...mockData, ...mockData,
clair: { sast_container: {
path: 'clair.json', path: 'gl-sast-container.json',
blob_path: 'blob_path', blob_path: 'blob_path',
}, },
}; };
...@@ -385,7 +385,7 @@ describe('ee merge request widget options', () => { ...@@ -385,7 +385,7 @@ describe('ee merge request widget options', () => {
expect( expect(
vm.$el.querySelector('.js-docker-widget').textContent.trim(), vm.$el.querySelector('.js-docker-widget').textContent.trim(),
).toContain('Loading clair report'); ).toContain('Loading sast:container report');
}); });
}); });
...@@ -394,7 +394,7 @@ describe('ee merge request widget options', () => { ...@@ -394,7 +394,7 @@ describe('ee merge request widget options', () => {
beforeEach(() => { beforeEach(() => {
mock = mock = new MockAdapter(axios); mock = mock = new MockAdapter(axios);
mock.onGet('clair.json').reply(200, dockerReport); mock.onGet('gl-sast-container.json').reply(200, dockerReport);
vm = mountComponent(Component); vm = mountComponent(Component);
}); });
...@@ -433,7 +433,7 @@ describe('ee merge request widget options', () => { ...@@ -433,7 +433,7 @@ describe('ee merge request widget options', () => {
beforeEach(() => { beforeEach(() => {
mock = mock = new MockAdapter(axios); mock = mock = new MockAdapter(axios);
mock.onGet('clair.json').reply(500, {}); mock.onGet('gl-sast-container.json').reply(500, {});
vm = mountComponent(Component); vm = mountComponent(Component);
}); });
...@@ -445,7 +445,7 @@ describe('ee merge request widget options', () => { ...@@ -445,7 +445,7 @@ describe('ee merge request widget options', () => {
setTimeout(() => { setTimeout(() => {
expect( expect(
vm.$el.querySelector('.js-docker-widget').textContent.trim(), vm.$el.querySelector('.js-docker-widget').textContent.trim(),
).toContain('Failed to load clair report'); ).toContain('Failed to load sast:container report');
done(); done();
}, 0); }, 0);
}); });
...@@ -496,7 +496,7 @@ describe('ee merge request widget options', () => { ...@@ -496,7 +496,7 @@ describe('ee merge request widget options', () => {
vm = mountComponent(Component, { vm = mountComponent(Component, {
mrData: { mrData: {
...mockData, ...mockData,
clair: { sast_container: {
path: 'foo', path: 'foo',
}, },
}, },
......
...@@ -113,9 +113,9 @@ describe('MergeRequestStore', () => { ...@@ -113,9 +113,9 @@ describe('MergeRequestStore', () => {
describe('initDockerReport', () => { describe('initDockerReport', () => {
it('sets the defaults', () => { it('sets the defaults', () => {
store.initDockerReport({ clair: { path: 'clair.json' } }); store.initDockerReport({ sast_container: { path: 'gl-sast-container.json' } });
expect(store.clair).toEqual({ path: 'clair.json' }); expect(store.sastContainer).toEqual({ path: 'gl-sast-container.json' });
expect(store.dockerReport).toEqual({ expect(store.dockerReport).toEqual({
approved: [], approved: [],
unapproved: [], unapproved: [],
......
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