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