Class: SemgrepWebApp::ProtosSecretsV1HistoricalInfo

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

Overview

ProtosSecretsV1HistoricalInfo Model.

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(git_blob: SKIP, git_commit: SKIP, git_commit_timestamp: SKIP, additional_properties: nil) ⇒ ProtosSecretsV1HistoricalInfo

Returns a new instance of ProtosSecretsV1HistoricalInfo.



59
60
61
62
63
64
65
66
67
68
# File 'lib/semgrep_web_app/models/protos_secrets_v1_historical_info.rb', line 59

def initialize(git_blob: SKIP, git_commit: SKIP, git_commit_timestamp: SKIP,
               additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @git_blob = git_blob unless git_blob == SKIP
  @git_commit = git_commit unless git_commit == SKIP
  @git_commit_timestamp = git_commit_timestamp unless git_commit_timestamp == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#git_blobString

Git blob at which the finding is present. Sent in addition to the commit since some SCMs have permalinks which use the blob sha, so this information is useful when generating links back to the SCM.

Returns:

  • (String)


18
19
20
# File 'lib/semgrep_web_app/models/protos_secrets_v1_historical_info.rb', line 18

def git_blob
  @git_blob
end

#git_commitString

Git commit at which the finding is present. Used by "historical" scans, which scan non-HEAD commits in the git history. Relevant for finding, e.g., secrets which are buried in the git history which we wouldn't find at HEAD

Returns:

  • (String)


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

def git_commit
  @git_commit
end

#git_commit_timestampDateTime

Git commit at which the finding is present. Used by "historical" scans, which scan non-HEAD commits in the git history. Relevant for finding, e.g., secrets which are buried in the git history which we wouldn't find at HEAD

Returns:

  • (DateTime)


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

def git_commit_timestamp
  @git_commit_timestamp
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# File 'lib/semgrep_web_app/models/protos_secrets_v1_historical_info.rb', line 71

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  git_blob = hash.key?('gitBlob') ? hash['gitBlob'] : SKIP
  git_commit = hash.key?('gitCommit') ? hash['gitCommit'] : SKIP
  git_commit_timestamp = if hash.key?('gitCommitTimestamp')
                           (DateTimeHelper.from_rfc3339(hash['gitCommitTimestamp']) if hash['gitCommitTimestamp'])
                         else
                           SKIP
                         end

  # 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.
  ProtosSecretsV1HistoricalInfo.new(git_blob: git_blob,
                                    git_commit: git_commit,
                                    git_commit_timestamp: git_commit_timestamp,
                                    additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



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

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['git_blob'] = 'gitBlob'
  @_hash['git_commit'] = 'gitCommit'
  @_hash['git_commit_timestamp'] = 'gitCommitTimestamp'
  @_hash
end

.nullablesObject

An array for nullable fields



55
56
57
# File 'lib/semgrep_web_app/models/protos_secrets_v1_historical_info.rb', line 55

def self.nullables
  []
end

.optionalsObject

An array for optional fields



46
47
48
49
50
51
52
# File 'lib/semgrep_web_app/models/protos_secrets_v1_historical_info.rb', line 46

def self.optionals
  %w[
    git_blob
    git_commit
    git_commit_timestamp
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



109
110
111
112
113
114
# File 'lib/semgrep_web_app/models/protos_secrets_v1_historical_info.rb', line 109

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

#to_custom_git_commit_timestampObject



97
98
99
# File 'lib/semgrep_web_app/models/protos_secrets_v1_historical_info.rb', line 97

def to_custom_git_commit_timestamp
  DateTimeHelper.to_rfc3339(git_commit_timestamp)
end

#to_sObject

Provides a human-readable string representation of the object.



102
103
104
105
106
# File 'lib/semgrep_web_app/models/protos_secrets_v1_historical_info.rb', line 102

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