nessus_client 0.1.3 → 0.1.4

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
  SHA256:
3
- metadata.gz: 9b009898d60e9cf21fbaa66050139ddd5d38cf4aff33b45fae7fc146f56c518b
4
- data.tar.gz: 7a6b5f73f2030bae2d4d2ddecd058fc088aaddb48da32384af977cfa6ffa0702
3
+ metadata.gz: 8bd8d8e9586e3b3023b0a0ca4b0cf42c78519ad0b83c7d7a2d0d9b9adaf133bc
4
+ data.tar.gz: 9734f1945a3daffbd200714f6f736f45d41b3c6d2d3901f35f043775d7a3d6ae
5
5
  SHA512:
6
- metadata.gz: f1084ca533fe97317ebdf481df3c947e3e63249d7644f10c6428bca0ba0d67873d2eef99b8df4e5aec63d4da2005dfa3d38154a3d7036619c7e915636c9acc12
7
- data.tar.gz: ab3fdc9d6b87679e4cea96e9efdd0cdd5fe65468649072d1a98c643aec69fdde04f8359b055e56f578d9d0be2aef7fbd8624d159079bc84fa64acaec313a1d29
6
+ metadata.gz: d68ef88707cf6d6e83171a2b4de47d27ce8f6938e6968acbd2aae05836e755017747f917aa3de0792f06b14d8a7fdf6750ad4069d3e51bcb2bba81cd5e30d680
7
+ data.tar.gz: cf523010cf9bd661dc5ccb708215c4b50d6b0d3f251ecef17d2ae090eecbe0f139bff31d2a2ad87ff33ab647668fd023b0903ee587299ef62dd74f8e8a05caea
data/README.md CHANGED
@@ -1,10 +1,13 @@
1
1
  NessusClient
2
2
  =========
3
3
 
4
- Usable, fast, simple Ruby gem for Tenable Nessus Pro v7.x and v8.x
4
+ Usable, fast, simple Ruby gem for Tenable Nessus Pro from v7.0.1 to v8.3.1
5
5
  NessusClient was designed to be simple, fast and performant through communication with Nessus over REST interface.
6
6
 
