tcell_agent 0.2.4 → 0.2.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6a8919fddc03b6bf97fc9a8c6bd48d9703d870b9
4
- data.tar.gz: df20c9fadd9142dda76a34e9d37b90a351ef781d
3
+ metadata.gz: f2e3e8eaef2cd61c9cc3effe2b97fa731eeebecf
4
+ data.tar.gz: a10e24f2d47029ade958ac9b75ebb7f287abd825
5
5
  SHA512:
6
- metadata.gz: 3fe7bbdebfdb3e6c240e365b8b13a1ebc159e07f8481e9431fc7eb8bda7c61b1054e3d84a282b8c36731aec9bd5ebd8d1bbd369e89a52329ba0f46c884f9e340
7
- data.tar.gz: b1c209b6a3ad6dc3e2ceaffcd59e56de1c15fecf0d06a11c75250ae955ca38b62ed7655afedb349eb267c3b88451019c2cd029f66cc883f4470725d804ab7659
6
+ metadata.gz: e5f0910986b130a99684b68ed99fe5af1bef89f82a9a555a4dc6f233e4580d7ceeaa2b335fe02e85a79a34407d5f41202c14d5c7f3bb7151215a94e04e22e640
7
+ data.tar.gz: 79176adc5b5892cafcc7da924d1f0fcbcea066af31f2615c1744117975e8eae0a2a91b56f6a32b6638c778f60e09531e703d43275558c04a8d533327a69b7dca
data/lib/tcell_agent.rb CHANGED
@@ -3,14 +3,6 @@
3
3
  require 'tcell_agent/logger'
4
4
  require 'tcell_agent/configuration'
5
5
 
6
- module TCellAgent
7
- TCellAgent.logger.debug("Instrumenting")
8
- if (TCellAgent.configuration.enabled && TCellAgent.configuration.instrument_for_events)
9
- require 'tcell_agent/rails' if defined?(Rails)
10
- require 'tcell_agent/sinatra' if defined?(Sinatra)
11
- end
12
- end
13
-
14
6
  require 'tcell_agent/agent'
15
7
 
16
8
  require 'tcell_agent/policies/content_security_policy'
@@ -5,35 +5,74 @@ require 'tcell_agent/agent'
5
5
  require 'tcell_agent/configuration'
6
6
  require 'thread'
7
7
 
8
- TCellAgent.thread_agent.start
8
+ module TCellAgent
9
+ def self.run_instrumentation
10
+ TCellAgent.logger.debug("Instrumenting")
11
+ if (TCellAgent.configuration.enabled && TCellAgent.configuration.instrument_for_events)
12
+ require 'tcell_agent/rails' if defined?(Rails)
13
+ require 'tcell_agent/sinatra' if defined?(Sinatra)
14
+ end
15
+ end
16
+ end
9
17
 
10
18
  # creates a fork and pipes a string from parent to child
11
19
  if File.basename($0) != 'rake'
12
- if (File.basename($0) == 'rails' &&
13
- ((defined?(Thin) && (Rack::Handler.default == Rack::Handler::Thin)) ||
14
- (defined?(WEBrick) && (Rack::Handler.default == Rack::Handler::WEBrick))))
15
- TCellAgent.logger.debug("Initializing background thread: Thin")
16
- begin
17
- TCellAgent.thread_agent.start
18
- #TCellAgent.ensure_event_processor_running
19
- rescue Exception => e
20
- TCellAgent.logger.error("Could not start worker.", e.message)
20
+ tcell_server = ENV["TCELL_AGENT_SERVER"]
21
+ if tcell_server == nil
22
+ if (File.basename($0) == 'rails' &&
23
+ Rack::Handler.default &&
24
+ ((defined?(Thin) && (Rack::Handler.default == Rack::Handler::Thin)) ||
25
+ (defined?(WEBrick) && (Rack::Handler.default == Rack::Handler::WEBrick))))
26
+ tcell_server = "thin"
27
+ elsif defined?(Puma) && defined?(Puma.cli_config) && Puma.cli_config.options[:workers] > 1
28
+ tcell_server = "puma"
29
+ elsif defined?(Unicorn)
30
+ tcell_server = "unicorn"
31
+ elsif defined?(Puma)
32
+ tcell_server = "thin"
33
+ else
34
+ puts "[tCell.io] **********************************************************************"
35
+ puts "[tCell.io] Server used to launch rails not recognized."
36
+ puts "[tCell.io] You can override this with the env variable"
37
+ puts "[tCell.io] TCELL_AGENT_SERVER=thin|puma|unicorn"
38
+ puts "[tCell.io] **********************************************************************"
21
39
  end
