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.

These can be either GRPC::Exclusions when used as a service, or `Security::ProjectSecurityExclusion
object when used as a gem.
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.



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

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.



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

def applied_exclusions
  @applied_exclusions
end

#metadataObject (readonly)

Returns the value of attribute metadata.



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

def 
  @metadata
end

#resultsObject (readonly)

Returns the value of attribute results.



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

def results
  @results
end

#statusObject (readonly)

Returns the value of attribute status.



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

def status
  @status
end

Instance Method Details

#==(other) ⇒ Object



25
26
27
# File 'lib/gitlab/secret_detection/core/response.rb', line 25

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

#to_hObject



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

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