Class: Nexpose::Connection
- Inherits:
-
Object
- Object
- Nexpose::Connection
- Defined in:
- lib\nexpose-functions.rb
Instance Method Summary (collapse)
-
- (Asset) getAsset(host)
Get an Asset object for the specified host IP.
-
- (Hash) getScanTemplatesbyId
Get a Hash object containing pairs of scan template names/ids where the Hash key is the scan template id.
-
- (Hash) getScanTemplatesbyName
Get a Hash object containing pairs of scan template names/ids where the Hash key is the scan template name.
-
- (Hash) getSitesInfobyId
Get a Hash object containing pairs of site ids/names where the Hash key is the site id.
-
- (Hash) getSitesInfobyName
Get a Hash object containing pairs of site names/ids where the Hash key is the site name.
-
- (Array[Asset]) notScannedSince(days)
Get an array of Asset objects for hosts that have not been scanned in 'X' days.
-
- (String) siteid_to_name(siteid)
Get the name for a site ID.
-
- (Fixnum) sitename_to_id(sitename)
Get the ID for a site name.
-
- (Boolean) validate_engineid(engID)
Check if an input is a valid engine id.
Instance Method Details
- (Asset) getAsset(host)
Get an Asset object for the specified host IP.
111 112 113 |
# File 'lib\nexpose-functions.rb', line 111 def getAsset(host) return self.filter(Nexpose::Search::Field::ASSET, Nexpose::Search::Operator::IS, host) end |
- (Hash) getScanTemplatesbyId
Get a Hash object containing pairs of scan template names/ids where the Hash key is the scan template id.
88 89 90 91 92 93 94 |
# File 'lib\nexpose-functions.rb', line 88 def getScanTemplatesbyId() templateinfo = {} self.list_scan_templates.each { |template| templateinfo[template.id] = template.name } return templateinfo end |
- (Hash) getScanTemplatesbyName
Get a Hash object containing pairs of scan template names/ids where the Hash key is the scan template name.
99 100 101 102 103 104 105 |
# File 'lib\nexpose-functions.rb', line 99 def getScanTemplatesbyName() templateinfo = {} self.list_scan_templates.each { |template| templateinfo[template.name] = template.id } return templateinfo end |
- (Hash) getSitesInfobyId
Get a Hash object containing pairs of site ids/names where the Hash key is the site id.
66 67 68 69 70 71 72 |
# File 'lib\nexpose-functions.rb', line 66 def getSitesInfobyId() sitesinfo = {} self.list_sites.each { |site| sitesinfo[site.id] = site.name } return sitesinfo end |
- (Hash) getSitesInfobyName
Get a Hash object containing pairs of site names/ids where the Hash key is the site name.
77 78 79 80 81 82 83 |
# File 'lib\nexpose-functions.rb', line 77 def getSitesInfobyName() sitesinfo = {} self.list_sites.each { |site| sitesinfo[site.name] = site.id } return sitesinfo end |
- (Array[Asset]) notScannedSince(days)
Get an array of Asset objects for hosts that have not been scanned in 'X' days.
119 120 121 |
# File 'lib\nexpose-functions.rb', line 119 def notScannedSince(days) return self.filter(Nexpose::Search::Field::SCAN_DATE, Nexpose::Search::Operator::EARLIER_THAN, days.to_i) end |
- (String) siteid_to_name(siteid)
Get the name for a site ID.
55 56 57 58 59 60 61 |
# File 'lib\nexpose-functions.rb', line 55 def siteid_to_name(siteid) self.list_sites.each { |site| if site.id == siteid return site.name end } end |
- (Fixnum) sitename_to_id(sitename)
Get the ID for a site name.
43 44 45 46 47 48 49 |
# File 'lib\nexpose-functions.rb', line 43 def sitename_to_id(sitename) self.list_sites.each { |site| if site.name == sitename return site.id end } end |
- (Boolean) validate_engineid(engID)
Check if an input is a valid engine id.
29 30 31 32 33 34 35 36 37 |
# File 'lib\nexpose-functions.rb', line 29 def validate_engineid(engID) # Create array of engine ids for validation engine_ids = [] for eng in self.list_engines do engine_ids << eng.id end return engine_ids.include?(engID.to_i) end |