Class: Nexpose::External::Asset

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

Overview

Object for importing assets from external sources into a Nexpose console. This exists primarily as a convenience for marshalling the data into the proper JSON format.

In order to successfully import an asset, it must contain at least one scannable identifier: IP address, fully qualified domain name, or NetBIOS name. This ensures that once an asset is imported to the console, it can be scanned.

Besides a scannable identifier, all other fields are optional.

Defined Under Namespace

Modules: HostType

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeAsset

Returns a new instance of Asset.



89
90
91
92
93
94
95
96
97
98
99
# File 'lib/nexpose/external.rb', line 89

def initialize
  @aliases            = []
  @software           = []
  @services           = []
  @attributes         = []
  @users              = []
  @groups             = []
  @files              = []
  @unique_identifiers = []
  @vulnerabilities    = []
end

Instance Attribute Details

#aliasesObject

A list of alternate identifiers of the asset. This can include additional IP addresses and host names.



65
66
67
# File 'lib/nexpose/external.rb', line 65

def aliases
  @aliases
end

#attributesObject

A list of key-value attributes associated with the asset.



85
86
87
# File 'lib/nexpose/external.rb', line 85

def attributes
  @attributes
end

#filesObject

Files and directories on the asset.



81
82
83
# File 'lib/nexpose/external.rb', line 81

def files
  @files
end

#fqdnObject

A fully qualified domain name of the asset.



56
57
58
# File 'lib/nexpose/external.rb', line 56

def fqdn
  @fqdn
end

#groupsObject

A list of group accounts on the asset.



79
80
81
# File 'lib/nexpose/external.rb', line 79

def groups
  @groups
end

#host_typeObject

The host type of the asset. One of: GUEST, HYPERVISOR, PHYSICAL, MOBILE.



62
63
64
# File 'lib/nexpose/external.rb', line 62

def host_type
  @host_type
end

#ipObject

IPv4 or IPv6 that is the primary identifier of the asset.



54
55
56
# File 'lib/nexpose/external.rb', line 54

def ip
  @ip
end

#macObject

The MAC address of the asset.



60
61
62
# File 'lib/nexpose/external.rb', line 60

def mac
  @mac
end

#net_biosObject

A NetBIOS name of the asset.



58
59
60
# File 'lib/nexpose/external.rb', line 58

def net_bios
  @net_bios
end

#osObject

The CPE for the operating system on the asset.



71
72
73
# File 'lib/nexpose/external.rb', line 71

def os
  @os
end

#scan_dateObject

The date the asset was scanned. If left blank, the current time will be used by the console. Use the ISO 8601 basic date-time format. For example: 20141211T100614.526Z



69
70
71
# File 'lib/nexpose/external.rb', line 69

def scan_date
  @scan_date
end

#servicesObject

A list of service endpoints on the asset.



75
76
77
# File 'lib/nexpose/external.rb', line 75

def services
  @services
end

#softwareObject

A list of CPEs identifying software installed on the asset.



73
74
75
# File 'lib/nexpose/external.rb', line 73

def software
  @software
end

#unique_identifiersObject

Unique system identifiers on the asset.



83
84
85
# File 'lib/nexpose/external.rb', line 83

def unique_identifiers
  @unique_identifiers
end

#usersObject

A list of user accounts on the asset.



77
78
79
# File 'lib/nexpose/external.rb', line 77

def users
  @users
end

#vulnerabilitiesObject

Asset-level vulnerabilities.



87
88
89
# File 'lib/nexpose/external.rb', line 87

def vulnerabilities
  @vulnerabilities
end

Instance Method Details

#to_hObject



105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# File 'lib/nexpose/external.rb', line 105

def to_h
  { ip: ip,
    fqdn: fqdn,
    net_bios: net_bios,
    mac: mac,
    host_type: host_type,
    aliases: aliases,
    scan_date: scan_date,
    os: os,
    software: software,
    services: services.map(&:to_h),
    users: users.map(&:to_h),
    groups: groups.map(&:to_h),
    files: files.map(&:to_h),
    unique_identifiers: unique_identifiers.map(&:to_h),
    vulnerabilities: vulnerabilities.map(&:to_h),
    attributes: Attributes.to_hash(attributes) }
end

#to_jsonObject



101
102
103
# File 'lib/nexpose/external.rb', line 101

def to_json
  JSON.generate(to_h)
end