22
- elsif defined?(Puma) && defined?(Puma.cli_config) && Puma.cli_config.options[:workers] > 1
23
- agent.start_event_processor(false)
24
- # preload app
40
+ end
41
+ if tcell_server != nil
42
+ if (tcell_server == "mock")
43
+ elsif (tcell_server == "thin" || tcell_server == "webrick")
44
+ TCellAgent.run_instrumentation
45
+ TCellAgent.logger.debug("Initializing background thread: Thin or webrick")
46
+ begin
47
+ TCellAgent.thread_agent.start
48
+ rescue Exception => e
49
+ TCellAgent.logger.error("Could not start worker.", e.message)
50
+ end
51
+ elsif (tcell_server == "puma")
52
+ TCellAgent.run_instrumentation
25
53
  TCellAgent.logger.debug("Initializing background thread: Puma Preload")
54
+ begin
55
+ TCellAgent.thread_agent.start
56
+ rescue Exception => e
57
+ TCellAgent.logger.error("Could not start worker.", e.message)
58
+ end
59
+ # preload app
26
60
  puma_worker_start = Proc.new do
27
61
  begin
28
62
  TCellAgent.thread_agent.start
29
- #TCellAgent.ensure_event_processor_running
30
63
  rescue Exception => e
31
64
  TCellAgent.logger.error("Could not start worker." + e.message)
32
65
  end
33
66
  end
34
67
  Puma.cli_config.options[:before_worker_boot].push(puma_worker_start)
35
- elsif defined?(Unicorn)
36
- TCellAgent.logger.debug("Initializing background thread: Unicorn Preload")
68
+ elsif (tcell_server == "unicorn")
69
+ TCellAgent.run_instrumentation
70
+ TCellAgent.logger.debug("Initializing background thread: Unicorn")
71
+ begin
72
+ TCellAgent.thread_agent.start
73
+ rescue Exception => e
74
+ TCellAgent.logger.error("Could not start worker.", e.message)
75
+ end
37
76
  class Unicorn::HttpServer
38
77
  alias _tcell_start spawn_missing_workers
39
78
  def spawn_missing_workers
@@ -48,20 +87,19 @@ if File.basename($0) != 'rake'
48
87
  TCellAgent.thread_agent.policy_polling_worker_mutex = Mutex.new
49
88
  TCellAgent.thread_agent.policy_polling_thread = nil
50
89
  TCellAgent.thread_agent.start
51
- #TCellAgent.ensure_event_processor_running
52
90
  rescue Exception => e
53
91
  TCellAgent.logger.error("Could not start worker.")
54
92
  end
55
93
  start_process
56
94
  end
57
95
  end
58
- else
59
- TCellAgent.logger.debug("Initializing background thread (no-preload).")
60
- begin
61
- TCellAgent.thread_agent.start
62
- rescue Exception => e
63
- TCellAgent.logger.error("Could not start worker.")
64
- end
96
+ else
97
+ puts "[tCell.io] **********************************************************************"
98
+ puts "[tCell.io] Unknown Server for starting rails: #{tcell_server}"
99
+ puts "[tCell.io] You can override this with the env variable"
100
+ puts "[tCell.io] TCELL_AGENT_SERVER=thin|puma|unicorn"
101
+ puts "[tCell.io] **********************************************************************"
102
+ end
65
103
  end
66
104
  end
67
105
 
@@ -1,5 +1,5 @@
1
1
  # See the file "LICENSE" for the full license governing this code.
2
2
 
3
3
  module TCellAgent
4
- VERSION = "0.2.4"
4
+ VERSION = "0.2.5"
5
5
  end
data/spec/spec_helper.rb CHANGED
@@ -1,6 +1,8 @@
1
1
  require 'rspec'
2
2
  require 'rails'
3
3
  require 'webmock/rspec'
4
+
5
+ ENV['TCELL_AGENT_SERVER'] = "mock"
4
6
  require File.join(File.dirname(__FILE__), '..', 'lib', 'tcell_agent')
5
7
 
6
8
  module TCellAgent
@@ -18,3 +20,5 @@ module TCellAgent
18
20
  self.thread_agent = thread_agent
19
21
  end
20
22
  end
23
+
24
+ TCellAgent.run_instrumentation
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tcell_agent
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Garrett
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-01-08 00:00:00.000000000 Z
11
+ date: 2016-01-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client
@@ -117,24 +117,20 @@ executables:
117
117
  extensions: []
118
118
  extra_rdoc_files: []
119
119
  files:
120
- - LICENSE
121
- - README.md
122
120
  - Rakefile
123
- - bin/tcell_agent
124
- - lib/tcell_agent.rb
125
- - lib/tcell_agent/agent.rb
126
121
  - lib/tcell_agent/agent/event_processor.rb
127
122
  - lib/tcell_agent/agent/fork_pipe_manager.rb
128
123
  - lib/tcell_agent/agent/policy_manager.rb
129
124
  - lib/tcell_agent/agent/policy_types.rb
130
125
  - lib/tcell_agent/agent/route_manager.rb
131
126
  - lib/tcell_agent/agent/static_agent.rb
127
+ - lib/tcell_agent/agent.rb
132
128
  - lib/tcell_agent/api.rb
133
- - lib/tcell_agent/appsensor.rb
134
129
  - lib/tcell_agent/appsensor/cmdi.rb
135
130
  - lib/tcell_agent/appsensor/path_traversal.rb
136
131
  - lib/tcell_agent/appsensor/sqli.rb
137
132
  - lib/tcell_agent/appsensor/xss.rb
133
+ - lib/tcell_agent/appsensor.rb
138
134
  - lib/tcell_agent/authlogic.rb
139
135
  - lib/tcell_agent/configuration.rb
140
136
  - lib/tcell_agent/devise.rb
@@ -149,7 +145,6 @@ files:
149
145
  - lib/tcell_agent/policies/http_tx_policy.rb
150
146
  - lib/tcell_agent/policies/login_fraud_policy.rb
151
147
  - lib/tcell_agent/policies/secure_headers_policy.rb
152
- - lib/tcell_agent/rails.rb
153
148
  - lib/tcell_agent/rails/auth/authlogic.rb
154
149
  - lib/tcell_agent/rails/auth/devise.rb
155
150
  - lib/tcell_agent/rails/dlp.rb
@@ -159,6 +154,7 @@ files:
159
154
  - lib/tcell_agent/rails/middleware/headers_middleware.rb
160
155
  - lib/tcell_agent/rails/routes.rb
161
156
  - lib/tcell_agent/rails/settings_reporter.rb
157
+ - lib/tcell_agent/rails.rb
162
158
  - lib/tcell_agent/routes/table.rb
163
159
  - lib/tcell_agent/sensor_events/app_config.rb
164
160
  - lib/tcell_agent/sensor_events/app_sensor.rb
@@ -177,6 +173,7 @@ files:
177
173
  - lib/tcell_agent/userinfo.rb
178
174
  - lib/tcell_agent/utils/queue_with_timeout.rb
179
175
  - lib/tcell_agent/version.rb
176
+ - lib/tcell_agent.rb
180
177
  - spec/controllers/application_controller.rb
181
178
  - spec/lib/tcell_agent/api/api_spec.rb
182
179
  - spec/lib/tcell_agent/appsensor_spec.rb
@@ -198,7 +195,10 @@ files:
198
195
  - spec/lib/tcell_agent_spec.rb
199
196
  - spec/resources/normal_config.json
200
197
  - spec/spec_helper.rb
198
+ - README.md
199
+ - LICENSE
201
200
  - tcell_agent.gemspec
201
+ - bin/tcell_agent
202
202
  homepage: https://www.tcell.io
203
203
  licenses:
204
204
  - Copyright (c) 2015 tCell.io (see LICENSE file)
@@ -221,7 +221,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
221
221
  version: '0'
222
222
  requirements: []
223
223
  rubyforge_project:
224
- rubygems_version: 2.4.8
224
+ rubygems_version: 2.0.14
225
225
  signing_key:
226
226
  specification_version: 4
227
227
  summary: tCell.io Agent for Rails & Sinatra