logjam_agent 0.9.2 → 0.9.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZDYzMWNjYjFmNzcxZTcxZTE4NGM2MzFlZDMyMDFjMzBmNjk1MGI4NQ==
4
+ OGE1MWZkYjNjYzNjYzQ5MzkyZjQzMGEzMjZmMTBhOTE0YWM5YzdiZQ==
5
5
  data.tar.gz: !binary |-
6
- ZmU5ZTUwYTFjODkxYzgxZDZhMDkyNzY3YTNlYjZjNGEyZDlhNmRiMA==
6
+ YjJhZWU1YjdiNjYwYzM4ZDRjNDQ5NzNhY2I3YzE5Njc0NjFhYTBhMg==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- ZWY1OGE4NGU2MzMyZjM2YWM4NmFmOWZjZjA3OTQwMjZiOGMzY2FmNzM3MjVl
10
- MzJiYWRkMmFjMTJlNjZiMWZkYmJmYTc3MzBhYzNjNzNmNDBiNGQ5NjU2YWQw
11
- NTRiNDU5OTk4ZjY1ZjhmY2ZkZmYxMDVjYTMxMTc3MjE0NTgzOGI=
9
+ Y2M2NmJhZDRjZTJlOWM2M2ZjNDg1ZDIxODVkYTIwZmExYTE0MDhjOWIyOGEz
10
+ MWM5NmQ1YWQ0YjNjNjE1ZDEyNTM2NjU2ODI0NzY2YTY3NWFiYjA3OTY1ZTVi
11
+ MjA2NGNlOTA4MzZhZmNhODQwZjA4MGFiM2NhZjVmMWFjOWUyNzA=
12
12
  data.tar.gz: !binary |-
13
- ZDM2NWQwYjIxMTRkNTJkM2E0MGFiNjNmOTFkMmJhMmQ3ZTI0NWQ4NmY4M2Ex
14
- Zjk0OGM5YzBjZWEyM2YzYTE4YTZkY2IyMWMxYjAyZTQ2YmRjNjhjZWQzNThh
15
- NmYxN2ZjMWI0MTY3ODRmOTc3MWJmZTU5NjU5OGQwZDkwYWZhNzk=
13
+ NWRjZGIyZjFlMzg1YmJjYWI5ZWIxYzYwMDU5ZWZjNWQwODdhYzE0YTcxNTZl
14
+ MmJlNmJmMWE3Mjg5YmJhZTFhZDE3YjllNjY0NWFkZDJkMjhmMGRkNTAzZDVl
15
+ NzZkOWNjNGYzZjVkNzY4ZDUxNGQxYjQzNTM4YmU3M2ZlZTliMWI=
data/README.md CHANGED
@@ -38,7 +38,7 @@ module LogjamAgent
38
38
  # Configure request data forwarder for ZeroMQ.
39
39
  add_forwarder(:zmq, :host => "logjam.instance.at.your.org", :port => 9605)
40
40
 
41
- # Configure request data forwarder for ZeroMQ.
41
+ # Configure request data forwarder for AMQP.
42
42
  # add_forwarder(:amqp, :host => "message.broker.at.your.org"))
43
43
 
44
44
  # Configure ip obfuscation. Defaults to no obfuscation.
@@ -49,6 +49,19 @@ module LogjamAgent
49
49
  end
50
50
  ```
51
51
 
52
+ ### Generating unique request ids
53
+
54
+ The agent generates unique request ids for all request handled. It
55
+ will use [uuid4r](https://github.com/skaes/uuid4r) if this is
56
+ avalaibale in the application. Otherwise it will fall back to use the
57
+ standard `SecureRandom` class shipped with Ruby.
58
+
59
+ ### Generating JSON
60
+
61
+ The agent will try to use the [Oj](https://github.com/ohler55/oj) to
62
+ generate JSON. If this is not available in your application, it will
63
+ fall back to the `to_json` method.
64
+
52
65
  ## Troubleshooting
53
66
 
54
67
  If the agent experiences problems when sending data, it will log information to a file named
data/lib/logjam_agent.rb CHANGED
@@ -91,7 +91,7 @@ module LogjamAgent
91
91
  self.obfuscate_ips = false
92
92
 
93
93
  # TODO: ipv6 obfuscation
94
- def self.ip_fuscator(ip)
94
+ def self.ip_obfuscator(ip)
95
95
  obfuscate_ips ? ip.to_s.sub(/\d+\z/, 'XXX') : ip
96
96
  end
97
97
 
@@ -53,7 +53,7 @@ module LogjamAgent
53
53
  path = request.filtered_path
54
54
 
55
55
  logjam_fields = LogjamAgent.request.fields
56
- ip = LogjamAgent.ip_fuscator(request.remote_ip)
56
+ ip = LogjamAgent.ip_obfuscator(request.ip)
57
57
  logjam_fields.merge!(:started_at => start_time.iso8601, :ip => ip, :host => @hostname)
58
58
  logjam_fields.merge!(extract_request_info(request))
59
59
 
@@ -69,6 +69,38 @@ module LogjamAgent
69
69
  end
70
70
  end
71
71
  end
72
+
73
+ # patch rack so that the ip method returns the same result as rails remote_ip (modulo exceptions)
74
+ app.config.after_initialize do
75
+ if app.config.action_dispatch.trusted_proxies
76
+ trusted_proxies = /^127\.0\.0\.1$|^(10|172\.(1[6-9]|2[0-9]|30|31)|192\.168)\.|^::1$|^fd[0-9a-f]{2}:.+|^localhost$/i
77
+ trusted_proxies = Regexp.union(trusted_proxies, app.config.action_dispatch.trusted_proxies)
78
+ ::Rack::Request.class_eval <<-"EVA"
79
+ def trusted_proxy?(ip)
80
+ ip =~ #{trusted_proxies.inspect}
81
+ end
82
+ EVA
83
+ end
84
+
85
+ ::Rack::Request.class_eval <<-EVA
86
+ def ip
87
+ remote_addrs = @env['REMOTE_ADDR'] ? @env['REMOTE_ADDR'].split(/[,\s]+/) : []
88
+ remote_addrs.reject! { |addr| trusted_proxy?(addr) }
89
+
90
+ return remote_addrs.first if remote_addrs.any?
91
+
92
+ forwarded_ips = @env['HTTP_X_FORWARDED_FOR'] ? @env['HTTP_X_FORWARDED_FOR'].strip.split(/[,\s]+/) : []
93
+
94
+ if client_ip = @env['HTTP_TRUE_CLIENT_IP'] || @env['HTTP_CLIENT_IP']
95
+ # If forwarded_ips doesn't include the client_ip, it might be an
96
+ # ip spoofing attempt, so we ignore HTTP_CLIENT_IP
97
+ return client_ip if forwarded_ips.include?(client_ip)
98
+ end
99
+
100
+ return forwarded_ips.reject { |ip| trusted_proxy?(ip) }.last || @env["REMOTE_ADDR"]
101
+ end
102
+ EVA
103
+ end
72
104
  end
73
105
 
74
106
  # avoid garbled tempfile information in the logs
@@ -1,3 +1,3 @@
1
1
  module LogjamAgent
2
- VERSION = "0.9.2"
2
+ VERSION = "0.9.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logjam_agent
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.2
4
+ version: 0.9.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stefan Kaes
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-09-30 00:00:00.000000000 Z
11
+ date: 2013-11-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement