Commit 2ac340ec authored by Lukas Eipert's avatar Lukas Eipert

Remove security_reports hash from environment entitity

We decided that the merged BE implementation needs to be redone.
As the current implementation is not used by any consumer, we should remove it.

For more information see https://gitlab.com/gitlab-org/gitlab-ee/issues/4299
parent 3b70be8d
......@@ -7,44 +7,6 @@ module EE
expose :logs_path, if: -> (*) { can_read_pod_logs? } do |environment|
logs_project_environment_path(environment.project, environment)
end
expose :security_reports do
expose :has_security_reports do |environment|
has_security_reports?
end
expose :sast_path, if: -> (*) { environment.last_pipeline&.expose_sast_data? } do |environment|
raw_project_build_artifacts_url(environment.project,
environment.last_pipeline.sast_artifact,
path: Ci::Build::SAST_FILE)
end
expose :dependency_scanning_path, if: -> (*) { environment.last_pipeline&.expose_dependency_scanning_data? } do |environment|
raw_project_build_artifacts_url(environment.project,
environment.last_pipeline.dependency_scanning_artifact,
path: Ci::Build::DEPENDENCY_SCANNING_FILE)
end
expose :dast_path, if: -> (*) { environment.last_pipeline&.expose_dast_data? } do |environment|
raw_project_build_artifacts_url(environment.project,
environment.last_pipeline.dast_artifact,
path: Ci::Build::DAST_FILE)
end
expose :container_scanning_path, if: -> (*) { environment.last_pipeline&.expose_container_scanning_data? } do |environment|
raw_project_build_artifacts_url(environment.project,
environment.last_pipeline.container_scanning_artifact,
path: Ci::Build::CONTAINER_SCANNING_FILE)
end
expose :vulnerability_feedback_path, if: -> (*) { has_security_reports? } do |environment|
project_vulnerability_feedback_index_path(environment.project)
end
expose :pipeline_security_path, if: -> (*) { has_security_reports? } do |environment|
security_project_pipeline_path(environment.project, environment.last_pipeline)
end
end
end
private
......@@ -52,9 +14,5 @@ module EE
def can_read_pod_logs?
can?(current_user, :read_pod_logs, environment.project)
end
def has_security_reports?
environment.last_pipeline&.expose_security_dashboard? || false
end
end
end
......@@ -8,8 +8,7 @@
"last_deployment",
"environment_path",
"created_at",
"updated_at",
"security_reports"
"updated_at"
],
"properties": {
"id": {
......@@ -69,33 +68,6 @@
},
"can_stop": {
"type": "boolean"
},
"security_reports": {
"type": "object",
"additionalProperties": false,
"properties": {
"has_security_reports": {
"type": "boolean"
},
"sast_path": {
"type": "string"
},
"dast_path": {
"type": "string"
},
"container_scanning_path": {
"type": "string"
},
"dependency_scanning_path": {
"type": "string"
},
"vulnerability_feedback_path": {
"type": "string"
},
"pipeline_security_path": {
"type": "string"
}
}
}
}
}
......@@ -32,78 +32,4 @@ describe EnvironmentEntity do
it_behaves_like 'protected environments access', false
end
describe 'security_reports hash' do
it 'is present' do
expect(entity.as_json.include?(:security_reports)).to eq(true)
end
it 'value :has_security_reports is false' do
expect(entity.as_json[:security_reports].size).to eq(1)
expect(entity.as_json[:security_reports]).to include(:has_security_reports)
expect(entity.as_json[:security_reports][:has_security_reports]).to eq(false)
end
end
context 'with secure artifacts' do
let(:pipeline) { create(:ci_pipeline, :success, project: project) }
let(:deployable) { create(:ci_build, :success, pipeline: pipeline) }
jobs_parameters = [
{ name: 'sast', filename: Ci::Build::SAST_FILE },
{ name: 'dast', filename: Ci::Build::DAST_FILE },
{ name: 'container_scanning', filename: Ci::Build::CONTAINER_SCANNING_FILE },
{ name: 'dependency_scanning', filename: Ci::Build::DEPENDENCY_SCANNING_FILE }
]
before do
stub_licensed_features(sast: true, dast: true, dependency_scanning: true, sast_container: true)
create(:deployment, deployable: deployable, environment: environment)
jobs_parameters.each do |job_parameters|
create(
:ci_job_artifact,
:archive,
job: create(
:ci_build,
:success,
pipeline: pipeline,
name: job_parameters[:name],
options: {
artifacts: {
paths: [job_parameters[:filename]]
}
}))
end
allow_any_instance_of(LegacyArtifactUploader).to receive(:exists?).and_return(true)
end
describe 'security_reports hash' do
it 'contains the reports' do
expect(entity.as_json[:security_reports]).to include(:sast_path)
expect(entity.as_json[:security_reports]).to include(:dast_path)
expect(entity.as_json[:security_reports]).to include(:container_scanning_path)
expect(entity.as_json[:security_reports]).to include(:dependency_scanning_path)
expect(entity.as_json[:security_reports][:sast_path]).to end_with(Ci::Build::SAST_FILE)
expect(entity.as_json[:security_reports][:dast_path]).to end_with(Ci::Build::DAST_FILE)
expect(entity.as_json[:security_reports][:container_scanning_path]).to end_with(Ci::Build::CONTAINER_SCANNING_FILE)
expect(entity.as_json[:security_reports][:dependency_scanning_path]).to end_with(Ci::Build::DEPENDENCY_SCANNING_FILE)
end
it 'value :has_security_reports is true' do
expect(entity.as_json[:security_reports]).to include(:has_security_reports)
expect(entity.as_json[:security_reports][:has_security_reports]).to eq(true)
end
it 'contains link to latest pipeline' do
expect(entity.as_json[:security_reports]).to include(:pipeline_security_path)
end
it 'contains link to vulnerability feedback' do
expect(entity.as_json[:security_reports]).to include(:vulnerability_feedback_path)
end
end
end
end
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