class NessusAPI::Scan

Public Class Methods

list(session = Session.current) click to toggle source
# File lib/nessus_api/scan.rb, line 50
def self.list(session = Session.current)
  # Returns all currently running scan jobs.
  session.scanList
end
new(target, scan_name, policy, session=Session.current) click to toggle source

The class that handles API calls for individuals scans.

# File lib/nessus_api/scan.rb, line 9
def initialize(target, scan_name, policy, session=Session.current)
  # Creates a new scan on the Nessus
  # installation using the given params.
  @target = target
  @name = scan_name
  @policy = policy
  @session = session
  @uuid = @session.get('scan/new', {'target' => @target,
    'scan_name' => @name, 'policy_id' => @policy}).at_css("uuid").text
end

Public Instance Methods

changeStatus(path) click to toggle source
# File lib/nessus_api/scan.rb, line 35
def changeStatus(path)
  # Helper function for stop, pause
  # and resume.
  if @session.get("scan/#{path}",
                  {'scan_uuid' => @uuid}).css('status').text == 'OK'
    return true
  else
    return false
  end
end
pause() click to toggle source
# File lib/nessus_api/scan.rb, line 24
def pause
  # Pauses the current scan.
  changeStatus('pause')
end
resume() click to toggle source
# File lib/nessus_api/scan.rb, line 29
def resume
  # Resumes the current scan from being
  # paused.
  changeStatus('resume')
end
stop() click to toggle source
# File lib/nessus_api/scan.rb, line 20
def stop
  changeStatus('stop')
end
uuid() click to toggle source
# File lib/nessus_api/scan.rb, line 46
def uuid
  @uuid
end