Skip to content

Expose SAST & DAST devops adoption metrics [RUN ALL RSPEC] [RUN AS-IF-FOSS]

What does this MR do?

  1. Changes behaviour of "latestSnapshot" field to be more consistent with description. If for some reason latestSnapshot for previous month wasn't calculated the field should be null
  2. Exposes 2 new fields in Devops Adoption API so FE can use it and display data if it's present.

Migration output

== 20210614124111 AddDevopsAdoptionSastDastIndexes: reverting =================
-- transaction_open?()
   -> 0.0000s
-- indexes(:ci_job_artifacts)
   -> 0.0204s
-- remove_index(:ci_job_artifacts, {:algorithm=>:concurrently, :name=>"index_ci_job_artifacts_sast_for_devops_adoption"})
   -> 0.0058s
-- transaction_open?()
   -> 0.0000s
-- indexes(:ci_job_artifacts)
   -> 0.0172s
-- remove_index(:ci_job_artifacts, {:algorithm=>:concurrently, :name=>"index_ci_job_artifacts_dast_for_devops_adoption"})
   -> 0.0035s
== 20210614124111 AddDevopsAdoptionSastDastIndexes: reverted (0.0516s) ========

== 20210611101034 AddDevopsAdoptionSastDast: reverting ========================
-- remove_column(:analytics_devops_adoption_snapshots, :dast_enabled_count, :integer)
   -> 0.0050s
-- remove_column(:analytics_devops_adoption_snapshots, :sast_enabled_count, :integer)
   -> 0.0023s
== 20210611101034 AddDevopsAdoptionSastDast: reverted (0.0101s) ===============

== 20210611101034 AddDevopsAdoptionSastDast: migrating ========================
-- add_column(:analytics_devops_adoption_snapshots, :sast_enabled_count, :integer)
   -> 0.0058s
-- add_column(:analytics_devops_adoption_snapshots, :dast_enabled_count, :integer)
   -> 0.0025s
== 20210611101034 AddDevopsAdoptionSastDast: migrated (0.0084s) ===============

== 20210614124111 AddDevopsAdoptionSastDastIndexes: migrating =================
-- transaction_open?()
   -> 0.0000s
-- index_exists?(:ci_job_artifacts, [:project_id, :created_at], {:where=>"file_type = 5", :name=>"index_ci_job_artifacts_sast_for_devops_adoption", :algorithm=>:concurrently})
   -> 0.0188s
-- add_index(:ci_job_artifacts, [:project_id, :created_at], {:where=>"file_type = 5", :name=>"index_ci_job_artifacts_sast_for_devops_adoption", :algorithm=>:concurrently})
   -> 0.0097s
-- transaction_open?()
   -> 0.0000s
-- index_exists?(:ci_job_artifacts, [:project_id, :created_at], {:where=>"file_type = 8", :name=>"index_ci_job_artifacts_dast_for_devops_adoption", :algorithm=>:concurrently})
   -> 0.0190s
-- add_index(:ci_job_artifacts, [:project_id, :created_at], {:where=>"file_type = 8", :name=>"index_ci_job_artifacts_dast_for_devops_adoption", :algorithm=>:concurrently})
   -> 0.0066s
== 20210614124111 AddDevopsAdoptionSastDastIndexes: migrated (0.0596s) ========

Query explain

with

CREATE INDEX tmp_index ON ci_job_artifacts (project_id, created_at) WHERE file_type = 5

https://console.postgres.ai/gitlab/gitlab-production-tunnel-pg12/sessions/4581/commands/16171

Screenshots (strongly suggested)

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Security

Does this MR contain changes to processing or storing of credentials or tokens, authorization and authentication methods or other items described in the security review guidelines? If not, then delete this Security section.

  • Label as security and @ mention @gitlab-com/gl-security/appsec
  • The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
  • Security reports checked/validated by a reviewer from the AppSec team

Related to #326143 (closed)

Edited by Pavel Shutsin

Merge request reports