Module: Nessus::Client::Scan

Included in:
Nessus::Client
Defined in:
lib/nessus/client/scan.rb

Overview

Author:

Instance Method Summary collapse

Instance Method Details

#scan_listArray<Hash>

GET /scan/list

Returns:

  • (Array<Hash>)

    an array of scan hashes



33
34
35
36
# File 'lib/nessus/client/scan.rb', line 33

def scan_list
  response = get '/scan/list'
  response['reply']['contents']
end

#scan_new(target, policy_id, scan_name, seq = nil, description = nil) ⇒ Hash

POST /scan/new

Parameters:

  • target (String)

    a string that contains the scan target(s)

  • policy_id (Fixnum)

    a numeric ID that references the policy to use

  • scan_name (String)

    the name to assign to this scan

  • seq (Fixnum) (defaults to: nil)

    a unique identifier for the specific request

Returns:

  • (Hash)

    the newly created scan object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/nessus/client/scan.rb', line 13

def scan_new(target, policy_id, scan_name, seq = nil, description = nil)
  payload = {
    :custom_targets => target,
    :policy_id => policy_id,
    :name => scan_name
  }
  payload[:seq] = seq if seq
  payload[:description] = description if description
  response = post '/scan/new', payload

  if response['error']
    raise Nessus::UnknownError, response['error']
  end

  response['reply']['contents'] # ['scan']
end

#scan_pause(scan_uuid) ⇒ Object

POST /scan/pause

Parameters:

  • scan_uuid (String)

    unique identifier for the scan

Returns:

  • status OK if successful



53
54
55
56
# File 'lib/nessus/client/scan.rb', line 53

def scan_pause(scan_uuid)
  response = post '/scan/pause', :scan_uuid => scan_uuid
  response['reply']['contents']
end

#scan_resume(scan_uuid) ⇒ Object

POST /scan/resume

Parameters:

  • scan_uuid (String)

    unique identifier for the scan

Returns:

  • status OK if successful



63
64
65
66
# File 'lib/nessus/client/scan.rb', line 63

def scan_resume(scan_uuid)
  response = post '/scan/resume', :scan_uuid => scan_uuid
  response['reply']['contents']
end

#scan_stop(scan_uuid) ⇒ Object

POST /scan/stop

Parameters:

  • scan_uuid (String)

    unique identifier for the scan

Returns:

  • status OK if successful



43
44
45
46
# File 'lib/nessus/client/scan.rb', line 43

def scan_stop(scan_uuid)
  response = post '/scan/stop', :scan_uuid => scan_uuid
  response['reply']['contents']
end

#scan_template_new(template_name, policy_id, target, seq = nil, start_time = nil, rrules = nil) ⇒ Object

POST /scan/template/new

Parameters:

  • scan (String)

    template name

  • scan (String)

    policy identifier

  • targets (String)

    for scan template

Returns:

  • status OK if successful



75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/nessus/client/scan.rb', line 75

def scan_template_new(template_name, policy_id, target, seq = nil, start_time = nil, rrules = nil)
  payload = {
    :template_name => template_name,
    :policy_id => policy_id,
    :target => target
  }
  payload[:seq] = seq if seq
  payload[:startTime] = start_time if start_time
  payload[:rRules] = rrules if rrules
  response = post '/scan/template/new', payload

  if response['reply']['status'].eql? 'ERROR'
    raise Nessus::UnknownError, response['reply']['contents']
  end

  response['reply']['contents'] # ['scan']
end