class Nexpose::Connection

Public Instance Methods

getAsset(host) click to toggle source

Get an Asset object for the specified host IP.

@param host [String] the hostname to get an Asset object for. @return [Asset] the Asset object for the host.

# File lib/nexpose-functions.rb, line 114
def getAsset(host)
    return self.filter(Nexpose::Search::Field::ASSET, Nexpose::Search::Operator::IS, host)
end
getScanTemplatesbyId() click to toggle source

Get a Hash object containing pairs of scan template names/ids where the Hash key is the scan template id.

@return [Hash] object with scan template ids as the keys and scan template names as the values.

# 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() click to toggle source

Get a Hash object containing pairs of scan template names/ids where the Hash key is the scan template name.

@return [Hash] object with scan template names as the keys and scan template ids as the values.

# 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() click to toggle source

Get a Hash object containing pairs of site ids/names where the Hash key is the site id.

@return [Hash] object with site ids as the keys and site names as the values.

# File lib/nexpose-functions.rb, line 69
def getSitesInfobyId()
    sitesinfo = {}
    self.list_sites.each { |site|
        sitesinfo[site.id] = site.name
    }
    return sitesinfo
end
getSitesInfobyName() click to toggle source

Get a Hash object containing pairs of site names/ids where the Hash key is the site name.

@return [Hash] object with site names as the keys and site ids as the values.

# 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) click to toggle source

Get an array of Asset objects for hosts that have not been scanned in ‘X’ days.

@param days [Fixnum] the number of days back to check for unscanned hosts. @return [Array] array of Asset objects for the hosts.

# 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) click to toggle source

Get the name for a site ID.

@param siteid [Fixnum] a site id to look up. @return [String] the name of the site.

# 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) click to toggle source

Get the ID for a site name.

@param sitename [String] the site name to look up. @return [Fixnum] the id for the site name.

# 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) click to toggle source

Check if an input is a valid engine id.

@param engID [Fixnum] an id to check against the list of valid engine ids. @return [Boolean] true if engID is valid.

# 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