Nessus6 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 124565e9d918310372e96f46ecc233111eab7d20
4
- data.tar.gz: 25d9dd43bece92dd2637ec503e92749a996fd4b3
3
+ metadata.gz: 6f14c908922f0bd214211cd4d1c2167c7ac92d97
4
+ data.tar.gz: b71dffb41a264ed5c8325240d035dfde3e3fcab4
5
5
  SHA512:
6
- metadata.gz: 3802310a4764b6ea9b95f38604be99a7ee328ad03914f8dd76b91f09cb49eaaa9633a65e69112801cb68361b13de42d4c7ab8ff38cab27fb1d29a45c5c1e4ab8
7
- data.tar.gz: dc72bfe6665b1bdce87686255203fdf42f3478e3ad2a3ddded5e70df801fff84739bf8edc97ef6ca3ce3e1168ee311e90e40d986303a7dedfd412f9296f887fe
6
+ metadata.gz: 8568bee75ce076be518a1c9b9a53e5272bd7c420bb6f81bc30ad68ee11e4944f213d7672df249fe6637695de11ae1d4e69767529e1307eb303b034ead18fd178
7
+ data.tar.gz: bf5eac09145badcf7db00a8f1d669dbf3ca20c4d3ef1a6f89b8a5a90b9a0fd3bf6af5801b5e9148b0684b6407d113119b5bf32e049c112217997b613e09e92c3
@@ -6,6 +6,25 @@ require 'logger'
6
6
  require 'sqlite3'
7
7
  require 'json'
8
8
 
9
+ # The Nessus6 module is used to interact with Nessus version 6 servers.
10
+ module Nessus6
11
+ # The Scans class is for interacting with Nessus6 scans.
12
+ # https://localhost:8834/api#/resources/scans
13
+ class Scan
14
+ def download(scan_id, file_id, write_path = nil)
15
+ response = @client.get "scans/#{scan_id}/export/#{file_id}/download"
16
+ ::File.open(write_path, 'w+') { |file| file.write response.body } unless write_path.nil?
17
+ begin
18
+ hash_response = verify response,
19
+ not_found: 'The scan or file does not exist.'
20
+ rescue
21
+ hash_response = nil
22
+ end
23
+ hash_response
24
+ end
25
+ end
26
+ end
27
+
9
28
  # Global variables for the script / binary
10
29
  @base_directory = '/opt/scanner'
11
30
  @results_directory = "#{@base_directory}/results"
@@ -24,14 +43,14 @@ nessus_location = {
24
43
  @append_results = "x-scanner|#{nessus_location[:ip]}"
25
44
 
26
45
  # Prep work
27
- @logger = Logger.new(STDOUT)
28
- @logger.level = Logger::INFO
46
+ @logger = ::Logger.new(STDOUT)
47
+ @logger.level = ::Logger::INFO
29
48
 
30
49
  # Begin the main portion of the app
31
50
  @logger.debug 'Creating Nessus API Client'
32
51
  @client = Nessus6::Client.new credentials, nessus_location
33
52
 
34
- @db = SQLite3::Database.new '/home/scripts/launched_nessus_scans.db'
53
+ @db = ::SQLite3::Database.new '/home/scripts/launched_nessus_scans.db'
35
54
  @db.execute 'SELECT * FROM active_scans' do |row|
36
55
  mapped_row = {
37
56
  request_id: row[0],
@@ -43,7 +62,7 @@ nessus_location = {
43
62
  mapped_row[:file_id] = @client.scan.export(mapped_row[:scan_id], opts)['file']
44
63
 
45
64
  # Lock it in a closure so we don't have to have a huge one liner
46
- export_status = Proc.new { @client.scan.export_status mapped_row[:scan_id], mapped_row[:file_id] }
65
+ export_status = ::Proc.new { @client.scan.export_status mapped_row[:scan_id], mapped_row[:file_id] }
47
66
  ready_status = { 'status' => 'ready' }
48
67
  @logger.debug 'Waiting...' while export_status.call != ready_status
49
68
 
@@ -94,7 +94,7 @@ module Nessus6
94
94
  else
95
95
  response = @client.get("scans/#{scan_id}", history_id: history_id)
96
96
  end
97
- JSON.parse response.body
97
+ ::JSON.parse response.body
98
98
  end
99
99
 
100
100
  # Downloads an exported scan
@@ -104,7 +104,7 @@ module Nessus6
104
104
  # @param file_id [String, Fixnum] The id of the file to download (included in response from /scans/{scan_id}/export)
105
105
  def download(scan_id, file_id, write_path = nil)
106
106
  response = @client.get "scans/#{scan_id}/export/#{file_id}/download"
107
- File.open(write_path, 'w+') { |file| file.write response } unless write_path.nil?
107
+ ::File.open(write_path, 'w+') { |file| file.write response.body } unless write_path.nil?
108
108
  begin
109
109
  hash_response = verify response,
110
110
  not_found: 'The scan or file does not exist.'
@@ -165,7 +165,7 @@ module Nessus6
165
165
  # @return [Hash] Returns the scan list.
166
166
  def list
167
167
  response = @client.get 'scans'
168
- JSON.parse response.body
168
+ ::JSON.parse response.body
169
169
  end
170
170
 
171
171
  # Pauses a scan.
@@ -1,5 +1,5 @@
1
1
  # The Nessus6 module is used to interact with Nessus version 6 servers.
2
2
  module Nessus6
3
3
  # VERSION is the current version of the Nessus6 gem
4
- VERSION = '0.3.1'
4
+ VERSION = '0.3.2'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: Nessus6
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin Kirsche