Module: Resource::Scans
- Included in:
- NessusClient
- Defined in:
- lib/modules/scans.rb
Overview
Namespace for Scans resource.
Instance Method Summary collapse
-
#get_scan_by_name(scan_name, folder_id = nil) ⇒ String?
Get a scan by its name.
-
#launch(scan_id, targets = []) ⇒ JSON
Lauch a scan by its id.
-
#launch_by_name(scan_name, targets = []) ⇒ JSON
Lauch a scan by its name.
-
#list_scans(folder_id = nil) ⇒ JSON
(also: #scans)
List scans from the resource.
-
#scan_details(scan_id, history_id = nil) ⇒ JSON
See details of a scan.
Instance Method Details
#get_scan_by_name(scan_name, folder_id = nil) ⇒ String?
Get a scan by its name
45 46 47 48 49 |
# File 'lib/modules/scans.rb', line 45 def get_scan_by_name(scan_name, folder_id = nil) list_scans(folder_id)['scans'].each do |scan| return scan['id'] if scan['name'] == scan_name end end |
#launch(scan_id, targets = []) ⇒ JSON
Lauch a scan by its id
27 28 29 30 |
# File 'lib/modules/scans.rb', line 27 def launch(scan_id, targets = []) payload = { alt_targets: targets } unless targets.empty? request.post({ path: "/scans/#{scan_id}/launch", payload: payload, headers: headers }) end |
#launch_by_name(scan_name, targets = []) ⇒ JSON
Lauch a scan by its name
36 37 38 39 |
# File 'lib/modules/scans.rb', line 36 def launch_by_name(scan_name, targets = []) scan_id = get_scan_by_name(scan_name) launch(scan_id, targets) end |
#list_scans(folder_id = nil) ⇒ JSON Also known as: scans
List scans from the resource.
8 9 10 11 |
# File 'lib/modules/scans.rb', line 8 def list_scans(folder_id = nil) query = folder_id.nil? ? nil : { 'folder_id' => folder_id } request.get({ path: '/scans', query: query, headers: headers }) end |
#scan_details(scan_id, history_id = nil) ⇒ JSON
See details of a scan.
18 19 20 21 |
# File 'lib/modules/scans.rb', line 18 def scan_details(scan_id, history_id = nil) query = history_id.nil? ? nil : { 'history_id' => history_id } request.get({ path: "/scans/#{scan_id}", query: query, headers: headers }) end |