honeypot 0.0.3 → 0.0.4
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/README.rdoc +3 -5
- data/VERSION +1 -1
- data/honeypot.gemspec +2 -2
- data/lib/honeypot.rb +12 -3
- data/lib/honeypot/railtie.rb +2 -2
- metadata +3 -3
data/README.rdoc
CHANGED
@@ -29,7 +29,7 @@ when somebody touches a honeypot, make sure to log it:
|
|
29
29
|
class UsersController < ApplicationController
|
30
30
|
def create
|
31
31
|
# [...]
|
32
|
-
@user.log_remote_request(
|
32
|
+
@user.log_remote_request(request)
|
33
33
|
# [...]
|
34
34
|
end
|
35
35
|
end
|
@@ -37,7 +37,7 @@ when somebody touches a honeypot, make sure to log it:
|
|
37
37
|
class VotesController < ApplicationController
|
38
38
|
def create
|
39
39
|
# [...]
|
40
|
-
@vote.log_remote_request(
|
40
|
+
@vote.log_remote_request(request)
|
41
41
|
# [...]
|
42
42
|
end
|
43
43
|
end
|
@@ -48,13 +48,11 @@ and be creative...
|
|
48
48
|
# notice when a User logs in
|
49
49
|
def create
|
50
50
|
# [...]
|
51
|
-
current_user.log_remote_request(
|
51
|
+
current_user.log_remote_request(request)
|
52
52
|
# [...]
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
56
|
-
you pass both the session and the request so that you have the maximum chance of getting a real remote ip
|
57
|
-
|
58
56
|
== migration
|
59
57
|
|
60
58
|
create_table "remote_hosts" do |t|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.4
|
data/honeypot.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{honeypot}
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.4"
|
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"]
|
12
|
-
s.date = %q{2010-05-
|
12
|
+
s.date = %q{2010-05-13}
|
13
13
|
s.description = %q{Catch bad guys when they stick their hands in the honey.}
|
14
14
|
s.email = %q{seamus@abshere.net}
|
15
15
|
s.extra_rdoc_files = [
|
data/lib/honeypot.rb
CHANGED
@@ -1,6 +1,12 @@
|
|
1
1
|
require 'ipaddr'
|
2
2
|
require 'set'
|
3
3
|
require 'active_support'
|
4
|
+
require 'active_support/version'
|
5
|
+
%w{
|
6
|
+
active_support/core_ext/object/blank
|
7
|
+
}.each do |active_support_3_requirement|
|
8
|
+
require active_support_3_requirement
|
9
|
+
end if ActiveSupport::VERSION::MAJOR == 3
|
4
10
|
require 'active_record'
|
5
11
|
require 'fast_timestamp'
|
6
12
|
require 'honeypot/ipaddr_ext'
|
@@ -18,12 +24,15 @@ module Honeypot
|
|
18
24
|
end
|
19
25
|
end
|
20
26
|
|
21
|
-
def log_remote_request(
|
22
|
-
effective_ip_address =
|
27
|
+
def log_remote_request(request)
|
28
|
+
effective_ip_address = [
|
29
|
+
request.env['rack.session']['honeypot.last_known_remote_ip'].to_s,
|
30
|
+
request.remote_ip.to_s
|
31
|
+
].detect(&:present?)
|
23
32
|
remote_host = RemoteHost.find_or_create_by_ip_address effective_ip_address
|
24
33
|
remote_request = remote_requests.find_or_create_by_remote_host_id remote_host.id
|
25
34
|
remote_request.last_http_referer = request.referer if request.referer.present?
|
26
|
-
remote_request.last_request_uri = request.
|
35
|
+
remote_request.last_request_uri = request.url if request.url.present?
|
27
36
|
remote_request.increment :hits
|
28
37
|
remote_request.save!
|
29
38
|
true
|
data/lib/honeypot/railtie.rb
CHANGED
@@ -3,8 +3,8 @@ require 'rails'
|
|
3
3
|
|
4
4
|
module Honeypot
|
5
5
|
class Railtie < Rails::Railtie
|
6
|
-
initializer
|
7
|
-
app.middleware.
|
6
|
+
initializer 'honeypot.configure_rails_initialization' do |app|
|
7
|
+
app.middleware.insert_after 'ActionDispatch::RemoteIp', ::Honeypot::Rack
|
8
8
|
end
|
9
9
|
end
|
10
10
|
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 0.0.
|
8
|
+
- 4
|
9
|
+
version: 0.0.4
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Seamus Abshere
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-05-
|
17
|
+
date: 2010-05-13 00:00:00 -04:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|