7
- [![Gem Version](https://badge.fury.io/rb/nessus_client.svg)](https://badge.fury.io/rb/nessus_client) [![codecov](https://codecov.io/gh/heyder/nessus_client/branch/master/graph/badge.svg)](https://codecov.io/gh/heyder/nessus_client) [![Inline docs](http://inch-ci.org/github/heyder/nessus_client.svg?branch=master)](http://inch-ci.org/github/heyder/nessus_client)
7
+ [![Gem Version](https://badge.fury.io/rb/nessus_client.svg)](https://badge.fury.io/rb/nessus_client)
8
+ [![Maintainability](https://api.codeclimate.com/v1/badges/9cca9e4260cadd8ab98d/maintainability)](https://codeclimate.com/github/heyder/nessus_client/maintainability)
9
+ [![codecov](https://codecov.io/gh/heyder/nessus_client/branch/master/graph/badge.svg)](https://codecov.io/gh/heyder/nessus_client)
10
+ [![Inline docs](http://inch-ci.org/github/heyder/nessus_client.svg?branch=master)](http://inch-ci.org/github/heyder/nessus_client)
8
11
 
9
12
  **Ruby gem for Nessus API**
10
13
 
@@ -29,29 +32,31 @@ Getting started
29
32
  require 'nessus_client'
30
33
 
31
34
  nc = NessusClient.new( { :uri=>'https://localhost:8834', :username=>'username',:password=> 'password'} )
32
- status = Oj.load( nc.status )
35
+ status = nc.server_status
36
+ puts status
37
+ puts nc.server_properties
33
38
 
34
39
  if status['status'] == 'ready'
35
- scan_id = nc.get_scan_by_name('weekly_scan')
36
- scan_uuid = Oj.load( nc.launch_by_name( 'weekly_scan' ,['127.0.0.1']) )['scan_uuid']
40
+ scan_id = nc.get_scan_by_name('Monthly Scan')
41
+ scan_uuid = nc.launch_by_name( 'Monthly Scan', ['127.0.0.1'])['scan_uuid']
37
42
 
38
- while true do
43
+ loop do
39
44
  puts `clear`
40
- scan_status = Oj.load( nc.scan_details( scan_id ) )["info"]["status"]
45
+ scan_status = nc.scan_details( scan_id )["info"]["status"]
41
46
  puts " #{scan_id} - #{scan_uuid} - #{scan_status} "
42
47
  sleep 5
43
48
  if ["completed","canceled"].include? scan_status
44
- export_request = Oj.load( nc.export_request( scan_id, "nessus" ))
49
+ export_request = nc.export_request(scan_id, "nessus" )
45
50
  puts " export request: #{export_request}"
46
51
  while true do
47
52
  puts `clear`
48
- export_status = Oj.load( nc.export_status( export_request['token']) )["status"]
53
+ export_status = nc.token_status( export_request['token'])["status"]
49
54
  puts " export status: #{export_status}"
50
55
  sleep 5
51
56
  if export_status == "ready"
52
57
  puts " downloading..."
53
58
  open("scan_report", "wb") do |file|
54
- file.write(nc.export_download( scan_id, export_request['file'] ))
59
+ file.write(nc.token_download( export_request['token'] ))
55
60
  end
56
61
  exit 0
57
62
  end
@@ -59,7 +64,6 @@ if status['status'] == 'ready'
59
64
  end
60
65
  end
61
66
  end
62
-
63
67
  ```
64
68
 
65
69
  ## Installation
@@ -1,6 +1,7 @@
1
- module NessusClient::Exports
2
1
 
3
- # Request a export of vulnerabilities scan.
2
+ module Resource::Exports # Namespace for Exports resource.
3
+
4
+ # Export the given scan. Once requested, the file can be downloaded using the Resource::Tokens.token_download method upon receiving a "ready" status from the Resource::Tokens#token_status method. You can also use the older Resource::Exports#export_status and Resource::Exports#export_download methods.
4
5
  # @param [String] scan_id The export uuid string.
5
6
  # @param [String] format The file format to use (Nessus, HTML, PDF, CSV, or DB).
6
7
  # @return [JSON]
@@ -9,22 +10,23 @@ module NessusClient::Exports
9
10
  self.request.post( { :path => "/scans/#{scan_id}/export", :payload => payload, :headers => self.headers} )
10
11
  end
11
12
 
12
- # Check the status of a export request
13
- # @param [String] export_id The export uuid string.
13
+ # Check the file status of an exported scan. When an export has been requested, it is necessary to poll this resource until a "ready" status is returned, at which point the file is complete and can be downloaded using the export download resource.
14
+ # @param [String] scan_id The identifier for the scan. This identifier can be the either the 'schedule_uuid' or the numeric 'id' attribute for the scan. We recommend that you use 'schedule_uuid'.
15
+ # @param [String] file_id The ID of the file to poll (Included in response from #export_request).
14
16
  # @return [JSON]
15
17
  # @example Checking the status of a export.
16
- # export_status = nc.export_status( "73376c41-1508-46b7-8587-483d159cd956" )
18
+ # export_status = nc.export_status( "15", "cd956" )
17
19
  # return true if export_status["status"] == "ready"
18
- def export_status( export_id )
19
- self.request.get( {:path => "/tokens/#{export_id}/status", :headers => self.headers} )
20
+ def export_status( scan_id, file_id )
21
+ self.request.get( {:path => "/scans/#{scan_id}/export/#{file_id}/status", :headers => self.headers} )
20
22
  end
21
23
 
22
- # Download a vulnerabities scan output.
23
- # @param [Integer] scan_id The id of the scan to export.
24
- # @param [Integer] file_id The id of the file to download (see #export_request).
25
- # @return (see #format)
24
+ # Download exported scan.
25
+ # @param [String] scan_id The identifier for the scan. This identifier can be the either the 'schedule_uuid' or the numeric 'id' attribute for the scan. We recommend that you use 'schedule_uuid'.
26
+ # @param [String] file_id The ID of the file to poll (Included in response from #export_request).
27
+ # @return [JSON]
26
28
  # @example Download a ready export.
27
- # export = nc.export_download("73376c41-1508-46b7-8587-483d159cd956")
29
+ # export = nc.export_download( '17', '46b78587')
28
30
  # open("scan_report", "wb") do |file|
29
31
  # file.write( export )
30
32
  # end
@@ -32,4 +34,4 @@ module NessusClient::Exports
32
34
  self.request.get( {:path => "/scans/#{scan_id}/export/#{file_id}/download", :headers => self.headers} )
33
35
  end
34
36
 
35
- end
37
+ end
@@ -1,12 +1,12 @@
1
- module NessusClient::Folders
2
- # Get the list of folders from the endpoint.
1
+ module Resource::Folders # Namespace for Folders resource.
2
+ # Get the list of folders from the resource.
3
3
  # @return [JSON]
4
4
  def list_folders
5
5
  self.request.get({:path => "/folders", :headers => self.headers})
6
6
  end
7
- # Create a folder into the endpoint.
7
+ # Create a folder into the resource.
8
8
  # @param [String] folder_name The name of the folder the will be created.
9
- # @return [Json]
9
+ # @return [JSON]
10
10
  def create_folder( folder_name )
11
11
  payload = {:name => folder_name }
12
12
  self.request.post({:path=>"/folders", :payload => payload, :headers => self.headers})
@@ -1,5 +1,5 @@
1
- module NessusClient::Policies
2
- # List the scan polices from the endpoint.
1
+ module Resource::Policies # Namespace for Policies resource.
2
+ # List the scan polices.
3
3
  # @return [JSON]
4
4
  def policies
5
5
  self.request.get( {:path => "/policies", :headers => self.headers} )
data/lib/modules/scans.rb CHANGED
@@ -1,12 +1,12 @@
1
1
 
2
- module NessusClient::Scans
2
+ module Resource::Scans # Namespace for Scans resource.
3
3
 
4
- # List scans from the endpoint.
4
+ # List scans from the resource.
5
5
  # @param [String] folder_id (nil) The name of a alredy created scan.
6
6
  # @return [JSON]
7
7
  def list_scans( folder_id=nil )
8
8
  query = folder_id.nil? ? nil : { "folder_id" => folder_id }
9
- self.request.get( {:path => "/scans", :query => query, :headers => self.headers} )
9
+ self.request.get( {path: "/scans", query: query, headers: self.headers} )
10
10
  end
11
11
  alias_method :scans, :list_scans
12
12
 
@@ -23,7 +23,7 @@ module NessusClient::Scans
23
23
  # @param [Integer] scan_id The ID of a alredy created scan.
24
24
  # @param [Array<String>] targets comma separeted new target to be scanned.
25
25
  # @return [JSON]
26
- def launch( scan_id, targets=[])
26
+ def launch( scan_id, targets=[] )
27
27
  payload = { :alt_targets => targets } unless targets.empty?
28
28
  self.request.post( {:path => "/scans/#{scan_id}/launch", :payload => payload, :headers => self.headers} )
29
29
  end
@@ -42,7 +42,7 @@ module NessusClient::Scans
42
42
  # @param [String] scan_name The name of the scan to look for.
43
43
  # @return [String, nil] The uuid of the scan.
44
44
  def get_scan_by_name( folder_id=nil, scan_name )
45
- Oj.load(list_scans( folder_id ))["scans"].each do |scan|
45
+ list_scans( folder_id )["scans"].each do |scan|
46
46
  return scan['id'] if scan['name'] == scan_name
47
47
  end
48
48
  end
@@ -0,0 +1,15 @@
1
+ module Resource::Server # Namespace for Server resource.
2
+
3
+ # Returns the server status.
4
+ # @return [JSON] Returns the server status (loading, ready, corrupt-db, feed-expired, eval-expired, locked, register, register-locked, download-failed, feed-error).
5
+ def server_status
6
+ self.request.get( {:path => "/server/status", :headers => self.headers} )
7
+ end
8
+
9
+ # Returns the server version and other properties.
10
+ # @return [JSON] Returns the server properties
11
+ def server_properties
12
+ self.request.get( {:path => "/server/properties", :headers => self.headers} )
13
+ end
14
+
15
+ end
@@ -1,16 +1,12 @@
1
- require 'oj'
2
- # Abstract Session class for NessusClient.
3
- # @since 0.1.0
4
- # @attr_reader [String] token Autentication session token.
5
- # @attr_reader [String] api_token Autentication API token.
6
- module NessusClient::Session
7
1
 
2
+ module Resource::Session # Namespace for Session resource.
3
+
4
+ # @return [Boolean] whether has a session.
8
5
  attr_reader :session
9
6
 
10
- @@api_token = nil
11
7
  @session = false
12
8
 
13
- # Autenticate into Nessus endpoint.
9
+ # Autenticate into Nessus resource.
14
10
  # @param [String] username
15
11
  # @param [String] password
16
12
  # @return [nil]
@@ -23,20 +19,17 @@ module NessusClient::Session
23
19
  password: password
24
20
  }
25
21
 
26
- response = self.request.post( {:path => '/session', :payload => payload, :headers => self.headers} )
27
-
28
- response = Oj.load(response) if response.length > 0
22
+ resp = self.request.post( {path: '/session', payload: payload, headers: self.headers} )
29
23
 
30
- raise NessusClient::Error.new( "Unable to authenticate. The response did not include a session token." ) unless response['token']
24
+ raise NessusClient::Error.new( "Unable to authenticate. The response did not include a session token." ) unless resp.has_key?("token")
25
+ raise NessusClient::Error.new( "The token doesnt match with the pattern." ) unless resp["token"].match(%r{(?<token>[a-z0-9]{48})})
31
26
 
32
27
  begin
33
- self.headers.update( 'X-Cookie' => 'token=' + response['token'] )
28
+ self.headers.update( 'X-Cookie' => 'token=' + resp["token"] )
34
29
  @session = true
35
30
  self.headers.update( 'X-API-Token' => set_api_token() )
36
31
  rescue NessusClient::Error => err
37
32
  puts err.message
38
- else
39
- @@api_token = true
40
33
  ensure
41
34
  return
42
35
  end
@@ -44,19 +37,19 @@ module NessusClient::Session
44
37
  end
45
38
  alias_method :session_create, :set_session
46
39
 
47
- # Destroy the current session from Nessus endpoint
40
+ # Destroy the current session.
48
41
  def destroy
49
- self.request.delete( '/session', nil, self.headers )
42
+ self.request.delete( {path: '/session', headers: self.headers} )
50
43
  @session = false
51
44
  end
52
45
  alias_method :logout , :destroy
53
46
 
54
47
  private
55
-
56
48
  # Set the API Token from legacy Nessus version
57
49
  # @raise [NessusClient::Error] Unable to get API Token.
50
+ # @todo To get it direct from the session authentication on v6.x
58
51
  def set_api_token
59
- response = self.request.get( {:path => "/nessus6.js", :headers => self.headers} )
52
+ response = self.request.get( {path: "/nessus6.js", headers: self.headers} )
60
53
  response.match( %r{return"(\w{8}-(?:\w{4}-){3}\w{12})"\}} )
61
54
 
62
55
  raise NessusClient::Error.new( "Unable to get API Token. Some features won't work." ) unless $1
@@ -0,0 +1,25 @@
1
+ module Resource::Tokens # Namespace for tokens resource.
2
+
3
+ # Check the status of a export request
4
+ # @param [String] export_uuid The export uuid string.
5
+ # @return [JSON]
6
+ # @example Checking the status of a export.
7
+ # export_status = nc.export_status( "73376c41-1508-46b7-8587-483d159cd956" )
8
+ # return true if export_status["status"] == "ready"
9
+ def token_status( export_uuid )
10
+ self.request.get( {:path => "/tokens/#{export_uuid}/status", :headers => self.headers} )
11
+ end
12
+
13
+ # Check the download of a export request
14
+ # @param [String] export_uuid The export uuid string.
15
+ # @return [JSON] (@see #format)
16
+ # @example Download a ready export.
17
+ # export = nc.export_download( '73376c41-1508-46b7-8587-483d159cd956')
18
+ # open("scan_report", "wb") do |file|
19
+ # file.write( export )
20
+ # end
21
+ def token_download( export_uuid )
22
+ self.request.get( {:path => "/tokens/#{export_uuid}/download", :headers => self.headers} )
23
+ end
24
+
25
+ end
data/lib/nessus_client.rb CHANGED
@@ -1,26 +1,36 @@
1
1
  require_relative 'nessus_client/version'
2
2
  require_relative 'nessus_client/exception'
3
+ require_relative 'nessus_client/resource'
3
4
 
4
5
  Dir[File.join(__dir__, 'modules', '*.rb')].each { |file| require file }
5
6
 
7
+ # Nessus resource abstraction.
6
8
  class NessusClient
7
9
 
8
- attr_reader :request, :session, :headers
10
+ # @return [NessusClient::Request] Instance HTTP request object.
11
+ # @see NessusClient::Request
12
+ attr_reader :request
13
+ # @return [Boolean] whether has a session.
14
+ attr_reader :session
15
+ # @return [Hash] Instance current HTTP headers.
16
+ attr_reader :headers
9
17
 
10
- include NessusClient::Session
11
- include NessusClient::Scans
12
- include NessusClient::Exports
13
- include NessusClient::Folders
14
- include NessusClient::Policies
18
+ include Resource::Exports
19
+ include Resource::Folders
20
+ include Resource::Policies
21
+ include Resource::Scans
22
+ include Resource::Server
23
+ include Resource::Session
24
+ include Resource::Tokens
15
25
 
16
26
  autoload :Request, "nessus_client/request"
17
27
 
18
28
  # @param [Hash] params the options to create a NessusClient with.
19
- # @option params [String] :uri ('https://localhost:8834/') Nessus endpoint to connect with
20
- # @option params [String] :username Username (nil) to use in the connection
21
- # @option params [String] :password Password (nil) to use in the connection
22
- # @option params [String] :ssl_verify_peer (false) should check whether valid SSL certificate
23
- def initialize( params = {} )
29
+ # @option params [String] :uri ('https://localhost:8834/') Nessus resource to connect with
30
+ # @option params [String] :username (nil) Username to use in the connection
31
+ # @option params [String] :password (nil) Password to use in the connection
32
+ # @option params [String] :ssl_verify_peer (true) Whether should check valid SSL certificate
33
+ def initialize( params={} )
24
34
 
25
35
  default_params = {
26
36
  uri: 'https://localhost:8834/',
@@ -29,25 +39,18 @@ class NessusClient
29
39
  ssl_verify_peer: true
30
40
  }
31
41
  params = default_params.merge( params )
32
- req_params = params.select {|key, value| [:uri, :ssl_verify_peer].include?(key) }
42
+ req_params = params.select { |key, value| [:uri, :ssl_verify_peer].include?(key) }
33
43
 
34
44
  @request = NessusClient::Request.new( req_params )
35
45
  @headers = NessusClient::Request::DEFAULT_HEADERS.dup
36
46
  self.set_session( params.fetch(:username), params.fetch(:password) )
37
47
 
38
-
39
48
  end
40
49
 
41
50
  # Gets NessusClient::Session authentication status.
42
- # @return [Boolean]
51
+ # @return [Boolean] whether NessusClient has successfully authenticated.
43
52
  def has_session?
44
53
  self.session
45
54
  end
46
55
 
47
- # Gets the server status.
48
- # @return [Json] Returns the server status (loading, ready, corrupt-db, feed-expired, eval-expired, locked, register, register-locked, download-failed, feed-error).
49
- def status
50
- self.request.get( {:path => "/server/status", :headers => self.headers} )
51
- end
52
-
53
56
  end
@@ -1,7 +1,11 @@
1
1
  class NessusClient
2
2
  # Abstract Error class for NessusClient.
3
3
  class Error < ::StandardError
4
- def initialize(msg="message")
4
+ # Raise a custom error namespace.
5
+ # @param [String] msg The exception message.
6
+ # @example
7
+ # NessusClient::Error.new('This is a custom error.')
8
+ def initialize( msg )
5
9
  super
6
10
  end
7
11
  end
@@ -1,56 +1,60 @@
1
1
  require 'excon'
2
- require 'json'
2
+ require 'oj'
3
3
 
4
4
  class NessusClient
5
5
 
6
- # Abstract request class for NessusClient. Provides some helper methods for
6
+ # Abstract http request class for NessusClient. Provides some helper methods for perform HTTP requests.
7
7
  class Request
8
-
8
+ # @return [String] The base url of the API.
9
9
  attr_reader :url
10
10
 
11
11
  # Default HTTP header to be used on the requests.
12
12
  DEFAULT_HEADERS = {
13
- "User-Agent" => "Mozilla/5.0 (Linux x86_64)",
14
- "Content-Type" => "application/json"
13
+ "User-Agent" => "NessusClient::Request (https://rubygems.org/gems/nessus_client)",
14
+ "Content-Type" => "application/json"
15
15
  }.freeze
16
16
 
17
- def initialize( params )
18
- # @headers = params[:headers] || DEFAULT_HEADERS
17
+ # @param [Hash] params the options to create a NessusClient::Request with.
18
+ # @option params [String] :uri ('https://localhost:8834/') Nessus server to connect with
19
+ # @option params [String] :ssl_verify_peer (true) Whether should check valid SSL certificate
20
+ def initialize( params={} )
19
21
  params = {:uri => nil }.merge( params )
20
22
  @@ssl_verify_peer = params[:ssl_verify_peer] ? true : false
21
23
  @url = @@url = NessusClient::Request.uri_parse( params.fetch(:uri) )
22
24
  end
23
25
 
24
- # @raise [NotImplementedError] Use update from Hash insted.
25
- # def headers=(value)
26
- # raise NotImplementedError.new("Use update from Hash insted.")
27
- # end
28
-
29
- # Perform a HTTP GET to the endpoint.
30
- # @param [String] path The URI path to perform the request.
31
- # @param [String] payload The HTTP body to send.
32
- # @param [String] query The URI query to send.
26
+ # Perform a HTTP GET request.
27
+ # @param [Hash] opts to use in the request.
28
+ # @option opts [String] path The URI path to perform the request.
29
+ # @option opts [String] payload The HTTP body to send.
30
+ # @option opts [String] query The URI query to send.
31
+ # @return [JSON] The body of the resposnse if there is any.
33
32
  def get( opts={} )
34
33
  http_request( :get, opts )
35
34
  end
36
35
 
37
- # Perform a HTTP POST to the endpoint.
38
- # @param [String] path The URI path to perform the request.
39
- # @param [String] payload The HTTP body to send.
40
- # @param [String] query The URI query to send.
36
+ # Perform a HTTP POST request.
37
+ # @param [Hash] opts to use in the request.
38
+ # @option opts [String] path The URI path to perform the request.
39
+ # @option opts [String] payload The HTTP body to send.
40
+ # @option opts [String] query The URI query to send.
41
+ # @return [JSON] The body of the resposnse if there is any.
41
42
  def post( opts={} )
42
43
  http_request( :post, opts )
43
44
  end
44
45
 
45
- # Perform a HTTP DELETE to the endpoint.
46
- # @param [String] path The URI path to perform the request.
47
- # @param [String] payload The HTTP body to send.
48
- # @param [String] query The URI query to send.
46
+ # Perform a HTTP DELETE request.
47
+ # @param [Hash] opts to use in the request.
48
+ # @option opts [String] path The URI path to perform the request.
49
+ # @option opts [String] payload The HTTP body to send.
50
+ # @option opts [String] query The URI query to send.
51
+ # @return [JSON] The body of the resposnse if there is any.
49
52
  def delete( opts={} )
50
53
  http_request( :delete, opts )
51
54
  end
52
- # Parse a receiveid URI
53
- # @param [String] uri A valid URI.
55
+
56
+ # Parse a receiveid string against the URI stantard.
57
+ # @param [String] uri A string to be validate URI.
54
58
  # @return [String] A string uri.
55
59
  def self.uri_parse( uri )
56
60
  url = URI.parse( uri )
@@ -59,35 +63,43 @@ class NessusClient
59
63
  end
60
64
 
61
65
  private
62
-
63
66
  # @private HTTP request abstraction to be used.
64
- # @param [Symbol] method A HTTP method to be used could be `:get`, `:post` or `:delete`.
65
- # @param [String] path The URI path to perform the request.
66
- # @param [String] payload The HTTP body to send.
67
- # @param [String] query The URI query to send.
67
+ # @param [Symbol] method The HTTP method to be used on the request.
68
+ # @param [Hash] args Parameters to use in the request.
69
+ # @option args [String] path (nil) The URI path to perform the request.
70
+ # @option args [String] payload (nil) The HTTP body to send.
71
+ # @option args [String] query (nil) The URI query to send.
72
+ # @option args [String] headers (nil) The headers to send.
73
+ # @return [JSON] The body of the resposnse if there is any.
68
74
  def http_request( method=:get, args )
69
- opts = {
70
- :path => nil,
71
- :payload => nil,
72
- :query => nil,
73
- :headers => nil
74
- }.merge( args )
75
+ begin
75
76
 
76
- connection = Excon.new( @@url, {ssl_verify_peer: @@ssl_verify_peer} )
77
-
78
- body = opts[:payload] ? opts[:payload].to_json : ''
79
- options = {
80
- method: method,
81
- path: opts.fetch(:path),
82
- body: body,
83
- query: opts.fetch(:query),
84
- headers: opts.fetch(:headers),
85
- expects: [200, 201]
86
- }
87
- response = connection.request( options )
88
-
89
- return response.body if response.body.length > 0
77
+ opts = {
78
+ :path => nil,
79
+ :payload => nil,
80
+ :query => nil,
81
+ :headers => nil
82
+ }.merge( args )
83
+
84
+ connection = Excon.new( @@url, {ssl_verify_peer: @@ssl_verify_peer} )
85
+
86
+ body = opts[:payload] ? Oj.dump( opts[:payload], mode: :compat ) : ''
87
+ options = {
88
+ method: method,
89
+ path: opts.fetch(:path),
90
+ body: body,
91
+ query: opts.fetch(:query),
92
+ headers: opts.fetch(:headers),
93
+ expects: [200, 201]
94
+ }
90
95
 
96
+ response = connection.request( options )
97
+ ret = Oj.load(response.body) #if response.body.length > 0
98
+ rescue Oj::ParseError => e
99
+ return response.body
100
+ else
101
+ return ret
102
+ end
91
103
  end
92
104
 
93
105
  end
@@ -0,0 +1 @@
1
+ module Resource end # Namespace for endpoints
@@ -1,4 +1,4 @@
1
1
  class NessusClient
2
2
  # The current version of the libary.
3
- VERSION = '0.1.3'
3
+ VERSION = '0.1.4'
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nessus_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Heyder
@@ -81,54 +81,21 @@ dependencies:
81
81
  - !ruby/object:Gem::Version
82
82
  version: 0.12.2
83
83
  - !ruby/object:Gem::Dependency
84
- name: simplecov
84
+ name: regexp-examples
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - "~>"
88
- - !ruby/object:Gem::Version
89
- version: 0.17.0
90
- type: :development
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - "~>"
95
- - !ruby/object:Gem::Version
96
- version: 0.17.0
97
- - !ruby/object:Gem::Dependency
98
- name: codecov
99
- requirement: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - "~>"
102
- - !ruby/object:Gem::Version
103
- version: 0.1.14
104
- type: :development
105
- prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - "~>"
109
- - !ruby/object:Gem::Version
110
- version: 0.1.14
111
- - !ruby/object:Gem::Dependency
112
- name: yard
113
- requirement: !ruby/object:Gem::Requirement
114
- requirements:
115
- - - "~>"
116
- - !ruby/object:Gem::Version
117
- version: '0.9'
118
87
  - - ">="
119
88
  - !ruby/object:Gem::Version
120
- version: 0.9.20
89
+ version: 1.5.0
121
90
  type: :development
122
91
  prerelease: false
123
92
  version_requirements: !ruby/object:Gem::Requirement
124
93
  requirements:
125
- - - "~>"
126
- - !ruby/object:Gem::Version
127
- version: '0.9'
128
94
  - - ">="
129
95
  - !ruby/object:Gem::Version
130
- version: 0.9.20
131
- description: NessusClient was designed to be simple, fast and performant through communication
96
+ version: 1.5.0
97
+ description: Usable, fast, simple Ruby gem for Tenable Nessus Pro from v7.0.1 to v8.3.1.
98
+ NessusClient was designed to be simple, fast and performant through communication
132
99
  with Nessus over REST interface.
133
100
  email: eu@heyderandrade.org
134
101
  executables: []
@@ -145,10 +112,13 @@ files:
145
112
  - lib/modules/folders.rb
146
113
  - lib/modules/policies.rb
147
114
  - lib/modules/scans.rb
115
+ - lib/modules/server.rb
148
116
  - lib/modules/session.rb
117
+ - lib/modules/tokens.rb
149
118
  - lib/nessus_client.rb
150
119
  - lib/nessus_client/exception.rb
151
120
  - lib/nessus_client/request.rb
121
+ - lib/nessus_client/resource.rb
152
122
  - lib/nessus_client/version.rb
153
123
  homepage: https://github.com/heyder/nessus_client
154
124
  licenses:
@@ -174,5 +144,5 @@ requirements: []
174
144
  rubygems_version: 3.0.3
175
145
  signing_key:
176
146
  specification_version: 4
177
- summary: Usable, fast, simple Ruby gem for Tenable Nessus Pro v6.x and v7.x
147
+ summary: Usable, fast, simple Ruby gem for Tenable Nessus Pro from v7.0.1 to v8.3.1.
178
148
  test_files: []