class OCI::VulnerabilityScanning::Models::HostVulnerability

A vulnerability found in one or more host scans in a compartment

Constants

LIFECYCLE_STATE_ENUM
SEVERITY_ENUM
STATE_ENUM
VULNERABILITY_TYPE_ENUM

Attributes

authentication[RW]

Mechanism used for scan authentication @return [String]

compartment_id[RW]

[Required] Compartment ID of the vulnerability. Vulnerabilities with identical CVEs can exist in different compartments, based on scan target location @return [String]

cve_details[RW]

@return [OCI::VulnerabilityScanning::Models::CveDetails]

cve_reference[RW]

Reference to MITRE CVE ID @return [String]

host_count[RW]

[Required] Number of scanned hosts in this compartment whose scan results currently report this vulnerability @return [Integer]

id[RW]

[Required] ID of the vulnerability @return [String]

lifecycle_state[R]

The current state of the resource. @return [String]

name[RW]

[Required] Vulnerability name @return [String]

severity[R]

[Required] Severity of the vulnerability @return [String]

state[R]

State of the vulnerability @return [String]

time_first_detected[RW]

[Required] Date of scan result that first reported the vulnerability @return [DateTime]

time_last_detected[RW]

[Required] Date of scan result that most recently reported the vulnerability @return [DateTime]

vulnerability_type[R]

[Required] Specifies the type of Vulnerability @return [String]

Public Class Methods

attribute_map() click to toggle source

Attribute mapping from ruby-style variable name to JSON key.

# File lib/oci/vulnerability_scanning/models/host_vulnerability.rb, line 95
def self.attribute_map
  {
    # rubocop:disable Style/SymbolLiteral
    'id': :'id',
    'compartment_id': :'compartmentId',
    'authentication': :'authentication',
    'cve_reference': :'cveReference',
    'cve_details': :'cveDetails',
    'severity': :'severity',
    'state': :'state',
    'name': :'name',
    'time_last_detected': :'timeLastDetected',
    'time_first_detected': :'timeFirstDetected',
    'host_count': :'hostCount',
    'vulnerability_type': :'vulnerabilityType',
    'lifecycle_state': :'lifecycleState'
    # rubocop:enable Style/SymbolLiteral
  }
end
new(attributes = {}) click to toggle source

Initializes the object @param [Hash] attributes Model attributes in the form of hash @option attributes [String] :id The value to assign to the {#id} property @option attributes [String] :compartment_id The value to assign to the {#compartment_id} property @option attributes [String] :authentication The value to assign to the {#authentication} property @option attributes [String] :cve_reference The value to assign to the {#cve_reference} property @option attributes [OCI::VulnerabilityScanning::Models::CveDetails] :cve_details The value to assign to the {#cve_details} property @option attributes [String] :severity The value to assign to the {#severity} property @option attributes [String] :state The value to assign to the {#state} property @option attributes [String] :name The value to assign to the {#name} property @option attributes [DateTime] :time_last_detected The value to assign to the {#time_last_detected} property @option attributes [DateTime] :time_first_detected The value to assign to the {#time_first_detected} property @option attributes [Integer] :host_count The value to assign to the {#host_count} property @option attributes [String] :vulnerability_type The value to assign to the {#vulnerability_type} property @option attributes [String] :lifecycle_state The value to assign to the {#lifecycle_state} property

# File lib/oci/vulnerability_scanning/models/host_vulnerability.rb, line 155
def initialize(attributes = {})
  return unless attributes.is_a?(Hash)

  # convert string to symbol for hash key
  attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }

  self.id = attributes[:'id'] if attributes[:'id']

  self.compartment_id = attributes[:'compartmentId'] if attributes[:'compartmentId']

  raise 'You cannot provide both :compartmentId and :compartment_id' if attributes.key?(:'compartmentId') && attributes.key?(:'compartment_id')

  self.compartment_id = attributes[:'compartment_id'] if attributes[:'compartment_id']

  self.authentication = attributes[:'authentication'] if attributes[:'authentication']

  self.cve_reference = attributes[:'cveReference'] if attributes[:'cveReference']

  raise 'You cannot provide both :cveReference and :cve_reference' if attributes.key?(:'cveReference') && attributes.key?(:'cve_reference')

  self.cve_reference = attributes[:'cve_reference'] if attributes[:'cve_reference']

  self.cve_details = attributes[:'cveDetails'] if attributes[:'cveDetails']

  raise 'You cannot provide both :cveDetails and :cve_details' if attributes.key?(:'cveDetails') && attributes.key?(:'cve_details')

  self.cve_details = attributes[:'cve_details'] if attributes[:'cve_details']

  self.severity = attributes[:'severity'] if attributes[:'severity']

  self.state = attributes[:'state'] if attributes[:'state']

  self.name = attributes[:'name'] if attributes[:'name']

  self.time_last_detected = attributes[:'timeLastDetected'] if attributes[:'timeLastDetected']

  raise 'You cannot provide both :timeLastDetected and :time_last_detected' if attributes.key?(:'timeLastDetected') && attributes.key?(:'time_last_detected')

  self.time_last_detected = attributes[:'time_last_detected'] if attributes[:'time_last_detected']

  self.time_first_detected = attributes[:'timeFirstDetected'] if attributes[:'timeFirstDetected']

  raise 'You cannot provide both :timeFirstDetected and :time_first_detected' if attributes.key?(:'timeFirstDetected') && attributes.key?(:'time_first_detected')

  self.time_first_detected = attributes[:'time_first_detected'] if attributes[:'time_first_detected']

  self.host_count = attributes[:'hostCount'] if attributes[:'hostCount']

  raise 'You cannot provide both :hostCount and :host_count' if attributes.key?(:'hostCount') && attributes.key?(:'host_count')

  self.host_count = attributes[:'host_count'] if attributes[:'host_count']

  self.vulnerability_type = attributes[:'vulnerabilityType'] if attributes[:'vulnerabilityType']

  raise 'You cannot provide both :vulnerabilityType and :vulnerability_type' if attributes.key?(:'vulnerabilityType') && attributes.key?(:'vulnerability_type')

  self.vulnerability_type = attributes[:'vulnerability_type'] if attributes[:'vulnerability_type']

  self.lifecycle_state = attributes[:'lifecycleState'] if attributes[:'lifecycleState']

  raise 'You cannot provide both :lifecycleState and :lifecycle_state' if attributes.key?(:'lifecycleState') && attributes.key?(:'lifecycle_state')

  self.lifecycle_state = attributes[:'lifecycle_state'] if attributes[:'lifecycle_state']
