Class: Gitlab::Ci::Reports::Security::Flag

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/ci/reports/security/flag.rb

Constant Summary collapse

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type: nil, origin: nil, description: nil) ⇒ Flag

Returns a new instance of Flag.



17
18
19
20
21
# File 'lib/gitlab/ci/reports/security/flag.rb', line 17

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

Instance Attribute Details

#descriptionObject (readonly)

Returns the value of attribute description.



8
9
10
# File 'lib/gitlab/ci/reports/security/flag.rb', line 8

def description
  @description
end

#originObject (readonly)

Returns the value of attribute origin.



8
9
10
# File 'lib/gitlab/ci/reports/security/flag.rb', line 8

def origin
  @origin
end

#typeObject (readonly)

Returns the value of attribute type.



8
9
10
# File 'lib/gitlab/ci/reports/security/flag.rb', line 8

def type
  @type
end

Instance Method Details

#false_positive?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/gitlab/ci/reports/security/flag.rb', line 31

def false_positive?
  flag_type == :false_positive
end

#flag_typeObject



13
14
15
# File 'lib/gitlab/ci/reports/security/flag.rb', line 13

def flag_type
  MAP.fetch(type, DEFAULT_FLAG_TYPE)
end

#to_hObject



23
24
25
26
27
28
29
# File 'lib/gitlab/ci/reports/security/flag.rb', line 23

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