Class: SemgrepWebApp::FoundDependency
- Defined in:
- lib/semgrep_web_app/models/found_dependency.rb
Overview
Information about the vulnerable package that was found in the codebase
Instance Attribute Summary collapse
-
#ecosystem ⇒ Ecosystem2
Ecosystem of the package.
-
#lockfile_line_url ⇒ String
URL to the specific line in the lockfile where the dependency is listed.
-
#package ⇒ String
Name of the package that contains the vulnerability.
-
#transitivity ⇒ Transitivity2
Indicates whether the dependency is direct or transitive.
-
#version ⇒ String
Version of the package that was found to be vulnerable.
Class Method Summary collapse
-
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
-
.names ⇒ Object
A mapping from model property names to API property names.
-
.nullables ⇒ Object
An array for nullable fields.
-
.optionals ⇒ Object
An array for optional fields.
-
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
Instance Method Summary collapse
-
#initialize(ecosystem: Ecosystem2::NO_PACKAGE_MANAGER, lockfile_line_url: SKIP, package: SKIP, transitivity: SKIP, version: SKIP, additional_properties: nil) ⇒ FoundDependency
constructor
A new instance of FoundDependency.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
-
#to_s ⇒ Object
Provides a human-readable string representation of the object.
Methods inherited from BaseModel
#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json
Constructor Details
#initialize(ecosystem: Ecosystem2::NO_PACKAGE_MANAGER, lockfile_line_url: SKIP, package: SKIP, transitivity: SKIP, version: SKIP, additional_properties: nil) ⇒ FoundDependency
Returns a new instance of FoundDependency.
59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/semgrep_web_app/models/found_dependency.rb', line 59 def initialize(ecosystem: Ecosystem2::NO_PACKAGE_MANAGER, lockfile_line_url: SKIP, package: SKIP, transitivity: SKIP, version: SKIP, additional_properties: nil) # Add additional model properties to the instance additional_properties = {} if additional_properties.nil? @ecosystem = ecosystem unless ecosystem == SKIP @lockfile_line_url = lockfile_line_url unless lockfile_line_url == SKIP @package = package unless package == SKIP @transitivity = transitivity unless transitivity == SKIP @version = version unless version == SKIP @additional_properties = additional_properties end |
Instance Attribute Details
#ecosystem ⇒ Ecosystem2
Ecosystem of the package
14 15 16 |
# File 'lib/semgrep_web_app/models/found_dependency.rb', line 14 def ecosystem @ecosystem end |
#lockfile_line_url ⇒ String
URL to the specific line in the lockfile where the dependency is listed
18 19 20 |
# File 'lib/semgrep_web_app/models/found_dependency.rb', line 18 def lockfile_line_url @lockfile_line_url end |
#package ⇒ String
Name of the package that contains the vulnerability
22 23 24 |
# File 'lib/semgrep_web_app/models/found_dependency.rb', line 22 def package @package end |
#transitivity ⇒ Transitivity2
Indicates whether the dependency is direct or transitive
26 27 28 |
# File 'lib/semgrep_web_app/models/found_dependency.rb', line 26 def transitivity @transitivity end |
#version ⇒ String
Version of the package that was found to be vulnerable
30 31 32 |
# File 'lib/semgrep_web_app/models/found_dependency.rb', line 30 def version @version end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/semgrep_web_app/models/found_dependency.rb', line 74 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. ecosystem = hash['ecosystem'] ||= Ecosystem2::NO_PACKAGE_MANAGER lockfile_line_url = hash.key?('lockfile_line_url') ? hash['lockfile_line_url'] : SKIP package = hash.key?('package') ? hash['package'] : SKIP transitivity = hash.key?('transitivity') ? hash['transitivity'] : SKIP version = hash.key?('version') ? hash['version'] : 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. FoundDependency.new(ecosystem: ecosystem, lockfile_line_url: lockfile_line_url, package: package, transitivity: transitivity, version: version, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
33 34 35 36 37 38 39 40 41 |
# File 'lib/semgrep_web_app/models/found_dependency.rb', line 33 def self.names @_hash = {} if @_hash.nil? @_hash['ecosystem'] = 'ecosystem' @_hash['lockfile_line_url'] = 'lockfile_line_url' @_hash['package'] = 'package' @_hash['transitivity'] = 'transitivity' @_hash['version'] = 'version' @_hash end |
.nullables ⇒ Object
An array for nullable fields
55 56 57 |
# File 'lib/semgrep_web_app/models/found_dependency.rb', line 55 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
44 45 46 47 48 49 50 51 52 |
# File 'lib/semgrep_web_app/models/found_dependency.rb', line 44 def self.optionals %w[ ecosystem lockfile_line_url package transitivity version ] end |
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
103 104 105 106 107 108 109 |
# File 'lib/semgrep_web_app/models/found_dependency.rb', line 103 def self.validate(value) return true if value.instance_of? self return false unless value.instance_of? Hash true end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
120 121 122 123 124 125 126 |
# File 'lib/semgrep_web_app/models/found_dependency.rb', line 120 def inspect class_name = self.class.name.split('::').last "<#{class_name} ecosystem: #{@ecosystem.inspect}, lockfile_line_url:"\ " #{@lockfile_line_url.inspect}, package: #{@package.inspect}, transitivity:"\ " #{@transitivity.inspect}, version: #{@version.inspect}, additional_properties:"\ " #{@additional_properties}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
112 113 114 115 116 117 |
# File 'lib/semgrep_web_app/models/found_dependency.rb', line 112 def to_s class_name = self.class.name.split('::').last "<#{class_name} ecosystem: #{@ecosystem}, lockfile_line_url: #{@lockfile_line_url},"\ " package: #{@package}, transitivity: #{@transitivity}, version: #{@version},"\ " additional_properties: #{@additional_properties}>" end |