Class: SemgrepWebApp::ListFindingsResponse

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/semgrep_web_app/models/list_findings_response.rb

Overview

Response containing a paginated list of findings (either Code or Supply Chain findings) with optional filtering applied

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json

Constructor Details

#initialize(ai_sast_findings: SKIP, sast_findings: SKIP, sca_findings: SKIP, additional_properties: nil) ⇒ ListFindingsResponse

Returns a new instance of ListFindingsResponse.



50
51
52
53
54
55
56
57
58
59
# File 'lib/semgrep_web_app/models/list_findings_response.rb', line 50

def initialize(ai_sast_findings: SKIP, sast_findings: SKIP,
               sca_findings: SKIP, additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @ai_sast_findings = ai_sast_findings unless ai_sast_findings == SKIP
  @sast_findings = sast_findings unless sast_findings == SKIP
  @sca_findings = sca_findings unless sca_findings == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#ai_sast_findingsAiSastFindings

A list of AI-powered scan findings that Semgrep has identified in your organization

Returns:



16
17
18
# File 'lib/semgrep_web_app/models/list_findings_response.rb', line 16

def ai_sast_findings
  @ai_sast_findings
end

#sast_findingsSastFindings

A list of Code findings that Semgrep has identified in your organization

Returns:



20
21
22
# File 'lib/semgrep_web_app/models/list_findings_response.rb', line 20

def sast_findings
  @sast_findings
end

#sca_findingsScaFindings

A list of Supply Chain findings that Semgrep has identified in your organization

Returns:



25
26
27
# File 'lib/semgrep_web_app/models/list_findings_response.rb', line 25

def sca_findings
  @sca_findings
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/semgrep_web_app/models/list_findings_response.rb', line 62

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  ai_sast_findings = AiSastFindings.from_hash(hash['aiSastFindings']) if
    hash['aiSastFindings']
  sast_findings = SastFindings.from_hash(hash['sastFindings']) if hash['sastFindings']
  sca_findings = ScaFindings.from_hash(hash['scaFindings']) if hash['scaFindings']

  # Create a new hash for additional properties, removing known properties.
  new_hash = hash.reject { |k, _| names.value?(k) }

  additional_properties = APIHelper.get_additional_properties(
    new_hash, proc { |value| value }
  )

  # Create object from extracted values.
  ListFindingsResponse.new(ai_sast_findings: ai_sast_findings,
                           sast_findings: sast_findings,
                           sca_findings: sca_findings,
                           additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



28
29
30
31
32
33
34
# File 'lib/semgrep_web_app/models/list_findings_response.rb', line 28

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['ai_sast_findings'] = 'aiSastFindings'
  @_hash['sast_findings'] = 'sastFindings'
  @_hash['sca_findings'] = 'scaFindings'
  @_hash
end

.nullablesObject

An array for nullable fields



46
47
48
# File 'lib/semgrep_web_app/models/list_findings_response.rb', line 46

def self.nullables
  []
end

.optionalsObject

An array for optional fields



37
38
39
40
41
42
43
# File 'lib/semgrep_web_app/models/list_findings_response.rb', line 37

def self.optionals
  %w[
    ai_sast_findings
    sast_findings
    sca_findings
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



93
94
95
96
97
98
# File 'lib/semgrep_web_app/models/list_findings_response.rb', line 93

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} ai_sast_findings: #{@ai_sast_findings.inspect}, sast_findings:"\
  " #{@sast_findings.inspect}, sca_findings: #{@sca_findings.inspect}, additional_properties:"\
  " #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



86
87
88
89
90
# File 'lib/semgrep_web_app/models/list_findings_response.rb', line 86

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} ai_sast_findings: #{@ai_sast_findings}, sast_findings: #{@sast_findings},"\
  " sca_findings: #{@sca_findings}, additional_properties: #{@additional_properties}>"
end