summaryrefslogtreecommitdiff
path: root/app/models/releases/evidence.rb
blob: 7c428f5ad03fd0b1044fba7ada54bbef23a4d9be (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# frozen_string_literal: true

module Releases
  class Evidence < ApplicationRecord
    include ShaAttribute
    include Presentable

    belongs_to :release, inverse_of: :evidences

    default_scope { order(created_at: :asc) } # rubocop:disable Cop/DefaultScope

    sha_attribute :summary_sha
    alias_attribute :collected_at, :created_at
    alias_attribute :sha, :summary_sha

    def milestones
      @milestones ||= release.milestones.includes(:issues)
    end

    ##
    # Return `summary` without sensitive information.
    #
    # Removing issues from summary in order to prevent leaking confidential ones.
    # See more https://gitlab.com/gitlab-org/gitlab/issues/121930
    def summary
      safe_summary = read_attribute(:summary)

      safe_summary.dig('release', 'milestones')&.each do |milestone|
        milestone.delete('issues')
      end

      safe_summary
    end
  end
end