end
swagger_types() click to toggle source

Attribute type mapping.

# File lib/oci/vulnerability_scanning/models/host_vulnerability.rb, line 116
def self.swagger_types
  {
    # rubocop:disable Style/SymbolLiteral
    'id': :'String',
    'compartment_id': :'String',
    'authentication': :'String',
    'cve_reference': :'String',
    'cve_details': :'OCI::VulnerabilityScanning::Models::CveDetails',
    'severity': :'String',
    'state': :'String',
    'name': :'String',
    'time_last_detected': :'DateTime',
    'time_first_detected': :'DateTime',
    'host_count': :'Integer',
    'vulnerability_type': :'String',
    'lifecycle_state': :'String'
    # rubocop:enable Style/SymbolLiteral
  }
end

Public Instance Methods

==(other) click to toggle source

Checks equality by comparing each attribute. @param [Object] other the other object to be compared

# File lib/oci/vulnerability_scanning/models/host_vulnerability.rb, line 279
def ==(other)
  return true if equal?(other)

  self.class == other.class &&
    id == other.id &&
    compartment_id == other.compartment_id &&
    authentication == other.authentication &&
    cve_reference == other.cve_reference &&
    cve_details == other.cve_details &&
    severity == other.severity &&
    state == other.state &&
    name == other.name &&
    time_last_detected == other.time_last_detected &&
    time_first_detected == other.time_first_detected &&
    host_count == other.host_count &&
    vulnerability_type == other.vulnerability_type &&
    lifecycle_state == other.lifecycle_state
end
build_from_hash(attributes) click to toggle source

Builds the object from hash @param [Hash] attributes Model attributes in the form of hash @return [Object] Returns the model itself

# File lib/oci/vulnerability_scanning/models/host_vulnerability.rb, line 321
def build_from_hash(attributes)
  return nil unless attributes.is_a?(Hash)

  self.class.swagger_types.each_pair do |key, type|
    if type =~ /^Array<(.*)>/i
      # check to ensure the input is an array given that the the attribute
      # is documented as an array but the input is not
      if attributes[self.class.attribute_map[key]].is_a?(Array)
        public_method("#{key}=").call(
          attributes[self.class.attribute_map[key]]
            .map { |v| OCI::Internal::Util.convert_to_type(Regexp.last_match(1), v) }
        )
      end
    elsif !attributes[self.class.attribute_map[key]].nil?
      public_method("#{key}=").call(
        OCI::Internal::Util.convert_to_type(type, attributes[self.class.attribute_map[key]])
      )
    end
    # or else data not found in attributes(hash), not an issue as the data can be optional
  end

  self
end
eql?(other) click to toggle source

@see the `==` method @param [Object] other the other object to be compared

# File lib/oci/vulnerability_scanning/models/host_vulnerability.rb, line 301
def eql?(other)
  self == other
end
hash() click to toggle source

Calculates hash code according to all attributes. @return [Fixnum] Hash code

