Class: Nexpose::Connection
- Inherits:
-
Object
- Object
- Nexpose::Connection
- Defined in:
- lib/nexpose-functions.rb
Instance Method Summary collapse
-
#getAsset(host) ⇒ Asset
Get an Asset object for the specified host IP.
-
#getScanTemplatesbyId ⇒ Hash
Get a Hash object containing pairs of scan template names/ids where the Hash key is the scan template id.
-
#getScanTemplatesbyName ⇒ Hash
Get a Hash object containing pairs of scan template names/ids where the Hash key is the scan template name.
-
#getSitesInfobyId ⇒ Hash
Get a Hash object containing pairs of site ids/names where the Hash key is the site id.
-
#getSitesInfobyName ⇒ Hash
Get a Hash object containing pairs of site names/ids where the Hash key is the site name.
-
#notScannedSince(days) ⇒ Array[Asset]
Get an array of Asset objects for hosts that have not been scanned in ‘X’ days.
-
#siteid_to_name(siteid) ⇒ String
Get the name for a site ID.
-
#sitename_to_id(sitename) ⇒ Fixnum
Get the ID for a site name.
-
#validate_engineid(engID) ⇒ Boolean
Check if an input is a valid engine id.
Instance Method Details
#getAsset(host) ⇒ Asset
Get an Asset object for the specified host IP.
114 115 116 |
# File 'lib/nexpose-functions.rb', line 114 def getAsset(host) return self.filter(Nexpose::Search::Field::ASSET, Nexpose::Search::Operator::IS, host) end |
#getScanTemplatesbyId ⇒ Hash
Get a Hash object containing pairs of scan template names/ids where the Hash key is the scan template id.
91 92 93 94 95 96 97 |
# File 'lib/nexpose-functions.rb', line 91 def getScanTemplatesbyId() templateinfo = {} self.list_scan_templates.each { |template| templateinfo[template.id] = template.name } return templateinfo end |
#getScanTemplatesbyName ⇒ Hash
Get a Hash object containing pairs of scan template names/ids where the Hash key is the scan template name.
102 103 104 105 106 107 108 |
# File 'lib/nexpose-functions.rb', line 102 def getScanTemplatesbyName() templateinfo = {} self.list_scan_templates.each { |template| templateinfo[template.name] = template.id } return templateinfo end |
#getSitesInfobyId ⇒ Hash
Get a Hash object containing pairs of site ids/names where the Hash key is the site id.
69 70 71 72 73 74 75 |
# File 'lib/nexpose-functions.rb', line 69 def getSitesInfobyId() sitesinfo = {} self.list_sites.each { |site| sitesinfo[site.id] = site.name } return sitesinfo end |
#getSitesInfobyName ⇒ Hash
Get a Hash object containing pairs of site names/ids where the Hash key is the site name.
80 81 82 83 84 85 86 |
# File 'lib/nexpose-functions.rb', line 80 def getSitesInfobyName() sitesinfo = {} self.list_sites.each { |site| sitesinfo[site.name] = site.id } return sitesinfo end |
#notScannedSince(days) ⇒ Array[Asset]
Get an array of Asset objects for hosts that have not been scanned in ‘X’ days.
122 123 124 |
# File 'lib/nexpose-functions.rb', line 122 def notScannedSince(days) return self.filter(Nexpose::Search::Field::SCAN_DATE, Nexpose::Search::Operator::EARLIER_THAN, days.to_i) end |
#siteid_to_name(siteid) ⇒ String
Get the name for a site ID.
58 59 60 61 62 63 64 |
# File 'lib/nexpose-functions.rb', line 58 def siteid_to_name(siteid) self.list_sites.each { |site| if site.id == siteid return site.name end } end |
#sitename_to_id(sitename) ⇒ Fixnum
Get the ID for a site name.
46 47 48 49 50 51 52 |
# File 'lib/nexpose-functions.rb', line 46 def sitename_to_id(sitename) self.list_sites.each { |site| if site.name == sitename return site.id end } end |
#validate_engineid(engID) ⇒ Boolean
Check if an input is a valid engine id.
32 33 34 35 36 37 38 39 40 |
# File 'lib/nexpose-functions.rb', line 32 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 |