keigan 0.0.0 → 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/NEWS.markdown +10 -0
- data/README.markdown +49 -2
- data/Rakefile +3 -2
- data/TODO.markdown +9 -0
- data/bin/keigan +2 -1
- data/keigan.gemspec +3 -5
- data/lib/keigan/cli/application.rb +215 -0
- data/lib/keigan/cli.rb +32 -0
- data/lib/keigan/web/application.rb +66 -0
- data/lib/keigan/web/public/css/layout.css +380 -0
- data/lib/keigan/web/public/images/risks_by_severity.png +0 -0
- data/lib/keigan/web/public/js/bluff-min.js +1 -0
- data/lib/keigan/web/public/js/bluff-src.js +2990 -0
- data/lib/keigan/web/public/js/excanvas.js +35 -0
- data/lib/keigan/web/public/js/js-class.js +1 -0
- data/lib/keigan/web/views/header.haml +16 -0
- data/lib/keigan/web/views/host.haml +47 -0
- data/lib/keigan/web/views/hosts.haml +34 -0
- data/lib/keigan/web/views/index.haml +72 -0
- data/lib/keigan/web/views/items.haml +34 -0
- data/lib/keigan/web/views/layout.haml +19 -0
- data/lib/keigan/web/views/not_implemented.haml +2 -0
- data/lib/keigan/web/views/report.haml +8 -0
- data/lib/keigan/web/views/reports.haml +9 -0
- data/lib/keigan/web.rb +32 -0
- data/lib/keigan.rb +16 -1
- metadata +72 -3
data/NEWS.markdown
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
# News
|
2
|
+
|
3
|
+
#0.0.1 (August 1, 2012)
|
4
|
+
- Initial **alpha** release of a web gui for viewing data
|
5
|
+
- This version is feature incomplete and will probably not even work in most cases!
|
6
|
+
- Enabled via % keigan
|
7
|
+
- Browse to http://localhost:8969 to view it, this is static for now
|
8
|
+
|
9
|
+
#0.0.0 (July 09, 2012)
|
10
|
+
- Initial gem push to save the gem name, unusable
|
data/README.markdown
CHANGED
@@ -2,14 +2,61 @@
|
|
2
2
|
|
3
3
|
Keigan is web interface for viewing a risu database
|
4
4
|
|
5
|
-
The name comes from the Japanese word for keen insight.
|
5
|
+
The name comes from the Japanese word for 'keen insight'.
|
6
|
+
|
7
|
+
# Requirements
|
8
|
+
|
9
|
+
##Ruby
|
10
|
+
Keigan has been tested with ruby-1.9.2-p320, ruby-1.9.3-p125. Please try to use one of these versions if possible. I recommend using RVM to setup your ruby environment you can get it [here](https://rvm.beginrescueend.com/).
|
11
|
+
|
12
|
+
### RubyGems
|
13
|
+
Keigan relies heavily on [RubyGems](http://rubygems.org/) to install other dependencies I highly recommend using it. RubyGems is included by default in the 1.9.x versions of [Ruby](http://ruby-lang.org/).
|
14
|
+
|
15
|
+
- rails
|
16
|
+
- yaml
|
17
|
+
- logger
|
18
|
+
- risu
|
19
|
+
- sinatra
|
20
|
+
- haml
|
21
|
+
|
22
|
+
# Installation
|
23
|
+
Installation is really easy just gem install!
|
24
|
+
|
25
|
+
% gem install keigan
|
26
|
+
|
27
|
+
# Usage
|
28
|
+
It is assumed that you already have a working [risu](http://www.arxopia.com/projects/risu) installation, a configuration file and a parsed database.
|
29
|
+
|
30
|
+
## Step 1: Starting the service
|
31
|
+
Simply type in a console; by default Keigan will read a configuration file for database settings from the current directory. This means you should run it from the same directory as your risu database(sqlite) and configuration file.
|
32
|
+
|
33
|
+
% keigan
|
34
|
+
|
35
|
+
Once the service boots up open a web browser and navigate to http://localhost:8869. Alternatively if you want the service to run in the background you can do the following.
|
36
|
+
|
37
|
+
% keigan &
|
38
|
+
|
39
|
+
## Step 2: Navigating the website
|
40
|
+
Keigan displays everything in the database in a easy view manner.
|
41
|
+
|
42
|
+
### Pages
|
43
|
+
- dashboard
|
44
|
+
- scans
|
45
|
+
- hosts
|
46
|
+
- items
|
47
|
+
- plugins
|
6
48
|
|
7
49
|
# Contributing
|
8
|
-
If you would like to contribute
|
50
|
+
If you would like to contribute to Keigan. The easiest way is to fork the project on [github](http://github.com/arxopia/keigan) and make the changes in your fork and the submit a pull request to the project.
|
9
51
|
|
10
52
|
# Issues
|
11
53
|
If you have any problems, bugs or feature requests please use the [github issue tracker](http://github.com/arxopia/keigan/issues).
|
12
54
|
|
55
|
+
# Copyrights
|
56
|
+
- keigan - (BSD) Copyright (C) 2012 Arxopia LLC.
|
57
|
+
- risu - (BSD) Copyright (C) 2010-2012 Arxopia LLC.
|
58
|
+
- Bluff - (MIT) Copyright (C) 2008-2010 James Coglan
|
59
|
+
|
13
60
|
# Contact
|
14
61
|
You can reach me at keigan[at]arxopia[dot]com.
|
15
62
|
|
data/Rakefile
CHANGED
@@ -37,6 +37,7 @@ end
|
|
37
37
|
|
38
38
|
task :release => :build do
|
39
39
|
system "gem push #{Keigan::APP_NAME}-#{Keigan::VERSION}.gem"
|
40
|
+
puts "Just released #{Keigan::APP_NAME} v#{Keigan::VERSION}. #{Keigan::APP_NAME} is always available in RubyGems! More information at http://arxopia.com/projects/keigan/"
|
40
41
|
end
|
41
42
|
|
42
43
|
task :clean do
|
@@ -47,9 +48,9 @@ task :clean do
|
|
47
48
|
system "rm -rf coverage"
|
48
49
|
end
|
49
50
|
|
50
|
-
task :default => [:
|
51
|
+
task :default => [:test]
|
51
52
|
|
52
|
-
Rake::TestTask.new("
|
53
|
+
Rake::TestTask.new("test") { |t|
|
53
54
|
t.libs << "test"
|
54
55
|
t.pattern = 'test/*/*_test.rb'
|
55
56
|
t.verbose = true
|
data/TODO.markdown
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
# TODO
|
2
|
+
|
3
|
+
**Release dates and road map are estimates, and features can be changed at any time.**
|
4
|
+
|
5
|
+
- Create a custom style for the application
|
6
|
+
- Move to http://twitter.github.com/bootstrap/index.html for the web gui
|
7
|
+
- Better layout all the pages and properly display everything
|
8
|
+
- Allow editing
|
9
|
+
- 100% code coverage for unit and integration tests
|
data/bin/keigan
CHANGED
data/keigan.gemspec
CHANGED
@@ -51,9 +51,7 @@ Gem::Specification.new do |s|
|
|
51
51
|
s.required_rubygems_version = ">= 1.8.24"
|
52
52
|
s.rubyforge_project = "#{Keigan::APP_NAME}"
|
53
53
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
#s.add_dependency('rails', ['>= 3.0.7'])
|
58
|
-
#s.add_dependency('libxml-ruby', ['>= 1.1.4'])
|
54
|
+
s.add_dependency('risu', ['>= 1.5.1'])
|
55
|
+
s.add_dependency('sinatra', [">= 1.3.2"])
|
56
|
+
s.add_dependency('haml', [">= 3.1.4"])
|
59
57
|
end
|
@@ -0,0 +1,215 @@
|
|
1
|
+
# Copyright (c) 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
|
+
|
27
|
+
module Keigan
|
28
|
+
module Cli
|
29
|
+
|
30
|
+
# Application class for Keigan
|
31
|
+
#
|
32
|
+
class Application
|
33
|
+
attr_accessor :database
|
34
|
+
|
35
|
+
# Initializes a CLI Application
|
36
|
+
#
|
37
|
+
def initialize
|
38
|
+
@options = {}
|
39
|
+
@database = {}
|
40
|
+
|
41
|
+
@options[:debug] = false
|
42
|
+
end
|
43
|
+
|
44
|
+
# Loads the configuration file
|
45
|
+
#
|
46
|
+
# @param file Path to configuration file
|
47
|
+
# @param in_memory_config [Boolean] If the configuration is in memory
|
48
|
+
#
|
49
|
+
def load_config(file=CONFIG_FILE, in_memory_config=false)
|
50
|
+
if File.exists?(file) == true or in_memory_config == true
|
51
|
+
begin
|
52
|
+
if in_memory_config
|
53
|
+
yaml = YAML::load(file)
|
54
|
+
else
|
55
|
+
yaml = YAML::load(File.open(file))
|
56
|
+
end
|
57
|
+
|
58
|
+
@database = yaml["database"]
|
59
|
+
@report = yaml["report"]
|
60
|
+
|
61
|
+
puts @database.inspect if @options[:debug]
|
62
|
+
|
63
|
+
#If no values were entered put a default value in
|
64
|
+
@report.each do |k, v|
|
65
|
+
if v == nil
|
66
|
+
@report[k] = "No #{k}"
|
67
|
+
end
|
68
|
+
end
|
69
|
+
rescue => e
|
70
|
+
puts "[!] Error loading configuration! - #{e.message}"
|
71
|
+
exit
|
72
|
+
end
|
73
|
+
else
|
74
|
+
puts "[!] Configuration file does not exist!"
|
75
|
+
exit
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
# Establishes an [ActiveRecord::Base] database connection
|
80
|
+
#
|
81
|
+
def db_connect
|
82
|
+
begin
|
83
|
+
if @database["adapter"] == nil
|
84
|
+
puts "[!] #{@database['adapter']}" if @options[:debug]
|
85
|
+
|
86
|
+
return false, "[!] Invalid database adapter, please check your configuration file"
|
87
|
+
end
|
88
|
+
|
89
|
+
ActiveRecord::Base.establish_connection(@database)
|
90
|
+
ActiveRecord::Base.connection
|
91
|
+
|
92
|
+
rescue ActiveRecord::AdapterNotSpecified => ans
|
93
|
+
puts "[!] Database adapter not found, please check your configuration file"
|
94
|
+
puts "#{ans.message}\n #{ans.backtrace}" if @options[:debug]
|
95
|
+
|
96
|
+
exit
|
97
|
+
rescue ActiveRecord::AdapterNotFound => anf
|
98
|
+
puts "[!] Database adapter not found, please check your configuration file"
|
99
|
+
puts "#{anf.message}\n #{anf.backtrace}" if @options[:debug]
|
100
|
+
|
101
|
+
exit
|
102
|
+
rescue => e
|
103
|
+
puts "[!] Exception! #{e.message}\n #{e.backtrace}"
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
# Tests the database connection
|
108
|
+
#
|
109
|
+
# @return [Boolean] True on successful, False on failure
|
110
|
+
def test_connection?
|
111
|
+
begin
|
112
|
+
|
113
|
+
db_connect
|
114
|
+
|
115
|
+
if ActiveRecord::Base.connected? == true
|
116
|
+
return true, "[*] Connection Test Successful"
|
117
|
+
else
|
118
|
+
return false, "[!] Connection Test Failed"
|
119
|
+
end
|
120
|
+
rescue => e
|
121
|
+
puts "[!] Exception! #{e.message}\n #{e.backtrace}"
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
# Parses all the command line
|
126
|
+
#
|
127
|
+
def parse_options
|
128
|
+
begin
|
129
|
+
opts = OptionParser.new do |opt|
|
130
|
+
opt.banner = "#{APP_NAME} v#{VERSION}\n#{AUTHOR}\n#{SITE}\n\n"
|
131
|
+
opt.banner << "Usage: #{APP_NAME} [options]"
|
132
|
+
opt.separator('')
|
133
|
+
opt.separator('Configuration Options')
|
134
|
+
|
135
|
+
opt.on('--config-file FILE', "Loads configuration settings for the specified file. By default #{APP_NAME} loads #{CONFIG_FILE}") do |option|
|
136
|
+
if File.exists?(option) == true
|
137
|
+
@options[:config_file] = option
|
138
|
+
else
|
139
|
+
puts "[!] Specified configuration file does not exist. Please specify a file that exists."
|
140
|
+
exit
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
opt.separator('')
|
145
|
+
opt.separator('Database Options')
|
146
|
+
|
147
|
+
opt.on('--test-connection','Tests the database connection settings') do |option|
|
148
|
+
@options[:test_connection] = option
|
149
|
+
end
|
150
|
+
|
151
|
+
opt.separator ''
|
152
|
+
opt.separator 'Other Options'
|
153
|
+
|
154
|
+
opt.on_tail('-v', '--version', "Shows application version information") do
|
155
|
+
puts "#{APP_NAME}: #{VERSION}\nRuby Version: #{RUBY_VERSION}\nRubygems Version: #{Gem::VERSION}"
|
156
|
+
exit
|
157
|
+
end
|
158
|
+
|
159
|
+
opt.on('-d','--debug','Enable Debug Mode (More verbose output)') do |option|
|
160
|
+
@options[:debug] = true
|
161
|
+
end
|
162
|
+
|
163
|
+
opt.on_tail("-?", "--help", "Show this message") do
|
164
|
+
puts opt.to_s + "\n"
|
165
|
+
exit
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
169
|
+
if ARGV.length != 0
|
170
|
+
opts.parse!
|
171
|
+
else
|
172
|
+
# puts opts.to_s + "\n"
|
173
|
+
# exit
|
174
|
+
end
|
175
|
+
rescue OptionParser::MissingArgument => m
|
176
|
+
puts opts.to_s + "\n"
|
177
|
+
exit
|
178
|
+
rescue OptionParser::InvalidOption => i
|
179
|
+
puts opts.to_s + "\n"
|
180
|
+
exit
|
181
|
+
end
|
182
|
+
end
|
183
|
+
|
184
|
+
# Main Application loop, handles all of the command line arguments and
|
185
|
+
#parsing of files on the command line
|
186
|
+
#
|
187
|
+
def run
|
188
|
+
parse_options
|
189
|
+
|
190
|
+
if @options[:debug] == true
|
191
|
+
puts "[*] Enabling Debug Mode"
|
192
|
+
end
|
193
|
+
|
194
|
+
if @options[:config_file] != nil
|
195
|
+
load_config @options[:config_file]
|
196
|
+
else
|
197
|
+
load_config
|
198
|
+
end
|
199
|
+
|
200
|
+
if @options[:test_connection] != nil
|
201
|
+
result = test_connection?
|
202
|
+
|
203
|
+
puts "#{result[1]}"
|
204
|
+
exit
|
205
|
+
end
|
206
|
+
|
207
|
+
db_connect
|
208
|
+
|
209
|
+
puts "Keigan Web Interface at http://localhost:8969/"
|
210
|
+
Keigan::Web::Application.run!
|
211
|
+
|
212
|
+
end
|
213
|
+
end
|
214
|
+
end
|
215
|
+
end
|
data/lib/keigan/cli.rb
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
# Copyright (c) 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
|
+
|
27
|
+
module Keigan
|
28
|
+
module Cli
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
require 'keigan/cli/application'
|
@@ -0,0 +1,66 @@
|
|
1
|
+
# Copyright (c) 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
|
+
|
27
|
+
module Keigan
|
28
|
+
module Web
|
29
|
+
class Application < Sinatra::Base
|
30
|
+
set :bind, 'localhost'
|
31
|
+
set :port, 8969
|
32
|
+
set :haml, :format => :html5
|
33
|
+
set :environment, :production
|
34
|
+
|
35
|
+
get '/' do
|
36
|
+
haml :index
|
37
|
+
end
|
38
|
+
|
39
|
+
get '/hosts' do
|
40
|
+
haml :hosts
|
41
|
+
end
|
42
|
+
|
43
|
+
get '/host/:id' do
|
44
|
+
@host = Host.find(params[:id])
|
45
|
+
haml :host, :layout => :layout
|
46
|
+
end
|
47
|
+
|
48
|
+
get '/reports' do
|
49
|
+
haml :reports
|
50
|
+
end
|
51
|
+
|
52
|
+
get '/report/:id' do
|
53
|
+
@report = Host.find(params[:id])
|
54
|
+
haml :report
|
55
|
+
end
|
56
|
+
|
57
|
+
get '/items' do
|
58
|
+
haml :not_implemented
|
59
|
+
end
|
60
|
+
|
61
|
+
get '/plugins' do
|
62
|
+
haml :not_implemented
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|