honeypot 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -12,8 +12,9 @@ begin
12
12
  gem.authors = ["Seamus Abshere"]
13
13
  gem.add_dependency 'fast_timestamp', '>=0.0.4'
14
14
  gem.add_dependency 'geokit', '>=1.5.0'
15
- gem.add_dependency 'activesupport', '>=3.0.0beta2'
16
- gem.add_dependency 'activerecord', '>=3.0.0beta2'
15
+ gem.add_dependency 'activesupport', '>=2.3.8'
16
+ gem.add_dependency 'activerecord', '>=2.3.8'
17
+ gem.add_dependency 'andand', '>=1.3.1'
17
18
  # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
18
19
  end
19
20
  Jeweler::GemcutterTasks.new
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.5
1
+ 0.0.6
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{honeypot}
8
- s.version = "0.0.5"
8
+ s.version = "0.0.6"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Seamus Abshere"]
@@ -27,6 +27,7 @@ Gem::Specification.new do |s|
27
27
  "lib/honeypot.rb",
28
28
  "lib/honeypot/ipaddr_ext.rb",
29
29
  "lib/honeypot/rack.rb",
30
+ "lib/honeypot/rails.rb",
30
31
  "lib/honeypot/railtie.rb",
31
32
  "lib/honeypot/remote_host.rb",
32
33
  "lib/honeypot/remote_request.rb",
@@ -50,19 +51,22 @@ Gem::Specification.new do |s|
50
51
  if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
51
52
  s.add_runtime_dependency(%q<fast_timestamp>, [">= 0.0.4"])
52
53
  s.add_runtime_dependency(%q<geokit>, [">= 1.5.0"])
53
- s.add_runtime_dependency(%q<activesupport>, [">= 3.0.0beta2"])
54
- s.add_runtime_dependency(%q<activerecord>, [">= 3.0.0beta2"])
54
+ s.add_runtime_dependency(%q<activesupport>, [">= 2.3.8"])
55
+ s.add_runtime_dependency(%q<activerecord>, [">= 2.3.8"])
56
+ s.add_runtime_dependency(%q<andand>, [">= 1.3.1"])
55
57
  else
56
58
  s.add_dependency(%q<fast_timestamp>, [">= 0.0.4"])
57
59
  s.add_dependency(%q<geokit>, [">= 1.5.0"])
58
- s.add_dependency(%q<activesupport>, [">= 3.0.0beta2"])
59
- s.add_dependency(%q<activerecord>, [">= 3.0.0beta2"])
60
+ s.add_dependency(%q<activesupport>, [">= 2.3.8"])
61
+ s.add_dependency(%q<activerecord>, [">= 2.3.8"])
62
+ s.add_dependency(%q<andand>, [">= 1.3.1"])
60
63
  end
61
64
  else
62
65
  s.add_dependency(%q<fast_timestamp>, [">= 0.0.4"])
63
66
  s.add_dependency(%q<geokit>, [">= 1.5.0"])
64
- s.add_dependency(%q<activesupport>, [">= 3.0.0beta2"])
65
- s.add_dependency(%q<activerecord>, [">= 3.0.0beta2"])
67
+ s.add_dependency(%q<activesupport>, [">= 2.3.8"])
68
+ s.add_dependency(%q<activerecord>, [">= 2.3.8"])
69
+ s.add_dependency(%q<andand>, [">= 1.3.1"])
66
70
  end
67
71
  end
68
72
 
@@ -1,5 +1,6 @@
1
1
  require 'ipaddr'
2
2
  require 'set'
3
+ require 'andand'
3
4
  require 'active_support'
4
5
  require 'active_support/version'
5
6
  %w{
@@ -26,7 +27,7 @@ module Honeypot
26
27
 
27
28
  def log_remote_request(request)
28
29
  effective_ip_address = [
29
- request.env['rack.session']['honeypot.last_known_remote_ip'].to_s,
30
+ request.env['rack.session'].andand['honeypot.last_known_remote_ip'].to_s,
30
31
  request.remote_ip.to_s
31
32
  ].detect(&:present?)
32
33
  remote_host = RemoteHost.find_or_create_by_ip_address effective_ip_address
@@ -8,8 +8,13 @@ module Honeypot
8
8
  end
9
9
 
10
10
  def call(env)
11
- if session = env['rack.session'] and raw_remote_ip = env['action_dispatch.remote_ip']
12
- remote_ip = IPAddr.new raw_remote_ip.to_s
11
+ raw_remote_ip = if env.has_key?('action_dispatch.remote_ip') # rails 3
12
+ env['action_dispatch.remote_ip']
13
+ elsif env.has_key?('action_controller.rescue.request') # rails 2
14
+ env['action_controller.rescue.request'].remote_ip
15
+ end
16
+ if raw_remote_ip and session = env['rack.session']
17
+ remote_ip = IPAddr.new raw_remote_ip.to_s
13
18
  session['honeypot.last_known_remote_ip'] = remote_ip.to_s if remote_ip.public?
14
19
  end
15
20
  @app.call env
@@ -0,0 +1,5 @@
1
+ require 'honeypot'
2
+
3
+ if defined?(::Rails.configuration) && ::Rails.configuration.respond_to?(:middleware)
4
+ ::Rails.configuration.middleware.insert_after 'ActionController::Failsafe', ::Honeypot::Rack
5
+ end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 5
9
- version: 0.0.5
8
+ - 6
9
+ version: 0.0.6
10
10
  platform: ruby
11
11
  authors:
12
12
  - Seamus Abshere
@@ -53,10 +53,10 @@ dependencies:
53
53
  - - ">="
54
54
  - !ruby/object:Gem::Version
55
55
  segments:
56
+ - 2
56
57
  - 3
57
- - 0
58
- - 0beta2
59
- version: 3.0.0beta2
58
+ - 8
59
+ version: 2.3.8
60
60
  type: :runtime
61
61
  version_requirements: *id003
62
62
  - !ruby/object:Gem::Dependency
@@ -67,12 +67,26 @@ dependencies:
67
67
  - - ">="
68
68
  - !ruby/object:Gem::Version
69
69
  segments:
70
+ - 2
70
71
  - 3
71
- - 0
72
- - 0beta2
73
- version: 3.0.0beta2
72
+ - 8
73
+ version: 2.3.8
74
74
  type: :runtime
75
75
  version_requirements: *id004
76
+ - !ruby/object:Gem::Dependency
77
+ name: andand
78
+ prerelease: false
79
+ requirement: &id005 !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ segments:
84
+ - 1
85
+ - 3
86
+ - 1
87
+ version: 1.3.1
88
+ type: :runtime
89
+ version_requirements: *id005
76
90
  description: Catch bad guys when they stick their hands in the honey.
77
91
  email: seamus@abshere.net
78
92
  executables: []
@@ -93,6 +107,7 @@ files:
93
107
  - lib/honeypot.rb
94
108
  - lib/honeypot/ipaddr_ext.rb
95
109
  - lib/honeypot/rack.rb
110
+ - lib/honeypot/rails.rb
96
111
  - lib/honeypot/railtie.rb
97
112
  - lib/honeypot/remote_host.rb
98
113
  - lib/honeypot/remote_request.rb