Class: Gitlab::SecretDetection::Core::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/secret_detection/core/response.rb

Overview

Response is the data object returned by the scan operation with the following structure

status

One of values from Gitlab::SecretDetection::Core::Status indicating the scan operation’s status

results

Array of Gitlab::SecretDetection::Core::Finding values. Default value is nil.

to embed more information on error.
applied_exclusions

Array of Exclusions that were applied during this scan.

metadata

Hash object containing additional meta information about the response. It is currently used

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(status:, results: [], applied_exclusions: [], metadata: {}) ⇒ Response

Returns a new instance of Response.



16
17
18
19
20
21
# File 'lib/gitlab/secret_detection/core/response.rb', line 16

def initialize(status:, results: [], applied_exclusions: [], metadata: {})
  @status = status
  @results = results
  @applied_exclusions = applied_exclusions
  @metadata = 
end

Instance Attribute Details

#applied_exclusionsObject (readonly)

Returns the value of attribute applied_exclusions.



14
15
16
# File 'lib/gitlab/secret_detection/core/response.rb', line 14

def applied_exclusions
  @applied_exclusions
end

#metadataObject (readonly)

Returns the value of attribute metadata.



14
15
16
# File 'lib/gitlab/secret_detection/core/response.rb', line 14

def 
  @metadata
end

#resultsObject (readonly)

Returns the value of attribute results.



14
15
16
# File 'lib/gitlab/secret_detection/core/response.rb', line 14

def results
  @results
end

#statusObject (readonly)

Returns the value of attribute status.



14
15
16
# File 'lib/gitlab/secret_detection/core/response.rb', line 14

def status
  @status
end

Instance Method Details

#==(other) ⇒ Object



23
24
25
# File 'lib/gitlab/secret_detection/core/response.rb', line 23

def ==(other)
  self.class == other.class && other.state == state
end

#to_hObject



27
28
29
30
31
32
33
34
# File 'lib/gitlab/secret_detection/core/response.rb', line 27

def to_h
  {
    status:,
    results: results&.map(&:to_h),
    applied_exclusions:,
    metadata:
  }
end