Class: Nexpose::CompletedAsset

Inherits:
Object
  • Object
show all
Defined in:
lib/nexpose/device.rb

Overview

Summary object of a completed asset for a scan.

Direct Known Subclasses

IncompleteAsset

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(&block) ⇒ CompletedAsset

Internal constructor to be called by #parse_json.



193
194
195
# File 'lib/nexpose/device.rb', line 193

def initialize(&block)
  instance_eval(&block) if block_given?
end

Instance Attribute Details

#durationObject (readonly)

Time it took to scan the asset, in milliseconds.



190
191
192
# File 'lib/nexpose/device.rb', line 190

def duration
  @duration
end

#host_nameObject (readonly)

Host name of the asset, if discovered.



181
182
183
# File 'lib/nexpose/device.rb', line 181

def host_name
  @host_name
end

#idObject (readonly)

Unique identifier of an asset.



177
178
179
# File 'lib/nexpose/device.rb', line 177

def id
  @id
end

#ipObject (readonly)

IP address of the asset.



179
180
181
# File 'lib/nexpose/device.rb', line 179

def ip
  @ip
end

#osObject (readonly)

Operating system fingerprint of the asset.



183
184
185
# File 'lib/nexpose/device.rb', line 183

def os
  @os
end

#statusObject (readonly)

Status of the asset on scan completion. One of :completed, :error, or :stopped.



188
189
190
# File 'lib/nexpose/device.rb', line 188

def status
  @status
end

#vulnsObject (readonly)

Number of vulnerabilities discovered on the asset.



185
186
187
# File 'lib/nexpose/device.rb', line 185

def vulns
  @vulns
end

Class Method Details

.parse_json(json) ⇒ Object

Internal method for converting a JSON representation into a CompletedScan object.



209
210
211
212
213
214
215
216
217
218
219
# File 'lib/nexpose/device.rb', line 209

def self.parse_json(json)
  new do
    @id = json['assetID'].to_i
    @ip = json['ipAddress']
    @host_name = json['hostName']
    @os = json['operatingSystem']
    @vulns = json['vulnerabilityCount']
    @status = json['scanStatusTranslation'].downcase.to_sym
    @duration = json['duration']
  end
end

Instance Method Details

#ip_addressObject

Convenience method for assessing “ip” as “ip_address”.



198
199
200
# File 'lib/nexpose/device.rb', line 198

def ip_address
  ip
end

#operating_systemObject

Convenience method for assessing “os” as “operating_system”.



203
204
205
# File 'lib/nexpose/device.rb', line 203

def operating_system
  os
end