risu 1.5.0 → 1.5.1
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.
- data/Gemfile.ci +2 -5
- data/KNOWNISSUES.markdown +12 -11
- data/LICENSE +11 -11
- data/NEWS.markdown +43 -8
- data/README.markdown +36 -32
- data/Rakefile +29 -9
- data/TODO.markdown +150 -77
- data/bin/risu +26 -0
- data/lib/risu.rb +27 -1
- data/lib/risu/base.rb +26 -0
- data/lib/risu/base/prawn_templater.rb +36 -8
- data/lib/risu/base/schema.rb +199 -163
- data/lib/risu/base/template_base.rb +34 -7
- data/lib/risu/base/template_manager.rb +37 -37
- data/lib/risu/base/templater.rb +36 -9
- data/lib/risu/cli.rb +26 -0
- data/lib/risu/cli/application.rb +72 -39
- data/lib/risu/cli/banner.rb +47 -21
- data/lib/risu/exceptions.rb +26 -0
- data/lib/risu/exceptions/invaliddocument.rb +30 -1
- data/lib/risu/models.rb +26 -0
- data/lib/risu/models/familyselection.rb +28 -2
- data/lib/risu/models/host.rb +59 -2
- data/lib/risu/models/individualpluginselection.rb +26 -1
- data/lib/risu/models/item.rb +132 -79
- data/lib/risu/models/patch.rb +26 -1
- data/lib/risu/models/plugin.rb +28 -2
- data/lib/risu/models/pluginspreference.rb +26 -2
- data/lib/risu/models/policy.rb +27 -2
- data/lib/risu/models/reference.rb +81 -20
- data/lib/risu/models/report.rb +33 -8
- data/lib/risu/models/serverpreference.rb +26 -1
- data/lib/risu/models/servicedescription.rb +26 -1
- data/lib/risu/models/version.rb +26 -1
- data/lib/risu/parsers.rb +29 -0
- data/lib/risu/parsers/nessus/nessus_document.rb +47 -14
- data/lib/risu/parsers/nessus/nessus_sax_listener.rb +45 -16
- data/lib/risu/parsers/nexpose/nexpose_document.rb +91 -0
- data/lib/risu/parsers/nexpose/simple_nexpose.rb +108 -0
- data/lib/risu/renderers.rb +26 -0
- data/lib/risu/renderers/nilrenderer.rb +30 -4
- data/lib/risu/templates/assets.rb +36 -10
- data/lib/risu/templates/cover_sheet.rb +34 -8
- data/lib/risu/templates/exec_summary.rb +45 -19
- data/lib/risu/templates/executive_summary.rb +37 -11
- data/lib/risu/templates/finding_statistics.rb +33 -7
- data/lib/risu/templates/findings_host.rb +44 -18
- data/lib/risu/templates/findings_summary.rb +43 -17
- data/lib/risu/templates/findings_summary_with_pluginid.rb +60 -18
- data/lib/risu/templates/graphs.rb +30 -0
- data/lib/risu/templates/host_summary.rb +34 -8
- data/lib/risu/templates/ms_patch_summary.rb +35 -9
- data/lib/risu/templates/ms_update_summary.rb +34 -8
- data/lib/risu/templates/ms_wsus_findings.rb +99 -0
- data/lib/risu/templates/notable.rb +39 -13
- data/lib/risu/templates/notable_detailed.rb +42 -16
- data/lib/risu/templates/pci_compliance.rb +40 -14
- data/lib/risu/templates/stig_findings_summary.rb +62 -36
- data/lib/risu/templates/technical_findings.rb +29 -3
- data/lib/risu/templates/template.rb +35 -9
- data/risu.gemspec +28 -7
- metadata +94 -101
@@ -1,23 +1,50 @@
|
|
1
|
+
# Copyright (c) 2010-2012 Arxopia LLC.
|
2
|
+
# All rights reserved.
|
3
|
+
|
4
|
+
# Redistribution and use in source and binary forms, with or without
|
5
|
+
# modification, are permitted provided that the following conditions are met:
|
6
|
+
|
7
|
+
# * Redistributions of source code must retain the above copyright
|
8
|
+
# notice, this list of conditions and the following disclaimer.
|
9
|
+
# * Redistributions in binary form must reproduce the above copyright
|
10
|
+
# notice, this list of conditions and the following disclaimer in the
|
11
|
+
# documentation and/or other materials provided with the distribution.
|
12
|
+
# * Neither the name of the Arxopia LLC nor the names of its contributors
|
13
|
+
# may be used to endorse or promote products derived from this software
|
14
|
+
# without specific prior written permission.
|
15
|
+
|
16
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
17
|
+
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
18
|
+
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
19
|
+
# DISCLAIMED. IN NO EVENT SHALL ARXOPIA LLC BE LIABLE FOR ANY DIRECT, INDIRECT,
|
20
|
+
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
21
|
+
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
22
|
+
# OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
23
|
+
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
24
|
+
#OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
25
|
+
#OF THE POSSIBILITY OF SUCH DAMAGE.
|
26
|
+
|
1
27
|
module Risu
|
2
28
|
module Base
|
3
29
|
|
4
30
|
# Base template class, all report templates must be a subclass of this.
|
5
31
|
#
|
6
|
-
class TemplateBase
|
32
|
+
class TemplateBase
|
7
33
|
@possible_templates = []
|
8
|
-
|
34
|
+
|
9
35
|
class << self
|
10
36
|
attr_reader :possible_templates
|
11
37
|
end
|
12
|
-
|
13
|
-
#
|
38
|
+
|
39
|
+
# Accessors for template meta-data
|
40
|
+
#
|
41
|
+
# @return [Hash] Containing template meta-data
|
14
42
|
#
|
15
|
-
# @return [Hash] Containing template metadata
|
16
43
|
attr_accessor :template_info
|
17
|
-
|
44
|
+
|
18
45
|
# Adds any class that inherits from [TemplateBase] into an [Array] of
|
19
46
|
# possible templates for further validation.
|
20
|
-
#
|
47
|
+
#
|
21
48
|
def self.inherited(child)
|
22
49
|
possible_templates << child
|
23
50
|
end
|
@@ -1,5 +1,32 @@
|
|
1
|
+
# Copyright (c) 2010-2012 Arxopia LLC.
|
2
|
+
# All rights reserved.
|
3
|
+
|
4
|
+
# Redistribution and use in source and binary forms, with or without
|
5
|
+
# modification, are permitted provided that the following conditions are met:
|
6
|
+
|
7
|
+
# * Redistributions of source code must retain the above copyright
|
8
|
+
# notice, this list of conditions and the following disclaimer.
|
9
|
+
# * Redistributions in binary form must reproduce the above copyright
|
10
|
+
# notice, this list of conditions and the following disclaimer in the
|
11
|
+
# documentation and/or other materials provided with the distribution.
|
12
|
+
# * Neither the name of the Arxopia LLC nor the names of its contributors
|
13
|
+
# may be used to endorse or promote products derived from this software
|
14
|
+
# without specific prior written permission.
|
15
|
+
|
16
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
17
|
+
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
18
|
+
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
19
|
+
# DISCLAIMED. IN NO EVENT SHALL ARXOPIA LLC BE LIABLE FOR ANY DIRECT, INDIRECT,
|
20
|
+
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
21
|
+
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
22
|
+
# OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
23
|
+
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
24
|
+
#OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
25
|
+
#OF THE POSSIBILITY OF SUCH DAMAGE.
|
26
|
+
|
1
27
|
module Risu
|
2
28
|
module Base
|
29
|
+
|
3
30
|
class TemplateManager
|
4
31
|
attr_accessor :registered_templates
|
5
32
|
|
@@ -8,12 +35,13 @@ module Risu
|
|
8
35
|
# @param path Path relative to the base_dir of risu
|
9
36
|
#
|
10
37
|
# @return New instance of the template manager with templates loaded.
|
38
|
+
#
|
11
39
|
def initialize (path)
|
12
40
|
@registered_templates = Array.new
|
13
41
|
@templates = Array.new
|
14
|
-
|
42
|
+
|
15
43
|
base_dir = __FILE__.gsub("risu/base/template_manager.rb", "")
|
16
|
-
|
44
|
+
|
17
45
|
load_templates(base_dir + path)
|
18
46
|
load_templates(File.expand_path(USER_TEMPLATES_DIR)) if File.exists?(File.expand_path(USER_TEMPLATES_DIR)) && File.directory?(File.expand_path(USER_TEMPLATES_DIR))
|
19
47
|
end
|
@@ -22,11 +50,11 @@ module Risu
|
|
22
50
|
#
|
23
51
|
# @param path Path to templates to load
|
24
52
|
#
|
25
|
-
def load_templates(path)
|
53
|
+
def load_templates(path)
|
26
54
|
begin
|
27
|
-
Dir["#{path}/**/*.rb"].each do |x|
|
55
|
+
Dir["#{path}/**/*.rb"].each do |x|
|
28
56
|
begin
|
29
|
-
|
57
|
+
require x
|
30
58
|
rescue => e
|
31
59
|
next
|
32
60
|
end
|
@@ -48,34 +76,11 @@ module Risu
|
|
48
76
|
#
|
49
77
|
def validate(template)
|
50
78
|
t = template.new
|
51
|
-
|
79
|
+
|
52
80
|
return false if t == nil
|
53
81
|
return t.respond_to?(:render)
|
54
82
|
end
|
55
83
|
|
56
|
-
#
|
57
|
-
#
|
58
|
-
def find_plugins(file_name)
|
59
|
-
Dir.new("#{file_name}").each do |file|
|
60
|
-
next if file.match(/^\.+/)
|
61
|
-
path = "#{file_name}/#{file}"
|
62
|
-
|
63
|
-
if FileTest.directory?("#{path}")
|
64
|
-
list("#{path}")
|
65
|
-
else
|
66
|
-
self.register_template path
|
67
|
-
end
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
#
|
72
|
-
#
|
73
|
-
def register_template(plugin)
|
74
|
-
load plugin
|
75
|
-
|
76
|
-
@templates.push(plugin) if @templates.include?(plugin) == false
|
77
|
-
end
|
78
|
-
|
79
84
|
# Finds a template by its name
|
80
85
|
#
|
81
86
|
# @param name Name of the template to find
|
@@ -88,15 +93,15 @@ module Risu
|
|
88
93
|
return t
|
89
94
|
end
|
90
95
|
end
|
91
|
-
|
96
|
+
|
92
97
|
return nil
|
93
98
|
end
|
94
|
-
|
99
|
+
|
95
100
|
# Displays a list of all the templates
|
96
101
|
#
|
97
102
|
def display_templates
|
98
103
|
puts "Available Templates"
|
99
|
-
@registered_templates.each do |x|
|
104
|
+
@registered_templates.each do |x|
|
100
105
|
p = x.new
|
101
106
|
puts "\t#{p.template_info[:name]} - #{p.template_info[:description]}\n"
|
102
107
|
end
|
@@ -104,8 +109,3 @@ module Risu
|
|
104
109
|
end
|
105
110
|
end
|
106
111
|
end
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
data/lib/risu/base/templater.rb
CHANGED
@@ -1,31 +1,58 @@
|
|
1
|
+
# Copyright (c) 2010-2012 Arxopia LLC.
|
2
|
+
# All rights reserved.
|
3
|
+
|
4
|
+
# Redistribution and use in source and binary forms, with or without
|
5
|
+
# modification, are permitted provided that the following conditions are met:
|
6
|
+
|
7
|
+
# * Redistributions of source code must retain the above copyright
|
8
|
+
# notice, this list of conditions and the following disclaimer.
|
9
|
+
# * Redistributions in binary form must reproduce the above copyright
|
10
|
+
# notice, this list of conditions and the following disclaimer in the
|
11
|
+
# documentation and/or other materials provided with the distribution.
|
12
|
+
# * Neither the name of the Arxopia LLC nor the names of its contributors
|
13
|
+
# may be used to endorse or promote products derived from this software
|
14
|
+
# without specific prior written permission.
|
15
|
+
|
16
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
17
|
+
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
18
|
+
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
19
|
+
# DISCLAIMED. IN NO EVENT SHALL ARXOPIA LLC BE LIABLE FOR ANY DIRECT, INDIRECT,
|
20
|
+
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
21
|
+
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
22
|
+
# OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
23
|
+
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
24
|
+
#OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
25
|
+
#OF THE POSSIBILITY OF SUCH DAMAGE.
|
26
|
+
|
1
27
|
module Risu
|
2
28
|
module Base
|
3
|
-
|
29
|
+
|
30
|
+
# Templater class for generating a report from a ERB template
|
4
31
|
#
|
5
|
-
# @author Jacob Hammack
|
6
32
|
class Templater
|
7
33
|
attr_accessor :template, :template_manager, :findings, :output_file
|
8
|
-
|
9
|
-
# Setups of the Templater class
|
34
|
+
|
35
|
+
# Setups of the Templater class initializing all of the variables
|
10
36
|
#
|
11
37
|
# @return [Templater] New Instance
|
12
38
|
def initialize(template, findings, output, template_manager)
|
13
39
|
@template = template
|
14
40
|
@findings = findings
|
15
|
-
@output_file = output
|
41
|
+
@output_file = output
|
16
42
|
@template_manager = template_manager
|
17
43
|
end
|
18
|
-
|
19
|
-
# Generates a report based on the
|
44
|
+
|
45
|
+
# Generates a report based on the ERB template
|
20
46
|
#
|
21
47
|
def generate
|
22
48
|
begin
|
23
49
|
template = @template
|
24
50
|
template_manager = @template_manager
|
25
|
-
|
26
|
-
Prawn::Document.generate(@output_file, :margin => [75, 50, 75, 50]) do |output|
|
51
|
+
|
52
|
+
Prawn::Document.generate(@output_file, :margin => [75, 50, 75, 50]) do |output|
|
27
53
|
output.font_size 12
|
28
54
|
t = template_manager.find_template_by_name(template)
|
55
|
+
t = t.class.new
|
29
56
|
t.render(output) unless t == nil
|
30
57
|
end
|
31
58
|
rescue => e
|
data/lib/risu/cli.rb
CHANGED
@@ -1,3 +1,29 @@
|
|
1
|
+
# Copyright (c) 2010-2012 Arxopia LLC.
|
2
|
+
# All rights reserved.
|
3
|
+
|
4
|
+
# Redistribution and use in source and binary forms, with or without
|
5
|
+
# modification, are permitted provided that the following conditions are met:
|
6
|
+
|
7
|
+
# * Redistributions of source code must retain the above copyright
|
8
|
+
# notice, this list of conditions and the following disclaimer.
|
9
|
+
# * Redistributions in binary form must reproduce the above copyright
|
10
|
+
# notice, this list of conditions and the following disclaimer in the
|
11
|
+
# documentation and/or other materials provided with the distribution.
|
12
|
+
# * Neither the name of the Arxopia LLC nor the names of its contributors
|
13
|
+
# may be used to endorse or promote products derived from this software
|
14
|
+
# without specific prior written permission.
|
15
|
+
|
16
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
17
|
+
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
18
|
+
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
19
|
+
# DISCLAIMED. IN NO EVENT SHALL ARXOPIA LLC BE LIABLE FOR ANY DIRECT, INDIRECT,
|
20
|
+
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
21
|
+
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
22
|
+
# OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
23
|
+
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
24
|
+
#OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
25
|
+
#OF THE POSSIBILITY OF SUCH DAMAGE.
|
26
|
+
|
1
27
|
module Risu
|
2
28
|
module CLI
|
3
29
|
end
|
data/lib/risu/cli/application.rb
CHANGED
@@ -1,15 +1,40 @@
|
|
1
|
+
# Copyright (c) 2010-2012 Arxopia LLC.
|
2
|
+
# All rights reserved.
|
3
|
+
|
4
|
+
# Redistribution and use in source and binary forms, with or without
|
5
|
+
# modification, are permitted provided that the following conditions are met:
|
6
|
+
|
7
|
+
# * Redistributions of source code must retain the above copyright
|
8
|
+
# notice, this list of conditions and the following disclaimer.
|
9
|
+
# * Redistributions in binary form must reproduce the above copyright
|
10
|
+
# notice, this list of conditions and the following disclaimer in the
|
11
|
+
# documentation and/or other materials provided with the distribution.
|
12
|
+
# * Neither the name of the Arxopia LLC nor the names of its contributors
|
13
|
+
# may be used to endorse or promote products derived from this software
|
14
|
+
# without specific prior written permission.
|
15
|
+
|
16
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
17
|
+
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
18
|
+
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
19
|
+
# DISCLAIMED. IN NO EVENT SHALL ARXOPIA LLC BE LIABLE FOR ANY DIRECT, INDIRECT,
|
20
|
+
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
21
|
+
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
22
|
+
# OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
23
|
+
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
24
|
+
#OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
25
|
+
#OF THE POSSIBILITY OF SUCH DAMAGE.
|
26
|
+
|
1
27
|
module Risu
|
2
28
|
module CLI
|
3
29
|
|
4
30
|
# Application class for Risu
|
5
31
|
#
|
6
|
-
# @author Jacob Hammack <jacob.hammack@hammackj.com>
|
7
32
|
class Application
|
8
33
|
include Risu::Base
|
9
34
|
attr_accessor :database
|
10
35
|
|
11
|
-
#
|
12
|
-
#
|
36
|
+
# Initializes a CLI Application
|
37
|
+
#
|
13
38
|
def initialize
|
14
39
|
@options = {}
|
15
40
|
@database = {}
|
@@ -18,15 +43,15 @@ module Risu
|
|
18
43
|
|
19
44
|
@options[:debug] = false
|
20
45
|
@options[:list_templates] = false
|
21
|
-
|
46
|
+
|
22
47
|
@template_manager = Risu::Base::TemplateManager.new "risu/templates"
|
23
48
|
end
|
24
49
|
|
25
|
-
# Creates a blank
|
50
|
+
# Creates a blank configuration file
|
26
51
|
#
|
27
52
|
# @todo does this need exception handling
|
28
53
|
#
|
29
|
-
# @param file Path to
|
54
|
+
# @param file Path to configuration file
|
30
55
|
#
|
31
56
|
def create_config(file=CONFIG_FILE)
|
32
57
|
File.open(file, 'w+') do |f|
|
@@ -48,8 +73,8 @@ module Risu
|
|
48
73
|
|
49
74
|
# Loads the configuration file
|
50
75
|
#
|
51
|
-
# @param file Path to
|
52
|
-
# @param in_memory_config [Boolean] If the
|
76
|
+
# @param file Path to configuration file
|
77
|
+
# @param in_memory_config [Boolean] If the configuration is in memory
|
53
78
|
#
|
54
79
|
def load_config(file=CONFIG_FILE, in_memory_config=false)
|
55
80
|
if File.exists?(file) == true or in_memory_config == true
|
@@ -72,11 +97,11 @@ module Risu
|
|
72
97
|
end
|
73
98
|
end
|
74
99
|
rescue => e
|
75
|
-
puts "[!] Error loading
|
100
|
+
puts "[!] Error loading configuration! - #{e.message}"
|
76
101
|
exit
|
77
102
|
end
|
78
103
|
else
|
79
|
-
puts "[!]
|
104
|
+
puts "[!] Configuration file does not exist!"
|
80
105
|
exit
|
81
106
|
end
|
82
107
|
end
|
@@ -88,7 +113,7 @@ module Risu
|
|
88
113
|
def migrate(direction)
|
89
114
|
begin
|
90
115
|
if @database["adapter"] == nil
|
91
|
-
return false, "[!] Invalid database adapter, please check your
|
116
|
+
return false, "[!] Invalid database adapter, please check your configuration file"
|
92
117
|
end
|
93
118
|
|
94
119
|
ActiveRecord::Base.establish_connection(@database)
|
@@ -101,18 +126,20 @@ module Risu
|
|
101
126
|
ver.version = Risu::VERSION
|
102
127
|
ver.save
|
103
128
|
end
|
104
|
-
|
129
|
+
|
105
130
|
puts "[*] Dropping tables" if direction == :down
|
106
131
|
|
132
|
+
#@todo temp hack, fix this by checking the schema on :up or :down for exiting data
|
133
|
+
rescue SQLite3::SQLException => sqlitex
|
134
|
+
puts "#{sqlitex.message}\n #{sqlitex.backtrace}" if @options[:debug]
|
135
|
+
continue
|
107
136
|
rescue ActiveRecord::AdapterNotSpecified => ans
|
108
|
-
puts "[!] Database adapter not found, please check your
|
137
|
+
puts "[!] Database adapter not found, please check your configuration file"
|
109
138
|
puts "#{ans.message}\n #{ans.backtrace}" if @options[:debug]
|
110
|
-
|
111
139
|
exit
|
112
140
|
rescue ActiveRecord::AdapterNotFound => anf
|
113
|
-
puts "[!] Database adapter not found, please check your
|
141
|
+
puts "[!] Database adapter not found, please check your configuration file"
|
114
142
|
puts "#{ans.message}\n #{ans.backtrace}" if @options[:debug]
|
115
|
-
|
116
143
|
exit
|
117
144
|
rescue => e
|
118
145
|
puts "[!] Exception! #{e.message}\n#{e.backtrace}"
|
@@ -127,21 +154,19 @@ module Risu
|
|
127
154
|
if @database["adapter"] == nil
|
128
155
|
puts "[!] #{@database['adapter']}" if @options[:debug]
|
129
156
|
|
130
|
-
return false, "[!] Invalid database adapter, please check your
|
157
|
+
return false, "[!] Invalid database adapter, please check your configuration file"
|
131
158
|
end
|
132
159
|
|
133
160
|
ActiveRecord::Base.establish_connection(@database)
|
134
161
|
ActiveRecord::Base.connection
|
135
162
|
|
136
163
|
rescue ActiveRecord::AdapterNotSpecified => ans
|
137
|
-
puts "[!] Database adapter not found, please check your
|
164
|
+
puts "[!] Database adapter not found, please check your configuration file"
|
138
165
|
puts "#{ans.message}\n #{ans.backtrace}" if @options[:debug]
|
139
|
-
|
140
166
|
exit
|
141
167
|
rescue ActiveRecord::AdapterNotFound => anf
|
142
|
-
puts "[!] Database adapter not found, please check your
|
168
|
+
puts "[!] Database adapter not found, please check your configuration file"
|
143
169
|
puts "#{anf.message}\n #{anf.backtrace}" if @options[:debug]
|
144
|
-
|
145
170
|
exit
|
146
171
|
rescue => e
|
147
172
|
puts "[!] Exception! #{e.message}\n #{e.backtrace}"
|
@@ -169,6 +194,7 @@ module Risu
|
|
169
194
|
# Starts a console and executes anything in a block sent to it
|
170
195
|
#
|
171
196
|
# @param block Code block to transfer control
|
197
|
+
#
|
172
198
|
def consolize &block
|
173
199
|
|
174
200
|
yield
|
@@ -207,16 +233,17 @@ module Risu
|
|
207
233
|
opt.on('-o', '--output-file FILE', 'The filename to output the generated report to') do |option|
|
208
234
|
@options[:output_file] = option
|
209
235
|
end
|
210
|
-
|
236
|
+
|
211
237
|
opt.on('-l', '--list-templates', "Lists all of the templates available to #{APP_NAME}") do |option|
|
212
238
|
@options[:list_templates] = option
|
213
239
|
end
|
214
240
|
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
end
|
241
|
+
# @todo THIS NO WORK
|
242
|
+
#opt.on('--create-template NAME', "Creates a template file in the ~/.risu/templates directory") do |option|
|
243
|
+
# if File.exists?(option) == true
|
244
|
+
# puts "[!] Template "
|
245
|
+
# end
|
246
|
+
#end
|
220
247
|
|
221
248
|
opt.separator('')
|
222
249
|
opt.separator('Configuration Options')
|
@@ -230,13 +257,13 @@ module Risu
|
|
230
257
|
end
|
231
258
|
end
|
232
259
|
|
233
|
-
opt.on('--create-config-file [FILE]',"Creates a
|
260
|
+
opt.on('--create-config-file [FILE]',"Creates a configuration file in the current directory with the specified name, Default is #{CONFIG_FILE}") do |option|
|
234
261
|
if option == nil
|
235
262
|
option = CONFIG_FILE
|
236
263
|
end
|
237
264
|
|
238
265
|
if File.exists?(option) == true
|
239
|
-
puts "[!]
|
266
|
+
puts "[!] Configuration file already exists; If you wish to over-write this file please delete it."
|
240
267
|
else
|
241
268
|
if option == nil
|
242
269
|
create_config
|
@@ -267,7 +294,7 @@ module Risu
|
|
267
294
|
opt.separator 'Other Options'
|
268
295
|
|
269
296
|
opt.on_tail('-v', '--version', "Shows application version information") do
|
270
|
-
puts "#{APP_NAME}
|
297
|
+
puts "#{APP_NAME}: #{VERSION}\nRuby Version: #{RUBY_VERSION}\nRubygems Version: #{Gem::VERSION}"
|
271
298
|
exit
|
272
299
|
end
|
273
300
|
|
@@ -305,10 +332,9 @@ module Risu
|
|
305
332
|
#
|
306
333
|
def run
|
307
334
|
parse_options
|
308
|
-
|
335
|
+
|
309
336
|
if @options[:list_templates]
|
310
337
|
@template_manager.display_templates
|
311
|
-
|
312
338
|
exit
|
313
339
|
end
|
314
340
|
|
@@ -361,7 +387,7 @@ module Risu
|
|
361
387
|
@findings.title = @report["title"]
|
362
388
|
@findings.company = @report["company"]
|
363
389
|
@findings.classification = @report["classification"]
|
364
|
-
|
390
|
+
|
365
391
|
template = Templater.new(@options[:template], @findings, @options[:output_file], @template_manager)
|
366
392
|
template.generate
|
367
393
|
end
|
@@ -386,7 +412,8 @@ module Risu
|
|
386
412
|
|
387
413
|
# Handles the parsing of a single file
|
388
414
|
#
|
389
|
-
# @param file
|
415
|
+
# @param file The to parse
|
416
|
+
#
|
390
417
|
def parse_file file
|
391
418
|
begin
|
392
419
|
puts "[*] Parsing #{file}..."
|
@@ -396,20 +423,26 @@ module Risu
|
|
396
423
|
raise Risu::Exceptions::InvalidDocument, "[!] Document does not exist - #{file}"
|
397
424
|
end
|
398
425
|
|
399
|
-
|
400
|
-
|
401
|
-
|
426
|
+
nessus_doc = Risu::Parsers::Nessus::NessusDocument.new file
|
427
|
+
nexpose_doc = Risu::Parsers::Nexpose::NexposeDocument.new file
|
428
|
+
|
429
|
+
if nessus_doc.valid? == true
|
430
|
+
nessus_doc.parse
|
402
431
|
|
403
432
|
puts "[*] Fixing IP Address field"
|
404
|
-
|
433
|
+
nessus_doc.fix_ips
|
434
|
+
elsif nexpose_doc.valid? == true
|
435
|
+
nexpose_doc.parse
|
405
436
|
|
437
|
+
puts "[*] Fixing IP Address field"
|
438
|
+
nexpose_doc.fix_ips
|
406
439
|
else
|
407
440
|
raise Risu::Exceptions::InvalidDocument, "[!] Invalid Document - #{file}"
|
408
441
|
end
|
409
442
|
|
410
443
|
printf "[*] Finished parsing %s. Parse took %.02f seconds\n", file, Time.now - tstart
|
411
444
|
rescue Interrupt => i
|
412
|
-
puts "[!] Parse
|
445
|
+
puts "[!] Parse canceled!"
|
413
446
|
exit(1)
|
414
447
|
rescue Mysql::Error => m
|
415
448
|
if m.errno == 1146
|