Class: SemgrepWebApp::ProtosScaV1DependencyFilter

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

Overview

Object to provide dependency details to filter by.

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(ecosystem: SKIP, license: SKIP, license_policy_settings: SKIP, lockfile_path: SKIP, name: SKIP, package_filters: SKIP, repository_id: SKIP, transitivity: SKIP, version: SKIP, additional_properties: nil) ⇒ ProtosScaV1DependencyFilter

Returns a new instance of ProtosScaV1DependencyFilter.



114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
# File 'lib/semgrep_web_app/models/protos_sca_v1_dependency_filter.rb', line 114

def initialize(ecosystem: SKIP, license: SKIP,
               license_policy_settings: SKIP, lockfile_path: SKIP,
               name: SKIP, package_filters: SKIP, repository_id: 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
  @license = license unless license == SKIP
  @license_policy_settings = license_policy_settings unless license_policy_settings == SKIP
  @lockfile_path = lockfile_path unless lockfile_path == SKIP
  @name = name unless name == SKIP
  @package_filters = package_filters unless package_filters == SKIP
  @repository_id = repository_id unless repository_id == SKIP
  @transitivity = transitivity unless transitivity == SKIP
  @version = version unless version == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#ecosystemEcosystem

Filter by ecosystem (e.g. npm, pypi, etc).

value description
no_package_manager
npm
pypi
gomod
cargo
maven
gem
composer
nuget
pub
swiftpm
hex
cocoapods
mix
opam

Returns:



31
32
33
# File 'lib/semgrep_web_app/models/protos_sca_v1_dependency_filter.rb', line 31

def ecosystem
  @ecosystem
end

#licenseArray[String]

Filter by license (e.g. MIT).

Returns:

  • (Array[String])


35
36
37
# File 'lib/semgrep_web_app/models/protos_sca_v1_dependency_filter.rb', line 35

def license
  @license
end

#license_policy_settingsLicensePolicySettings

Filter by license policy setting outcome.

value description
LICENSE_POLICY_SETTING_ALLOW
LICENSE_POLICY_SETTING_COMMENT
LICENSE_POLICY_SETTING_BLOCK


44
45
46
# File 'lib/semgrep_web_app/models/protos_sca_v1_dependency_filter.rb', line 44

def license_policy_settings
  @license_policy_settings
end

#lockfile_pathString

Filter by path to the lockfile (e.g. foo/bar/package-lock.json).

Returns:

  • (String)


48
49
50
# File 'lib/semgrep_web_app/models/protos_sca_v1_dependency_filter.rb', line 48

def lockfile_path
  @lockfile_path
end

#nameString

Deprecated - use package_filters instead. Filter by dependency name (e.g. lodash).

Returns:

  • (String)


53
54
55
# File 'lib/semgrep_web_app/models/protos_sca_v1_dependency_filter.rb', line 53

def name
  @name
end

#package_filtersArray[ProtosScaV1PackageFilter]

Multiple package filters with exact name matching and version bounds.

Returns:



57
58
59
# File 'lib/semgrep_web_app/models/protos_sca_v1_dependency_filter.rb', line 57

def package_filters
  @package_filters
end

#repository_idArray[Integer]

Repository IDs (numeric) to filter by. Omit if the endpoint has Repository ID as a path parameter. Use Projects endpoints to retrieve Repository IDs.

Returns:

  • (Array[Integer])


63
64
65
# File 'lib/semgrep_web_app/models/protos_sca_v1_dependency_filter.rb', line 63

def repository_id
  @repository_id
end

#transitivityTransitivity

Filter by transitivity.

value description
UNKNOWN_TRANSITIVITY
TRANSITIVE
DIRECT

Returns:



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

def transitivity
  @transitivity
end

#versionString

Deprecated - use package_filters instead. Filter by dependency version (e.g. 1.0.1).

Returns:

  • (String)


77
78
79
# File 'lib/semgrep_web_app/models/protos_sca_v1_dependency_filter.rb', line 77

def version
  @version
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
# File 'lib/semgrep_web_app/models/protos_sca_v1_dependency_filter.rb', line 135

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  ecosystem = hash.key?('ecosystem') ? hash['ecosystem'] : SKIP
  license = hash.key?('license') ? hash['license'] : SKIP
  license_policy_settings =
    hash.key?('licensePolicySettings') ? hash['licensePolicySettings'] : SKIP
  lockfile_path = hash.key?('lockfilePath') ? hash['lockfilePath'] : SKIP
  name = hash.key?('name') ? hash['name'] : SKIP
  # Parameter is an array, so we need to iterate through it
  package_filters = nil
  unless hash['packageFilters'].nil?
    package_filters = []
    hash['packageFilters'].each do |structure|
      package_filters << (ProtosScaV1PackageFilter.from_hash(structure) if structure)
    end
  end

  package_filters = SKIP unless hash.key?('packageFilters')
  repository_id = hash.key?('repositoryId') ? hash['repositoryId'] : 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.
  ProtosScaV1DependencyFilter.new(ecosystem: ecosystem,
                                  license: license,
                                  license_policy_settings: license_policy_settings,
                                  lockfile_path: lockfile_path,
                                  name: name,
                                  package_filters: package_filters,
                                  repository_id: repository_id,
                                  transitivity: transitivity,
                                  version: version,
                                  additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



80
81
82
83
84
85
86
87
88
89
90
91
92
# File 'lib/semgrep_web_app/models/protos_sca_v1_dependency_filter.rb', line 80

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['ecosystem'] = 'ecosystem'
  @_hash['license'] = 'license'
  @_hash['license_policy_settings'] = 'licensePolicySettings'
  @_hash['lockfile_path'] = 'lockfilePath'
  @_hash['name'] = 'name'
  @_hash['package_filters'] = 'packageFilters'
  @_hash['repository_id'] = 'repositoryId'
  @_hash['transitivity'] = 'transitivity'
  @_hash['version'] = 'version'
  @_hash
end

.nullablesObject

An array for nullable fields



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

def self.nullables
  []
end

.optionalsObject

An array for optional fields



95
96
97
98
99
100
101
102
103
104
105
106
107
# File 'lib/semgrep_web_app/models/protos_sca_v1_dependency_filter.rb', line 95

def self.optionals
  %w[
    ecosystem
    license
    license_policy_settings
    lockfile_path
    name
    package_filters
    repository_id
    transitivity
    version
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



189
190
191
192
193
194
195
196
197
# File 'lib/semgrep_web_app/models/protos_sca_v1_dependency_filter.rb', line 189

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} ecosystem: #{@ecosystem.inspect}, license: #{@license.inspect},"\
  " license_policy_settings: #{@license_policy_settings.inspect}, lockfile_path:"\
  " #{@lockfile_path.inspect}, name: #{@name.inspect}, package_filters:"\
  " #{@package_filters.inspect}, repository_id: #{@repository_id.inspect}, transitivity:"\
  " #{@transitivity.inspect}, version: #{@version.inspect}, additional_properties:"\
  " #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



180
181
182
183
184
185
186
# File 'lib/semgrep_web_app/models/protos_sca_v1_dependency_filter.rb', line 180

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} ecosystem: #{@ecosystem}, license: #{@license}, license_policy_settings:"\
  " #{@license_policy_settings}, lockfile_path: #{@lockfile_path}, name: #{@name},"\
  " package_filters: #{@package_filters}, repository_id: #{@repository_id}, transitivity:"\
  " #{@transitivity}, version: #{@version}, additional_properties: #{@additional_properties}>"
end