summaryrefslogtreecommitdiff
path: root/lib/gitlab/ci/reports/security/flag.rb
blob: 7e6cc758864beca733328dcfdb1348c9625cf409 (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
# frozen_string_literal: true

module Gitlab
  module Ci
    module Reports
      module Security
        class Flag
          attr_reader :type, :origin, :description

          MAP = { 'flagged-as-likely-false-positive' => :false_positive }.freeze
          DEFAULT_FLAG_TYPE = :false_positive

          def flag_type
            MAP.fetch(type, DEFAULT_FLAG_TYPE)
          end

          def initialize(type: nil, origin: nil, description: nil)
            @type = type
            @origin = origin
            @description = description
          end

          def to_hash
            {
              flag_type: flag_type,
              origin: origin,
              description: description
            }.compact
          end
        end
      end
    end
  end
end