rackamole 0.3.2 → 0.3.3
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/HISTORY +5 -1
- data/lib/rackamole.rb +1 -1
- data/lib/rackamole/alert/emole.rb +1 -2
- data/lib/rackamole/mole.rb +5 -1
- data/lib/rackamole/store/mongo_db.rb +23 -8
- data/spec/rackamole/store/mongo_db_spec.rb +51 -27
- data/spec/spec_helper.rb +0 -3
- data/spec/test_configs/rackamole_test.yml +6 -3
- metadata +2 -2
data/HISTORY
CHANGED
@@ -54,4 +54,8 @@
|
|
54
54
|
0.3.2
|
55
55
|
* Fix issue with excluded_path being nil.
|
56
56
|
* Changed default excluded_path
|
57
|
-
* Added perf_excludes option to exempt alerts from being sent for known slower requests
|
57
|
+
* Added perf_excludes option to exempt alerts from being sent for known slower requests
|
58
|
+
|
59
|
+
0.3.3
|
60
|
+
* Added support for rackamole store authentication
|
61
|
+
* Fixed issue to enforce regexp when excluded path are specified as strings.
|
data/lib/rackamole.rb
CHANGED
data/lib/rackamole/mole.rb
CHANGED
@@ -258,7 +258,11 @@ module Rack
|
|
258
258
|
def mole_request?( request )
|
259
259
|
if options.has_key?( :excluded_paths ) and options[:excluded_paths]
|
260
260
|
options[:excluded_paths].each do |exclude_path|
|
261
|
-
|
261
|
+
exclude_path = Regexp.new( exclude_path ) if exclude_path.is_a?( String )
|
262
|
+
if request.path =~ exclude_path
|
263
|
+
logger.debug ">>> Excluded request -- #{request.path} using exclude flag #{exclude_path}"
|
264
|
+
return false
|
265
|
+
end
|
262
266
|
end
|
263
267
|
end
|
264
268
|
true
|
@@ -19,9 +19,11 @@ module Rackamole
|
|
19
19
|
#
|
20
20
|
# === Options
|
21
21
|
#
|
22
|
-
# :host
|
23
|
-
# :port
|
24
|
-
# :db_name
|
22
|
+
# :host :: The name of the host running the mongo server. Default: localhost
|
23
|
+
# :port :: The port for the mongo server instance. Default: 27017
|
24
|
+
# :db_name :: The name of the mole databaase. Default: mole_mdb
|
25
|
+
# :username :: username if the mongo db has auth setup. optional
|
26
|
+
# :password :: password if the mongo db has auth required. optional
|
25
27
|
#
|
26
28
|
def initialize( options={} )
|
27
29
|
opts = default_options.merge( options )
|
@@ -79,9 +81,14 @@ module Rackamole
|
|
79
81
|
@connection = Mongo::Connection.new( @host, @port, :logger => opts[:logger] )
|
80
82
|
@database = @connection.db( @db_name )
|
81
83
|
|
82
|
-
|
83
|
-
|
84
|
-
|
84
|
+
if opts[:username] and opts[:password]
|
85
|
+
authenticated = @database.authenticate( opts[:username], opts[:password] )
|
86
|
+
raise "Authentication failed for database #{@db_name}. Please check your credentials and try again" unless authenticated
|
87
|
+
end
|
88
|
+
|
89
|
+
@features = database.collection( 'features' )
|
90
|
+
@logs = database.collection( 'logs' )
|
91
|
+
@users = database.collection( 'users' )
|
85
92
|
end
|
86
93
|
|
87
94
|
# Validates option hash.
|
@@ -91,14 +98,22 @@ module Rackamole
|
|
91
98
|
raise "[MOle] Mongo store configuration error -- You must specify a value for option `:#{option}"
|
92
99
|
end
|
93
100
|
end
|
101
|
+
# check for auth
|
102
|
+
if opts[:username]
|
103
|
+
%w(username password).each do |option|
|
104
|
+
unless opts[option.to_sym]
|
105
|
+
raise "[MOle] Mongo store configuration error -- You must specify a value for auth option `:#{option}"
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
94
109
|
end
|
95
110
|
|
96
111
|
# Set up mongo default options ie localhost host, default mongo port and
|
97
112
|
# the database being mole_mdb
|
98
113
|
def default_options
|
99
114
|
{
|
100
|
-
:host
|
101
|
-
:port
|
115
|
+
:host => 'localhost',
|
116
|
+
:port => Mongo::Connection::DEFAULT_PORT
|
102
117
|
}
|
103
118
|
end
|
104
119
|
|
@@ -4,6 +4,7 @@ require 'chronic'
|
|
4
4
|
describe Rackamole::Store::MongoDb do
|
5
5
|
|
6
6
|
describe "#mole" do
|
7
|
+
|
7
8
|
before( :all ) do
|
8
9
|
@now = Chronic.parse( "11/27/2009" )
|
9
10
|
@store = Rackamole::Store::MongoDb.new(
|
@@ -11,18 +12,18 @@ describe Rackamole::Store::MongoDb do
|
|
11
12
|
:port => 27017,
|
12
13
|
:db_name => 'mole_app_test_mdb',
|
13
14
|
:logger => Rackamole::Logger.new( :file_name => $stdout, :log_level => 'info' ) )
|
14
|
-
@db
|
15
|
+
@db = @store.database
|
15
16
|
end
|
16
17
|
|
17
18
|
before( :each ) do
|
18
19
|
@store.send( :reset! )
|
19
20
|
|
20
21
|
@args = OrderedHash.new
|
21
|
-
@args[:type]
|
22
|
-
@args[:app_name]
|
23
|
-
@args[:environment]
|
24
|
-
@args[:perf_issue]
|
25
|
-
@args[:ip]
|
22
|
+
@args[:type] = Rackamole.feature
|
23
|
+
@args[:app_name] = "app"
|
24
|
+
@args[:environment] = :test
|
25
|
+
@args[:perf_issue] = false
|
26
|
+
@args[:ip] = "1.1.1.1"
|
26
27
|
@args[:browser] = OrderedHash.new
|
27
28
|
@args[:browser][:name] = "Ibrowse"
|
28
29
|
@args[:browser][:version] = "1.X"
|
@@ -30,15 +31,15 @@ describe Rackamole::Store::MongoDb do
|
|
30
31
|
@args[:machine][:platform] = "Blee"
|
31
32
|
@args[:machine][:os] = "Windoze"
|
32
33
|
@args[:machine][:version] = "10.0"
|
33
|
-
@args[:user_id]
|
34
|
-
@args[:user_name]
|
35
|
-
@args[:request_time]
|
36
|
-
@args[:url]
|
37
|
-
@args[:path]
|
38
|
-
@args[:method]
|
39
|
-
@args[:params]
|
40
|
-
@args[:session]
|
41
|
-
@args[:created_at]
|
34
|
+
@args[:user_id] = 100
|
35
|
+
@args[:user_name] = "Fernand"
|
36
|
+
@args[:request_time] = 1.0
|
37
|
+
@args[:url] = "http://test_me/"
|
38
|
+
@args[:path] = "/fred"
|
39
|
+
@args[:method] = 'GET'
|
40
|
+
@args[:params] = { :blee => "duh".to_json }
|
41
|
+
@args[:session] = { :fred => 10.to_json }
|
42
|
+
@args[:created_at] = @now.utc
|
42
43
|
end
|
43
44
|
|
44
45
|
it "should mole a context based feature correctly" do
|
@@ -53,23 +54,23 @@ describe Rackamole::Store::MongoDb do
|
|
53
54
|
feature['ctx'].should == '/fred'
|
54
55
|
|
55
56
|
log = @store.logs.find_one()
|
56
|
-
log.should_not
|
57
|
-
log['typ'].should
|
58
|
-
log['fid'].should_not
|
59
|
-
log['par'].should
|
60
|
-
log['ip'].should
|
57
|
+
log.should_not be_nil
|
58
|
+
log['typ'].should == Rackamole.feature
|
59
|
+
log['fid'].should_not be_nil
|
60
|
+
log['par'].should == { 'blee' => 'duh'.to_json }
|
61
|
+
log['ip'].should == '1.1.1.1'
|
61
62
|
log['bro']['name'].should == "Ibrowse"
|
62
63
|
log['bro']['version'].should == "1.X"
|
63
64
|
log['mac']['platform'].should == "Blee"
|
64
65
|
log['mac']['os'].should == "Windoze"
|
65
66
|
log['mac']['version'].should == "10.0"
|
66
|
-
log['url'].should
|
67
|
-
log['met'].should
|
68
|
-
log['ses'].should
|
69
|
-
log['uid'].should_not
|
70
|
-
log['rti'].should
|
71
|
-
log['did'].should
|
72
|
-
log['tid'].should
|
67
|
+
log['url'].should == 'http://test_me/'
|
68
|
+
log['met'].should == 'GET'
|
69
|
+
log['ses'].should == { 'fred' => '10' }
|
70
|
+
log['uid'].should_not be_nil
|
71
|
+
log['rti'].should == 1.0
|
72
|
+
log['did'].should == '20091127'
|
73
|
+
log['tid'].should == '190000'
|
73
74
|
|
74
75
|
feature = @store.features.find_one( log['fid'] )
|
75
76
|
feature.should_not be_nil
|
@@ -164,4 +165,27 @@ describe Rackamole::Store::MongoDb do
|
|
164
165
|
end
|
165
166
|
end
|
166
167
|
|
168
|
+
describe( "authentication" ) do
|
169
|
+
it "should authenticate correctly if a store is setup with auth" do
|
170
|
+
store = Rackamole::Store::MongoDb.new(
|
171
|
+
:host => 'localhost',
|
172
|
+
:port => 27017,
|
173
|
+
:db_name => 'mole_sec_app_test_mdb',
|
174
|
+
:username => 'fred',
|
175
|
+
:password => 'letmein',
|
176
|
+
:logger => Rackamole::Logger.new( :file_name => $stdout, :log_level => 'info' ) )
|
177
|
+
end
|
178
|
+
|
179
|
+
it "should crap out if auth failed" do
|
180
|
+
lambda {
|
181
|
+
store = Rackamole::Store::MongoDb.new(
|
182
|
+
:host => 'localhost',
|
183
|
+
:port => 27017,
|
184
|
+
:db_name => 'mole_sec_app_test_mdb',
|
185
|
+
:username => 'fred',
|
186
|
+
:password => 'hoy',
|
187
|
+
:logger => Rackamole::Logger.new( :file_name => $stdout, :log_level => 'info' ) )
|
188
|
+
}.should raise_error( /Authentication failed/ )
|
189
|
+
end
|
190
|
+
end
|
167
191
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -37,6 +37,9 @@ production:
|
|
37
37
|
<<: *defaults
|
38
38
|
:perf_threshold: 5
|
39
39
|
:store: !ruby/object:Rackamole::Store::MongoDb
|
40
|
-
host:
|
41
|
-
port:
|
42
|
-
db_name:
|
40
|
+
host: fred
|
41
|
+
port: 10
|
42
|
+
db_name: mole_fred_production
|
43
|
+
username: fred
|
44
|
+
password: secret
|
45
|
+
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rackamole
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Fernand Galiana
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-02-
|
12
|
+
date: 2010-02-27 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|