Nessus6 0.1.6 → 0.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/Nessus6.rb +4 -1
- data/lib/Nessus6/error/method_not_allowed.rb +7 -0
- data/lib/Nessus6/policy.rb +94 -0
- data/lib/Nessus6/scan.rb +24 -0
- data/lib/Nessus6/verification.rb +3 -0
- data/lib/Nessus6/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a93311faca0577293ac581d90586cf5cdce9788e
|
4
|
+
data.tar.gz: 2d86c0f842b306a16a92e72020566e5de5571567
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9256f00ef92a34916df54c11d9f0b507799236b37d3c3855569494cdbf0d6a3c8aee787a772a6cfbd8f87cda0974eef16277753cb2cdaaf799240a75f8ed7941
|
7
|
+
data.tar.gz: a2ec430c521b43f956ee211e27030308b9dbac328920df8224c7073938e07f66495908ade94850e5f85dfb0a8756e9b8050817483e5279b21db5aba1414eaf2c
|
data/lib/Nessus6.rb
CHANGED
@@ -10,6 +10,7 @@ require 'Nessus6/group'
|
|
10
10
|
require 'Nessus6/permission'
|
11
11
|
require 'Nessus6/plugin'
|
12
12
|
require 'Nessus6/plugin_rule'
|
13
|
+
require 'Nessus6/policy'
|
13
14
|
require 'Nessus6/scan'
|
14
15
|
require 'Nessus6/scanner'
|
15
16
|
require 'Nessus6/server'
|
@@ -23,7 +24,8 @@ module Nessus6
|
|
23
24
|
class Client
|
24
25
|
attr_accessor :client
|
25
26
|
attr_reader :editor, :file, :folder, :group, :permission, :plugin,
|
26
|
-
:plugin_rule, :scan, :scanner, :server, :session,
|
27
|
+
:plugin_rule, :policy, :scan, :scanner, :server, :session,
|
28
|
+
:user
|
27
29
|
|
28
30
|
def initialize(credentials, nessus)
|
29
31
|
nessus[:port] = '8834' unless nessus.key?(:port)
|
@@ -66,6 +68,7 @@ module Nessus6
|
|
66
68
|
@group = Nessus6::Group.new client
|
67
69
|
@permission = Nessus6::Permission.new client
|
68
70
|
@plugin = Nessus6::Plugin.new client
|
71
|
+
@policy = Nessus6::Policy.new client
|
69
72
|
@plugin_rule = Nessus6::PluginRule.new client
|
70
73
|
@scan = Nessus6::Scan.new client
|
71
74
|
@scanner = Nessus6::Scanner.new client
|
@@ -0,0 +1,94 @@
|
|
1
|
+
# The Nessus6 module is used to interact with Nessus version 6 servers.
|
2
|
+
module Nessus6
|
3
|
+
# The Policy class is for defining scan test parameters.
|
4
|
+
# https://localhost:8834/api#/resources/policies
|
5
|
+
class Policy
|
6
|
+
include Nessus6::Verification
|
7
|
+
|
8
|
+
public
|
9
|
+
|
10
|
+
def initialize(client)
|
11
|
+
@client = client
|
12
|
+
end
|
13
|
+
|
14
|
+
|
15
|
+
# Changes the parameters of a policy
|
16
|
+
#
|
17
|
+
# @param policy_id [String, Fixnum] The id of the policy to change
|
18
|
+
# @param uuid [String] The uuid for the editor template to use
|
19
|
+
# @param settings_acl [Array] An array containing permissions to apply to the policy
|
20
|
+
# @return [Hash]
|
21
|
+
def configure(policy_id, uuid, settings_acl)
|
22
|
+
response = @client.put "policies/#{policy_id}", uuid: uuid, 'settings.acl' => settings_acl
|
23
|
+
verify response,
|
24
|
+
not_found: 'The requested policy does not exist.',
|
25
|
+
internal_server_error: 'Error occurred while saving the configuration.'
|
26
|
+
end
|
27
|
+
|
28
|
+
# Copy a policy
|
29
|
+
#
|
30
|
+
# @param policy_id [String, Fixnum] The id of the policy to copy
|
31
|
+
# @return [Hash]
|
32
|
+
def copy(policy_id)
|
33
|
+
response = @client.post "policies/#{policy_id}/copy"
|
34
|
+
verify response,
|
35
|
+
unauthorized: 'You do not have permission to copy this policy.',
|
36
|
+
not_found: 'The requested policy does not exist.',
|
37
|
+
internal_server_error: 'Failed to copy the policy. Internal server error.'
|
38
|
+
end
|
39
|
+
|
40
|
+
# Creates a policy
|
41
|
+
#
|
42
|
+
# @param uuid [String] The uuid of the editor template to use
|
43
|
+
# @return [Hash]
|
44
|
+
def create(uuid)
|
45
|
+
response = @client.post 'policies', uuid: uuid
|
46
|
+
verify response,
|
47
|
+
not_found: 'Could not find a scan with the requested UUID',
|
48
|
+
internal_server_error: 'Failed to save policy. Internal server error.'
|
49
|
+
end
|
50
|
+
|
51
|
+
|
52
|
+
# Delete a policy
|
53
|
+
#
|
54
|
+
# @param policy_id [String, Fixnum] The id of the policy to delete
|
55
|
+
# @return [Hash]
|
56
|
+
def delete(policy_id)
|
57
|
+
response = @client.delete "policies/#{policy_id}"
|
58
|
+
verify response,
|
59
|
+
unauthorized: 'You do not have permission to delete the policy.',
|
60
|
+
not_found: 'Could not find a policy with the provided ID.',
|
61
|
+
not_allowed: 'Policy is in use by a scan.'
|
62
|
+
end
|
63
|
+
|
64
|
+
# Returns the details for the given policy
|
65
|
+
#
|
66
|
+
# @param policy_id [String, Fixnum] The id of the policy to retrieve.
|
67
|
+
# @return [Hash]
|
68
|
+
def details(policy_id)
|
69
|
+
response = @client.get "policies/#{policy_id}"
|
70
|
+
verify response,
|
71
|
+
not_found: 'Could not find a policy with that ID.'
|
72
|
+
end
|
73
|
+
|
74
|
+
# Export the given policy
|
75
|
+
#
|
76
|
+
# @param policy_id [String, Fixnum] The id of the policy to export
|
77
|
+
# @return [Hash]
|
78
|
+
def export(policy_id)
|
79
|
+
response = @client.get "policies/#{policy_id}/export"
|
80
|
+
verify response,
|
81
|
+
unauthorized: 'You do not have permission to export the policy.',
|
82
|
+
not_found: 'Policy with the provided ID does not exist'
|
83
|
+
end
|
84
|
+
|
85
|
+
# Returns the policy list
|
86
|
+
#
|
87
|
+
# @return [Hash] Policy resource(s)
|
88
|
+
def list
|
89
|
+
response = @client.get 'policies'
|
90
|
+
verify response,
|
91
|
+
internal_server_error: 'Internal server error occurred.'
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
data/lib/Nessus6/scan.rb
CHANGED
@@ -115,6 +115,30 @@ module Nessus6
|
|
115
115
|
conflict: 'Scan is not active.'
|
116
116
|
end
|
117
117
|
|
118
|
+
# Resumes a scan
|
119
|
+
#
|
120
|
+
# @param scan_id [String, Fixnum] The id of the scan to resume
|
121
|
+
# @return [Hash]
|
122
|
+
def resume(scan_id)
|
123
|
+
response = @client.post "scans/#{scan_id}/resume"
|
124
|
+
verify response,
|
125
|
+
not_found: 'A scan with that ID could not be located',
|
126
|
+
conflict: "The scan is not active and / or couldn't be resumed"
|
127
|
+
end
|
128
|
+
|
129
|
+
# Enables or disables a scan schedule
|
130
|
+
#
|
131
|
+
# @param scan_id [String, Fixnum] The id of the scan
|
132
|
+
# @param enabled [String, Trueclass, Falseclass] Enables or disables the
|
133
|
+
# scan schedule
|
134
|
+
# @return [Hash] With enabled, control, rules, starttime, and timezone
|
135
|
+
def schedule(scan_id, enabled)
|
136
|
+
response = client.put "scans/#{scan_id}/schedule", enabled: enabled
|
137
|
+
verify response,
|
138
|
+
not_found: 'A scan with that ID could not be located',
|
139
|
+
internal_server_error: 'The scan does not have a schedule enabled'
|
140
|
+
end
|
141
|
+
|
118
142
|
# Stops a scan.
|
119
143
|
#
|
120
144
|
# @param scan_id [String, Fixnum] The id of the scan to stop.
|
data/lib/Nessus6/verification.rb
CHANGED
@@ -3,6 +3,7 @@ require 'Nessus6/error/bad_request'
|
|
3
3
|
require 'Nessus6/error/conflict'
|
4
4
|
require 'Nessus6/error/forbidden'
|
5
5
|
require 'Nessus6/error/internal_server_error'
|
6
|
+
require 'Nessus6/error/method_not_allowed'
|
6
7
|
require 'Nessus6/error/not_found'
|
7
8
|
require 'Nessus6/error/unauthorized'
|
8
9
|
require 'Nessus6/error/unknown'
|
@@ -25,6 +26,8 @@ module Nessus6
|
|
25
26
|
fail Nessus6::Error::ForbiddenError, "#{message[:forbidden]}"
|
26
27
|
when 404
|
27
28
|
fail Nessus6::Error::NotFoundError, "#{message[:not_found]}"
|
29
|
+
when 405
|
30
|
+
fail Nessus6::Error::MethodNotAllowedError, "#{message[:not_allowed]}"
|
28
31
|
when 409
|
29
32
|
fail Nessus6::Error::ConflictError, "#{message[:conflict]}"
|
30
33
|
when 500
|
data/lib/Nessus6/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: Nessus6
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kevin Kirsche
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-09-
|
11
|
+
date: 2015-09-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -118,6 +118,7 @@ files:
|
|
118
118
|
- lib/Nessus6/error/conflict.rb
|
119
119
|
- lib/Nessus6/error/forbidden.rb
|
120
120
|
- lib/Nessus6/error/internal_server_error.rb
|
121
|
+
- lib/Nessus6/error/method_not_allowed.rb
|
121
122
|
- lib/Nessus6/error/not_found.rb
|
122
123
|
- lib/Nessus6/error/unauthorized.rb
|
123
124
|
- lib/Nessus6/error/unknown.rb
|
@@ -127,6 +128,7 @@ files:
|
|
127
128
|
- lib/Nessus6/permission.rb
|
128
129
|
- lib/Nessus6/plugin.rb
|
129
130
|
- lib/Nessus6/plugin_rule.rb
|
131
|
+
- lib/Nessus6/policy.rb
|
130
132
|
- lib/Nessus6/scan.rb
|
131
133
|
- lib/Nessus6/scanner.rb
|
132
134
|
- lib/Nessus6/server.rb
|
@@ -159,4 +161,3 @@ signing_key:
|
|
159
161
|
specification_version: 4
|
160
162
|
summary: "[Under Construction] Nessus 6 API Gem"
|
161
163
|
test_files: []
|
162
|
-
has_rdoc:
|