Class: SemgrepWebApp::ProtosSecretsV1SecretsFinding

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

Overview

A Finding represents a single secret finding.

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(autotriage: SKIP, confidence: SKIP, created_at: SKIP, external_ticket: SKIP, finding_path: SKIP, finding_path_url: SKIP, historical_info: SKIP, id: SKIP, mode: SKIP, ref: SKIP, ref_url: SKIP, repository: SKIP, review_comments: SKIP, rule_hash_id: SKIP, severity: SKIP, status: SKIP, type: SKIP, updated_at: SKIP, validation_state: SKIP, additional_properties: nil) ⇒ ProtosSecretsV1SecretsFinding

Returns a new instance of ProtosSecretsV1SecretsFinding.



177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
# File 'lib/semgrep_web_app/models/protos_secrets_v1_secrets_finding.rb', line 177

def initialize(autotriage: SKIP, confidence: SKIP, created_at: SKIP,
               external_ticket: SKIP, finding_path: SKIP,
               finding_path_url: SKIP, historical_info: SKIP, id: SKIP,
               mode: SKIP, ref: SKIP, ref_url: SKIP, repository: SKIP,
               review_comments: SKIP, rule_hash_id: SKIP, severity: SKIP,
               status: SKIP, type: SKIP, updated_at: SKIP,
               validation_state: SKIP, additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @autotriage = autotriage unless autotriage == SKIP
  @confidence = confidence unless confidence == SKIP
  @created_at = created_at unless created_at == SKIP
  @external_ticket = external_ticket unless external_ticket == SKIP
  @finding_path = finding_path unless finding_path == SKIP
  @finding_path_url = finding_path_url unless finding_path_url == SKIP
  @historical_info = historical_info unless historical_info == SKIP
  @id = id unless id == SKIP
  @mode = mode unless mode == SKIP
  @ref = ref unless ref == SKIP
  @ref_url = ref_url unless ref_url == SKIP
  @repository = repository unless repository == SKIP
  @review_comments = review_comments unless review_comments == SKIP
  @rule_hash_id = rule_hash_id unless rule_hash_id == SKIP
  @severity = severity unless severity == SKIP
  @status = status unless status == SKIP
  @type = type unless type == SKIP
  @updated_at = updated_at unless updated_at == SKIP
  @validation_state = validation_state unless validation_state == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#autotriageProtosAiV1Autotriage

  • Autotriage info for the finding. This is used for the Generic Secrets Detection project, for autotriaging secrets findings with LLMs


17
18
19
# File 'lib/semgrep_web_app/models/protos_secrets_v1_secrets_finding.rb', line 17

def autotriage
  @autotriage
end

#confidenceConfidence7

Confidence of the finding.

value description
CONFIDENCE_HIGH
CONFIDENCE_MEDIUM
CONFIDENCE_LOW

Returns:



26
27
28
# File 'lib/semgrep_web_app/models/protos_secrets_v1_secrets_finding.rb', line 26

def confidence
  @confidence
end

#created_atDateTime

Creation timestamp.

Returns:

  • (DateTime)


30
31
32
# File 'lib/semgrep_web_app/models/protos_secrets_v1_secrets_finding.rb', line 30

def created_at
  @created_at
end

#external_ticketProtosTicketingV1ExternalTicket

The external ticket reference



34
35
36
# File 'lib/semgrep_web_app/models/protos_secrets_v1_secrets_finding.rb', line 34

def external_ticket
  @external_ticket
end

#finding_pathString

File path where the finding was detected.

Returns:

  • (String)


38
39
40
# File 'lib/semgrep_web_app/models/protos_secrets_v1_secrets_finding.rb', line 38

def finding_path
  @finding_path
end

#finding_path_urlString

URL to the file where the finding was detected.

Returns:

  • (String)


42
43
44
# File 'lib/semgrep_web_app/models/protos_secrets_v1_secrets_finding.rb', line 42

def finding_path_url
  @finding_path_url
end

#historical_infoProtosSecretsV1HistoricalInfo

Historical scanning info for the finding.



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

def historical_info
  @historical_info
end

#idString

ID of the finding.

Returns:

  • (String)


50
51
52
# File 'lib/semgrep_web_app/models/protos_secrets_v1_secrets_finding.rb', line 50

def id
  @id
end

#modeMode

The behavior of the finding reporting: Monitor / Comment / Block.

value description
MODE_MONITOR Monitor mode, silently report findings
MODE_COMMENT Comment mode, leaves PR comments but does not block
MODE_BLOCK Block mode, leaves PR comments and blocks PR
MODE_DISABLED Disabled mode, not active

Returns:



60
61
62
# File 'lib/semgrep_web_app/models/protos_secrets_v1_secrets_finding.rb', line 60

def mode
  @mode
end

#refString

Branch where the finding was detected.

Returns:

  • (String)


64
65
66
# File 'lib/semgrep_web_app/models/protos_secrets_v1_secrets_finding.rb', line 64

def ref
  @ref
end

#ref_urlString

URL to the branch where the finding was detected.

Returns:

  • (String)


68
69
70
# File 'lib/semgrep_web_app/models/protos_secrets_v1_secrets_finding.rb', line 68

def ref_url
  @ref_url
end

#repositoryProtosSecretsV1SecretsFindingRepository

Repository where the finding was detected.



72
73
74
# File 'lib/semgrep_web_app/models/protos_secrets_v1_secrets_finding.rb', line 72

def repository
  @repository
end

#review_commentsArray[ProtosCommonV1ReviewComment]

List of external review comment information associated with a finding

Returns:



76
77
78
# File 'lib/semgrep_web_app/models/protos_secrets_v1_secrets_finding.rb', line 76

def review_comments
  @review_comments
end

#rule_hash_idString

ID of the rule that triggered the finding.

Returns:

  • (String)


80
81
82
# File 'lib/semgrep_web_app/models/protos_secrets_v1_secrets_finding.rb', line 80

def rule_hash_id
  @rule_hash_id
end

#severitySeverity4

Severity of the finding.

value description
SEVERITY_HIGH
SEVERITY_MEDIUM
SEVERITY_LOW
SEVERITY_CRITICAL

Returns:



90
91
92
# File 'lib/semgrep_web_app/models/protos_secrets_v1_secrets_finding.rb', line 90

def severity
  @severity
end

#statusStatus6

Status of the finding.

value description
FINDING_STATUS_OPEN
FINDING_STATUS_IGNORED
FINDING_STATUS_FIXED
FINDING_STATUS_REMOVED
FINDING_STATUS_UNKNOWN
FINDING_STATUS_PROVISIONALLY_IGNORED

Returns:



102
103
104
# File 'lib/semgrep_web_app/models/protos_secrets_v1_secrets_finding.rb', line 102

def status
  @status
end

#typeString

Service type for the secrets finding (e.g. AWS, GitHub, GitLab, etc).

Returns:

  • (String)


106
107
108
# File 'lib/semgrep_web_app/models/protos_secrets_v1_secrets_finding.rb', line 106

def type
  @type
end

#updated_atDateTime

Update timestamp.

Returns:

  • (DateTime)


110
111
112
# File 'lib/semgrep_web_app/models/protos_secrets_v1_secrets_finding.rb', line 110

def updated_at
  @updated_at
end

#validation_stateValidationState2

Whether the finding was validated or not.

value description
VALIDATION_STATE_CONFIRMED_VALID
VALIDATION_STATE_CONFIRMED_INVALID
VALIDATION_STATE_VALIDATION_ERROR
VALIDATION_STATE_NO_VALIDATOR

Returns:



120
121
122
# File 'lib/semgrep_web_app/models/protos_secrets_v1_secrets_finding.rb', line 120

def validation_state
  @validation_state
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
# File 'lib/semgrep_web_app/models/protos_secrets_v1_secrets_finding.rb', line 210

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  autotriage = ProtosAiV1Autotriage.from_hash(hash['autotriage']) if hash['autotriage']
  confidence = hash.key?('confidence') ? hash['confidence'] : SKIP
  created_at = if hash.key?('createdAt')
                 (DateTimeHelper.from_rfc3339(hash['createdAt']) if hash['createdAt'])
               else
                 SKIP
               end
  external_ticket = ProtosTicketingV1ExternalTicket.from_hash(hash['externalTicket']) if
    hash['externalTicket']
  finding_path = hash.key?('findingPath') ? hash['findingPath'] : SKIP
  finding_path_url =
    hash.key?('findingPathUrl') ? hash['findingPathUrl'] : SKIP
  historical_info = ProtosSecretsV1HistoricalInfo.from_hash(hash['historicalInfo']) if
    hash['historicalInfo']
  id = hash.key?('id') ? hash['id'] : SKIP
  mode = hash.key?('mode') ? hash['mode'] : SKIP
  ref = hash.key?('ref') ? hash['ref'] : SKIP
  ref_url = hash.key?('refUrl') ? hash['refUrl'] : SKIP
  repository = ProtosSecretsV1SecretsFindingRepository.from_hash(hash['repository']) if
    hash['repository']
  # Parameter is an array, so we need to iterate through it
  review_comments = nil
  unless hash['reviewComments'].nil?
    review_comments = []
    hash['reviewComments'].each do |structure|
      review_comments << (ProtosCommonV1ReviewComment.from_hash(structure) if structure)
    end
  end

  review_comments = SKIP unless hash.key?('reviewComments')
  rule_hash_id = hash.key?('ruleHashId') ? hash['ruleHashId'] : SKIP
  severity = hash.key?('severity') ? hash['severity'] : SKIP
  status = hash.key?('status') ? hash['status'] : SKIP
  type = hash.key?('type') ? hash['type'] : SKIP
  updated_at = if hash.key?('updatedAt')
                 (DateTimeHelper.from_rfc3339(hash['updatedAt']) if hash['updatedAt'])
               else
                 SKIP
               end
  validation_state =
    hash.key?('validationState') ? hash['validationState'] : SKIP

  # 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.
  ProtosSecretsV1SecretsFinding.new(autotriage: autotriage,
                                    confidence: confidence,
                                    created_at: created_at,
                                    external_ticket: external_ticket,
                                    finding_path: finding_path,
                                    finding_path_url: finding_path_url,
                                    historical_info: historical_info,
                                    id: id,
                                    mode: mode,
                                    ref: ref,
                                    ref_url: ref_url,
                                    repository: repository,
                                    review_comments: review_comments,
                                    rule_hash_id: rule_hash_id,
                                    severity: severity,
                                    status: status,
                                    type: type,
                                    updated_at: updated_at,
                                    validation_state: validation_state,
                                    additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
# File 'lib/semgrep_web_app/models/protos_secrets_v1_secrets_finding.rb', line 123

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['autotriage'] = 'autotriage'
  @_hash['confidence'] = 'confidence'
  @_hash['created_at'] = 'createdAt'
  @_hash['external_ticket'] = 'externalTicket'
  @_hash['finding_path'] = 'findingPath'
  @_hash['finding_path_url'] = 'findingPathUrl'
  @_hash['historical_info'] = 'historicalInfo'
  @_hash['id'] = 'id'
  @_hash['mode'] = 'mode'
  @_hash['ref'] = 'ref'
  @_hash['ref_url'] = 'refUrl'
  @_hash['repository'] = 'repository'
  @_hash['review_comments'] = 'reviewComments'
  @_hash['rule_hash_id'] = 'ruleHashId'
  @_hash['severity'] = 'severity'
  @_hash['status'] = 'status'
  @_hash['type'] = 'type'
  @_hash['updated_at'] = 'updatedAt'
  @_hash['validation_state'] = 'validationState'
  @_hash
end

.nullablesObject

An array for nullable fields



173
174
175
# File 'lib/semgrep_web_app/models/protos_secrets_v1_secrets_finding.rb', line 173

def self.nullables
  []
end

.optionalsObject

An array for optional fields



148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
# File 'lib/semgrep_web_app/models/protos_secrets_v1_secrets_finding.rb', line 148

def self.optionals
  %w[
    autotriage
    confidence
    created_at
    external_ticket
    finding_path
    finding_path_url
    historical_info
    id
    mode
    ref
    ref_url
    repository
    review_comments
    rule_hash_id
    severity
    status
    type
    updated_at
    validation_state
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



307
308
309
310
311
312
313
314
315
316
317
318
# File 'lib/semgrep_web_app/models/protos_secrets_v1_secrets_finding.rb', line 307

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} autotriage: #{@autotriage.inspect}, confidence: #{@confidence.inspect},"\
  " created_at: #{@created_at.inspect}, external_ticket: #{@external_ticket.inspect},"\
  " finding_path: #{@finding_path.inspect}, finding_path_url: #{@finding_path_url.inspect},"\
  " historical_info: #{@historical_info.inspect}, id: #{@id.inspect}, mode: #{@mode.inspect},"\
  " ref: #{@ref.inspect}, ref_url: #{@ref_url.inspect}, repository: #{@repository.inspect},"\
  " review_comments: #{@review_comments.inspect}, rule_hash_id: #{@rule_hash_id.inspect},"\
  " severity: #{@severity.inspect}, status: #{@status.inspect}, type: #{@type.inspect},"\
  " updated_at: #{@updated_at.inspect}, validation_state: #{@validation_state.inspect},"\
  " additional_properties: #{@additional_properties}>"
end

#to_custom_created_atObject



286
287
288
# File 'lib/semgrep_web_app/models/protos_secrets_v1_secrets_finding.rb', line 286

def to_custom_created_at
  DateTimeHelper.to_rfc3339(created_at)
end

#to_custom_updated_atObject



290
291
292
# File 'lib/semgrep_web_app/models/protos_secrets_v1_secrets_finding.rb', line 290

def to_custom_updated_at
  DateTimeHelper.to_rfc3339(updated_at)
end

#to_sObject

Provides a human-readable string representation of the object.



295
296
297
298
299
300
301
302
303
304
# File 'lib/semgrep_web_app/models/protos_secrets_v1_secrets_finding.rb', line 295

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} autotriage: #{@autotriage}, confidence: #{@confidence}, created_at:"\
  " #{@created_at}, external_ticket: #{@external_ticket}, finding_path: #{@finding_path},"\
  " finding_path_url: #{@finding_path_url}, historical_info: #{@historical_info}, id: #{@id},"\
  " mode: #{@mode}, ref: #{@ref}, ref_url: #{@ref_url}, repository: #{@repository},"\
  " review_comments: #{@review_comments}, rule_hash_id: #{@rule_hash_id}, severity:"\
  " #{@severity}, status: #{@status}, type: #{@type}, updated_at: #{@updated_at},"\
  " validation_state: #{@validation_state}, additional_properties: #{@additional_properties}>"
end