# File lib/oci/vulnerability_scanning/models/host_vulnerability.rb, line 310
def hash
  [id, compartment_id, authentication, cve_reference, cve_details, severity, state, name, time_last_detected, time_first_detected, host_count, vulnerability_type, lifecycle_state].hash
end
lifecycle_state=(lifecycle_state) click to toggle source

Custom attribute writer method checking allowed values (enum). @param [Object] lifecycle_state Object to be assigned

# File lib/oci/vulnerability_scanning/models/host_vulnerability.rb, line 263
def lifecycle_state=(lifecycle_state)
  # rubocop:disable Style/ConditionalAssignment
  if lifecycle_state && !LIFECYCLE_STATE_ENUM.include?(lifecycle_state)
    OCI.logger.debug("Unknown value for 'lifecycle_state' [" + lifecycle_state + "]. Mapping to 'LIFECYCLE_STATE_UNKNOWN_ENUM_VALUE'") if OCI.logger
    @lifecycle_state = LIFECYCLE_STATE_UNKNOWN_ENUM_VALUE
  else
    @lifecycle_state = lifecycle_state
  end
  # rubocop:enable Style/ConditionalAssignment
end
severity=(severity) click to toggle source

Custom attribute writer method checking allowed values (enum). @param [Object] severity Object to be assigned

# File lib/oci/vulnerability_scanning/models/host_vulnerability.rb, line 224
def severity=(severity)
  # rubocop:disable Style/ConditionalAssignment
  if severity && !SEVERITY_ENUM.include?(severity)
    OCI.logger.debug("Unknown value for 'severity' [" + severity + "]. Mapping to 'SEVERITY_UNKNOWN_ENUM_VALUE'") if OCI.logger
    @severity = SEVERITY_UNKNOWN_ENUM_VALUE
  else
    @severity = severity
  end
  # rubocop:enable Style/ConditionalAssignment
end
state=(state) click to toggle source

Custom attribute writer method checking allowed values (enum). @param [Object] state Object to be assigned

# File lib/oci/vulnerability_scanning/models/host_vulnerability.rb, line 237
def state=(state)
  # rubocop:disable Style/ConditionalAssignment
  if state && !STATE_ENUM.include?(state)
    OCI.logger.debug("Unknown value for 'state' [" + state + "]. Mapping to 'STATE_UNKNOWN_ENUM_VALUE'") if OCI.logger
    @state = STATE_UNKNOWN_ENUM_VALUE
  else
    @state = state
  end
  # rubocop:enable Style/ConditionalAssignment
end
to_hash() click to toggle source

Returns the object in the form of hash @return [Hash] Returns the object in the form of hash

# File lib/oci/vulnerability_scanning/models/host_vulnerability.rb, line 354
def to_hash
  hash = {}
  self.class.attribute_map.each_pair do |attr, param|
    value = public_method(attr).call
    next if value.nil? && !instance_variable_defined?("@#{attr}")

    hash[param] = _to_hash(value)
  end
  hash
end
to_s() click to toggle source

Returns the string representation of the object @return [String] String presentation of the object

# File lib/oci/vulnerability_scanning/models/host_vulnerability.rb, line 348
def to_s
  to_hash.to_s
end
vulnerability_type=(vulnerability_type) click to toggle source

Custom attribute writer method checking allowed values (enum). @param [Object] vulnerability_type Object to be assigned

# File lib/oci/vulnerability_scanning/models/host_vulnerability.rb, line 250
def vulnerability_type=(vulnerability_type)
  # rubocop:disable Style/ConditionalAssignment
  if vulnerability_type && !VULNERABILITY_TYPE_ENUM.include?(vulnerability_type)
    OCI.logger.debug("Unknown value for 'vulnerability_type' [" + vulnerability_type + "]. Mapping to 'VULNERABILITY_TYPE_UNKNOWN_ENUM_VALUE'") if OCI.logger
    @vulnerability_type = VULNERABILITY_TYPE_UNKNOWN_ENUM_VALUE
  else
    @vulnerability_type = vulnerability_type
  end
  # rubocop:enable Style/ConditionalAssignment
end

Private Instance Methods

_to_hash(value) click to toggle source

Outputs non-array value in the form of hash For object, use to_hash. Otherwise, just return the value @param [Object] value Any valid value @return [Hash] Returns the value in the form of hash

# File lib/oci/vulnerability_scanning/models/host_vulnerability.rb, line 371
def _to_hash(value)
  if value.is_a?(Array)
    value.compact.map { |v| _to_hash(v) }
  elsif value.is_a?(Hash)
    {}.tap do |hash|
      value.each { |k, v| hash[k] = _to_hash(v) }
    end
  elsif value.respond_to? :to_hash
    value.to_hash
  else
    value
  end
end