tcell_agent 1.1.3 → 1.1.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.
Files changed (118) hide show
  1. checksums.yaml +4 -4
  2. data/bin/tcell_agent +10 -2
  3. data/lib/tcell_agent.rb +3 -3
  4. data/lib/tcell_agent/agent.rb +42 -52
  5. data/lib/tcell_agent/agent/event_processor.rb +129 -162
  6. data/lib/tcell_agent/agent/fork_pipe_manager.rb +57 -62
  7. data/lib/tcell_agent/agent/policy_manager.rb +83 -104
  8. data/lib/tcell_agent/agent/policy_types.rb +24 -29
  9. data/lib/tcell_agent/agent/route_manager.rb +36 -46
  10. data/lib/tcell_agent/agent/static_agent.rb +19 -21
  11. data/lib/tcell_agent/api.rb +23 -28
  12. data/lib/tcell_agent/appsensor/injections_reporter.rb +7 -11
  13. data/lib/tcell_agent/authlogic.rb +7 -7
  14. data/lib/tcell_agent/cmdi.rb +22 -23
  15. data/lib/tcell_agent/config/unknown_options.rb +71 -69
  16. data/lib/tcell_agent/configuration.rb +187 -191
  17. data/lib/tcell_agent/devise.rb +13 -15
  18. data/lib/tcell_agent/hooks/login_fraud.rb +1 -1
  19. data/lib/tcell_agent/instrumentation.rb +120 -124
  20. data/lib/tcell_agent/logger.rb +29 -45
  21. data/lib/tcell_agent/patches.rb +5 -5
  22. data/lib/tcell_agent/policies/dataloss_policy.rb +263 -288
  23. data/lib/tcell_agent/policies/http_redirect_policy.rb +25 -37
  24. data/lib/tcell_agent/policies/http_tx_policy.rb +48 -52
  25. data/lib/tcell_agent/policies/login_fraud_policy.rb +15 -20
  26. data/lib/tcell_agent/policies/policy.rb +0 -2
  27. data/lib/tcell_agent/policies/rust_policies.rb +24 -29
  28. data/lib/tcell_agent/rails.rb +2 -3
  29. data/lib/tcell_agent/rails/auth/authlogic.rb +2 -2
  30. data/lib/tcell_agent/rails/auth/devise.rb +2 -2
  31. data/lib/tcell_agent/rails/auth/doorkeeper.rb +2 -2
  32. data/lib/tcell_agent/rails/better_ip.rb +12 -16
  33. data/lib/tcell_agent/rails/csrf_exception.rb +4 -7
  34. data/lib/tcell_agent/rails/dlp.rb +208 -107
  35. data/lib/tcell_agent/rails/dlp/process_request.rb +37 -47
  36. data/lib/tcell_agent/rails/dlp_handler.rb +9 -11
  37. data/lib/tcell_agent/rails/js_agent_insert.rb +11 -14
  38. data/lib/tcell_agent/rails/middleware/body_filter_middleware.rb +8 -7
  39. data/lib/tcell_agent/rails/middleware/context_middleware.rb +4 -5
  40. data/lib/tcell_agent/rails/middleware/global_middleware.rb +5 -8
  41. data/lib/tcell_agent/rails/middleware/headers_middleware.rb +24 -27
  42. data/lib/tcell_agent/rails/on_start.rb +5 -5
  43. data/lib/tcell_agent/rails/responses.rb +7 -9
  44. data/lib/tcell_agent/rails/routes.rb +62 -81
  45. data/lib/tcell_agent/rails/routes/grape.rb +25 -30
  46. data/lib/tcell_agent/rails/routes/route_id.rb +9 -14
  47. data/lib/tcell_agent/rails/settings_reporter.rb +44 -33
  48. data/lib/tcell_agent/rails/tcell_body_proxy.rb +15 -18
  49. data/lib/tcell_agent/routes/table.rb +31 -33
  50. data/lib/tcell_agent/rust/{libtcellagent-1.3.0.dylib → libtcellagent-1.3.1.dylib} +0 -0
  51. data/lib/tcell_agent/rust/{libtcellagent-1.3.0.so → libtcellagent-1.3.1.so} +0 -0
  52. data/lib/tcell_agent/rust/{libtcellagent-alpine-1.3.0.so → libtcellagent-alpine-1.3.1.so} +0 -0
  53. data/lib/tcell_agent/rust/models.rb +32 -37
  54. data/lib/tcell_agent/rust/tcellagent-1.3.1.dll +0 -0
  55. data/lib/tcell_agent/rust/whisperer.rb +101 -104
  56. data/lib/tcell_agent/sensor_events/app_config.rb +7 -7
  57. data/lib/tcell_agent/sensor_events/appsensor_event.rb +26 -27
  58. data/lib/tcell_agent/sensor_events/appsensor_meta_event.rb +20 -88
  59. data/lib/tcell_agent/sensor_events/command_injection.rb +52 -80
  60. data/lib/tcell_agent/sensor_events/discovery.rb +27 -27
  61. data/lib/tcell_agent/sensor_events/dlp.rb +50 -56
  62. data/lib/tcell_agent/sensor_events/honeytokens.rb +9 -9
  63. data/lib/tcell_agent/sensor_events/metrics.rb +20 -21
  64. data/lib/tcell_agent/sensor_events/patches.rb +10 -12
  65. data/lib/tcell_agent/sensor_events/sensor.rb +32 -36
  66. data/lib/tcell_agent/sensor_events/server_agent.rb +130 -127
  67. data/lib/tcell_agent/sensor_events/util/sanitizer_utilities.rb +60 -80
  68. data/lib/tcell_agent/sensor_events/util/utils.rb +3 -5
  69. data/lib/tcell_agent/servers/passenger.rb +5 -9
  70. data/lib/tcell_agent/servers/puma.rb +18 -27
  71. data/lib/tcell_agent/servers/rails_server.rb +5 -9
  72. data/lib/tcell_agent/servers/thin.rb +2 -4
  73. data/lib/tcell_agent/servers/unicorn.rb +18 -27
  74. data/lib/tcell_agent/servers/webrick.rb +2 -4
  75. data/lib/tcell_agent/settings_reporter.rb +126 -0
  76. data/lib/tcell_agent/sinatra.rb +24 -26
  77. data/lib/tcell_agent/start_background_thread.rb +21 -142
  78. data/lib/tcell_agent/system_info.rb +4 -3
  79. data/lib/tcell_agent/tcell_context.rb +150 -0
  80. data/lib/tcell_agent/userinfo.rb +3 -3
  81. data/lib/tcell_agent/utils/io.rb +19 -24
  82. data/lib/tcell_agent/utils/params.rb +9 -15
  83. data/lib/tcell_agent/utils/queue_with_timeout.rb +26 -32
  84. data/lib/tcell_agent/utils/strings.rb +4 -6
  85. data/lib/tcell_agent/version.rb +1 -1
  86. data/spec/lib/tcell_agent/agent/policy_manager_spec.rb +5 -5
  87. data/spec/lib/tcell_agent/agent/static_agent_spec.rb +7 -7
  88. data/spec/lib/tcell_agent/cmdi_spec.rb +21 -21
  89. data/spec/lib/tcell_agent/hooks/login_fraud_spec.rb +29 -24
  90. data/spec/lib/tcell_agent/instrumentation_spec.rb +4 -4
  91. data/spec/lib/tcell_agent/patches_spec.rb +8 -8
  92. data/spec/lib/tcell_agent/policies/appsensor_policy_spec.rb +23 -23
  93. data/spec/lib/tcell_agent/policies/patches_policy_spec.rb +2 -2
  94. data/spec/lib/tcell_agent/rails/csrf_exception_spec.rb +69 -0
  95. data/spec/lib/tcell_agent/rails/dlp_spec.rb +1039 -0
  96. data/spec/lib/tcell_agent/rails/js_agent_insert_spec.rb +271 -0
  97. data/spec/lib/tcell_agent/rails/logger_spec.rb +5 -5
  98. data/spec/lib/tcell_agent/rails/middleware/appsensor_middleware_spec.rb +3 -3
  99. data/spec/lib/tcell_agent/rails/middleware/dlp_middleware_spec.rb +4 -4
  100. data/spec/lib/tcell_agent/rails/middleware/global_middleware_spec.rb +5 -5
  101. data/spec/lib/tcell_agent/rails/middleware/redirect_middleware_spec.rb +1 -1
  102. data/spec/lib/tcell_agent/rails/middleware/tcell_body_proxy_spec.rb +11 -8
  103. data/spec/lib/tcell_agent/rails/responses_spec.rb +2 -2
  104. data/spec/lib/tcell_agent/rails/routes/grape_spec.rb +2 -2
  105. data/spec/lib/tcell_agent/rails/routes/route_id_spec.rb +1 -1
  106. data/spec/lib/tcell_agent/rails/routes/routes_spec.rb +4 -4
  107. data/spec/lib/tcell_agent/rust/models_spec.rb +83 -75
  108. data/spec/lib/tcell_agent/rust/whisperer_spec.rb +14 -14
  109. data/spec/lib/tcell_agent/sensor_events/appsensor_meta_event_spec.rb +19 -70
  110. data/spec/lib/tcell_agent/sensor_events/sessions_metric_spec.rb +1 -1
  111. data/spec/lib/tcell_agent/settings_reporter_spec.rb +162 -0
  112. data/spec/lib/tcell_agent/tcell_context_spec.rb +154 -0
  113. data/spec/spec_helper.rb +5 -0
  114. metadata +18 -10
  115. data/lib/tcell_agent/appsensor/meta_data.rb +0 -132
  116. data/lib/tcell_agent/patches/meta_data.rb +0 -59
  117. data/lib/tcell_agent/rust/tcellagent-1.3.0.dll +0 -0
  118. data/spec/lib/tcell_agent/appsensor/meta_data_spec.rb +0 -71
@@ -1,8 +1,8 @@
1
1
  module TCellAgent
2
2
  class UserInformation
3
3
  # Devise
4
- def self.getUserFromRequest(request)
5
- return nil
4
+ def self.get_user_from_request(_request)
5
+ nil
6
6
  end
7
7
  end
8
- end
8
+ end
@@ -1,43 +1,38 @@
1
- require "pathname"
2
- require "tcell_agent/instrumentation"
3
- require "tcell_agent/utils/strings"
4
-
1
+ require 'pathname'
2
+ require 'tcell_agent/instrumentation'
3
+ require 'tcell_agent/utils/strings'
5
4
 
6
5
  module TCellAgent
7
6
  module Utils
8
7
  module IO
8
+ def self.create_directory(dir, owner = nil)
9
+ return if File.directory?(dir)
9
10
 
10
- def self.create_directory(dir, owner=nil)
11
- unless File.directory?(dir)
12
- directories = Pathname(dir).each_filename.to_a
11
+ directories = Pathname(dir).each_filename.to_a
13
12
 
14
- return if directories.size < 1
13
+ return if directories.empty?
15
14
 
16
- memoized_path = File::SEPARATOR
15
+ memoized_path = File::SEPARATOR
17
16
 
18
- directories.each do |directory|
19
- memoized_path = File.join(memoized_path, directory)
20
- unless File.directory?(memoized_path)
21
- FileUtils.mkdir(memoized_path)
17
+ directories.each do |directory|
18
+ memoized_path = File.join(memoized_path, directory)
19
+ next if File.directory?(memoized_path)
20
+ FileUtils.mkdir(memoized_path)
22
21
 
23
- if TCellAgent::Utils::Strings.present?(owner)
24
- TCellAgent::Instrumentation.safe_block("Ignoring agent_home_owner value, insufficient privileges") do
25
- FileUtils.chown( owner, nil, memoized_path)
26
- end
27
- end
28
- end
22
+ next unless TCellAgent::Utils::Strings.present?(owner)
23
+ TCellAgent::Instrumentation.safe_block('Ignoring agent_home_owner value, insufficient privileges') do
24
+ FileUtils.chown(owner, nil, memoized_path)
29
25
  end
30
26
  end
31
27
  end
32
28
 
33
- def self.set_owner(filename, owner=nil)
34
- TCellAgent::Instrumentation.safe_block("Ignoring agent_home_owner value, insufficient privileges") do
35
- if TCellAgent::Utils::Strings.present?(owner) && File.exists?(filename)
36
- FileUtils.chown( owner, nil, filename )
29
+ def self.set_owner(filename, owner = nil)
30
+ TCellAgent::Instrumentation.safe_block('Ignoring agent_home_owner value, insufficient privileges') do
31
+ if TCellAgent::Utils::Strings.present?(owner) && File.exist?(filename)
32
+ FileUtils.chown(owner, nil, filename)
37
33
  end
38
34
  end
39
35
  end
40
-
41
36
  end
42
37
  end
43
38
  end
@@ -1,16 +1,16 @@
1
1
  module TCellAgent
2
2
  module Utils
3
3
  module Params
4
- GET_PARAM = "get"
5
- POST_PARAM = "post"
6
- JSON_PARAM = "json"
7
- URI_PARAM = "uri"
8
- COOKIE_PARAM = "cookies"
9
- HEADER_PARAM = "header"
4
+ GET_PARAM = 'get'.freeze
5
+ POST_PARAM = 'post'.freeze
6
+ JSON_PARAM = 'json'.freeze
7
+ URI_PARAM = 'uri'.freeze
8
+ COOKIE_PARAM = 'cookies'.freeze
9
+ HEADER_PARAM = 'header'.freeze
10
10
 
11
- def self.flatten(param_dict, namespace=nil)
11
+ def self.flatten(param_dict, namespace = nil)
12
12
  flattened = {}
13
- namespace = [] unless namespace
13
+ namespace ||= []
14
14
  (param_dict || {}).each do |param_name, param_value|
15
15
  if param_value.is_a?(Hash)
16
16
  flattened = flattened.merge(flatten(param_value, namespace.dup << param_name.to_s))
@@ -22,23 +22,17 @@ module TCellAgent
22
22
  flattened = flattened.merge(flatten(val, new_namespace))
23
23
  elsif val.is_a?(String) || val.is_a?(Symbol)
24
24
  flattened[new_namespace.freeze] = val.to_s
25
- else
26
- # DROP any unrecognized types (like Tempfiles and other such possible things)
27
25
  end
28
26
  end
29
27
 
30
28
  elsif param_value.is_a?(String) || param_value.is_a?(Symbol)
31
29
  new_key = namespace.dup << param_name.to_s
32
30
  flattened[new_key.freeze] = param_value.to_s
33
-
34
- else
35
- # DROP any unrecognized types (like Tempfiles and other such possible things)
36
31
  end
37
32
  end
38
33
 
39
- return flattened
34
+ flattened
40
35
  end
41
-
42
36
  end
43
37
  end
44
38
  end
@@ -1,13 +1,11 @@
1
1
  # See the file "LICENSE" for the full license governing this code.
2
2
 
3
- require "tcell_agent/logger"
3
+ require 'tcell_agent/logger'
4
4
  require 'thread'
5
5
  require 'logger'
6
6
 
7
7
  module TCellAgent
8
-
9
8
  class BoundedQueue
10
-
11
9
  def initialize(max_size = :infinite)
12
10
  @lock = Mutex.new
13
11
  @items = []
@@ -16,16 +14,17 @@ module TCellAgent
16
14
  @space_available = ConditionVariable.new
17
15
  end
18
16
 
19
- def push(obj, timeout=:never, &timeout_policy)
20
- timeout_policy ||= -> do
21
- raise "Push timed out"
17
+ def push(obj, timeout = :never, &timeout_policy)
18
+ timeout_policy ||= lambda do
19
+ raise 'Push timed out'
22
20
  end
23
21
 
24
22
  wait_for_condition(
25
23
  @space_available,
26
- ->{!full?},
24
+ -> { !full? },
27
25
  timeout,
28
- timeout_policy) do
26
+ timeout_policy
27
+ ) do
29
28
 
30
29
  @items.push(obj)
31
30
  @item_available.signal
@@ -33,12 +32,13 @@ module TCellAgent
33
32
  end
34
33
 
35
34
  def pop(timeout = :never, &timeout_policy)
36
- timeout_policy ||= ->{nil}
35
+ timeout_policy ||= -> { nil }
37
36
  wait_for_condition(
38
37
  @item_available,
39
- ->{@items.any?},
38
+ -> { @items.any? },
40
39
  timeout,
41
- timeout_policy) do
40
+ timeout_policy
41
+ ) do
42
42
 
43
43
  item = @items.shift
44
44
  @space_available.signal
@@ -58,36 +58,32 @@ module TCellAgent
58
58
 
59
59
  private
60
60
 
61
- def wait_for_condition(cv, condition_predicate, timeout=:never, timeout_policy=->{nil})
62
-
61
+ def wait_for_condition(condition_variable, condition_predicate, timeout = :never, timeout_policy = -> { nil })
63
62
  deadline = timeout == :never ? :never : Time.now + timeout
64
63
 
65
64
  @lock.synchronize do
66
-
67
65
  loop do
68
66
  cv_timeout = timeout == :never ? nil : deadline - Time.now
69
67
 
70
68
  if !condition_predicate.call && cv_timeout.to_f >= 0
71
- cv.wait(@lock, cv_timeout)
69
+ condition_variable.wait(@lock, cv_timeout)
72
70
  end
73
71
 
74
- if condition_predicate.call
72
+ if condition_predicate.call # rubocop:disable Style/GuardClause
75
73
  return yield
76
74
 
77
- elsif :never == deadline || deadline > Time.now
75
+ elsif :never == deadline || deadline > Time.now # rubocop:disable Style/YodaCondition
78
76
  next
79
77
 
80
78
  else
81
79
  return timeout_policy.call
82
80
  end
83
81
  end
84
-
85
82
  end
86
83
  end
87
84
  end
88
85
 
89
86
  class QueueWithTimeout
90
-
91
87
  def initialize
92
88
  @mutex = Mutex.new
93
89
  @queue = []
@@ -95,7 +91,7 @@ module TCellAgent
95
91
  @recieved = ConditionVariable.new
96
92
  end
97
93
 
98
- def <<(x)
94
+ def <<(x) # rubocop:disable Naming/UncommunicativeMethodParamName
99
95
  @mutex.synchronize do
100
96
  @queue << x
101
97
  @recieved.signal
@@ -104,23 +100,21 @@ module TCellAgent
104
100
 
105
101
  def add_response_time(route_id, response_time)
106
102
  @mutex.synchronize do
107
- if (route_id == nil || route_id == "")
108
- route_id = "?"
109
- end
110
- @response_time_table[route_id] = @response_time_table.fetch(route_id,{})
111
- @response_time_table[route_id]["c"] = @response_time_table[route_id].fetch("c",0) + 1
112
- @response_time_table[route_id]["mx"] = [@response_time_table[route_id].fetch("mx",0), response_time].max
113
- @response_time_table[route_id]["mn"] = [@response_time_table[route_id].fetch("mn",response_time), response_time].min
114
- @response_time_table[route_id]["t"] = ((@response_time_table[route_id].fetch("t",0)*(@response_time_table[route_id]["c"]-1)) + response_time) / @response_time_table[route_id]["c"]
103
+ route_id = '?' if route_id.nil? || route_id == ''
104
+ @response_time_table[route_id] = @response_time_table.fetch(route_id, {})
105
+ @response_time_table[route_id]['c'] = @response_time_table[route_id].fetch('c', 0) + 1
106
+ @response_time_table[route_id]['mx'] = [@response_time_table[route_id].fetch('mx', 0), response_time].max
107
+ @response_time_table[route_id]['mn'] = [@response_time_table[route_id].fetch('mn', response_time), response_time].min
108
+ @response_time_table[route_id]['t'] = ((@response_time_table[route_id].fetch('t', 0) * (@response_time_table[route_id]['c'] - 1)) + response_time) / @response_time_table[route_id]['c']
115
109
  end
116
110
  end
117
111
 
118
112
  def length
119
- return @queue.length
113
+ @queue.length
120
114
  end
121
115
 
122
116
  def get_response_time_table
123
- return @response_time_table
117
+ @response_time_table
124
118
  end
125
119
 
126
120
  def reset_response_time_table
@@ -137,9 +131,9 @@ module TCellAgent
137
131
  @mutex.synchronize do
138
132
  if @queue.empty?
139
133
  @recieved.wait(@mutex, timeout) if timeout != 0
140
- #if we're still empty after the timeout, raise exception
134
+ # if we're still empty after the timeout, raise exception
141
135
  return nil if @queue.empty?
142
- #raise ThreadError, "queue empty" if @queue.empty?
136
+ # raise ThreadError, "queue empty" if @queue.empty?
143
137
  end
144
138
  @queue.shift
145
139
  end
@@ -4,19 +4,17 @@ module TCellAgent
4
4
  BLANK_RE = /\A[[:space:]]*\z/
5
5
 
6
6
  def self.blank?(str)
7
- str.nil? || str.empty? || BLANK_RE === str
7
+ str.nil? || str.empty? || BLANK_RE === str # rubocop:disable Style/CaseEquality
8
8
  end
9
9
 
10
10
  def self.present?(str)
11
- !self.blank?(str)
11
+ !blank?(str)
12
12
  end
13
13
 
14
14
  def self.remove_trailing_slash(path)
15
- if path && path != "/"
16
- return path.chomp("/")
17
- end
15
+ return path.chomp('/') if path && path != '/'
18
16
 
19
- return path
17
+ path
20
18
  end
21
19
 
22
20
  # emulate the java String.hashcode() without upcasting to BigInt
@@ -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 = "1.1.3"
4
+ VERSION = '1.1.4'.freeze
5
5
  end
@@ -332,7 +332,7 @@ module TCellAgent
332
332
 
333
333
  expect(TCellAgent::Policies::RustPolicies).to receive(:new).and_return(rust_policies)
334
334
  expect(File).to receive(:exist?).with(%r{tcell/cache/tcell_agent.cache}).and_return(false)
335
- expect_any_instance_of(TCellAgent::Agent).to_not receive(:processPolicyJson)
335
+ expect_any_instance_of(TCellAgent::Agent).to_not receive(:process_policy_json)
336
336
  agent = TCellAgent::Agent.new(Process.pid)
337
337
 
338
338
  expect(agent.policies).to eq({ 'rust' => rust_policies })
@@ -356,7 +356,7 @@ module TCellAgent
356
356
  rust_policies = double('rust_policies')
357
357
  expect(TCellAgent::Policies::RustPolicies).to receive(:new).and_return(rust_policies)
358
358
 
359
- expect_any_instance_of(TCellAgent::Agent).to_not receive(:processPolicyJson)
359
+ expect_any_instance_of(TCellAgent::Agent).to_not receive(:process_policy_json)
360
360
 
361
361
  agent = TCellAgent::Agent.new(Process.pid)
362
362
 
@@ -377,7 +377,7 @@ module TCellAgent
377
377
  logger = double('logger')
378
378
  expect(TCellAgent).to receive(:logger).and_return(logger)
379
379
  expect(logger).to receive(:warn).with(/unexpected token at 'bad_json'/)
380
- expect_any_instance_of(TCellAgent::Agent).to_not receive(:processPolicyJson)
380
+ expect_any_instance_of(TCellAgent::Agent).to_not receive(:process_policy_json)
381
381
 
382
382
  rust_policies = double('rust_policies')
383
383
  expect(TCellAgent::Policies::RustPolicies).to receive(:new).and_return(rust_policies)
@@ -400,7 +400,7 @@ module TCellAgent
400
400
  expect(TCellAgent).to_not receive(:logger)
401
401
 
402
402
  expect(TCellAgent::Policies::RustPolicies).to receive(:new).and_return(nil)
403
- expect_any_instance_of(TCellAgent::Agent).to receive(:processPolicyJson).with({}, false)
403
+ expect_any_instance_of(TCellAgent::Agent).to receive(:process_policy_json).with({}, false)
404
404
 
405
405
  TCellAgent::Agent.new(Process.pid)
406
406
  end
@@ -422,7 +422,7 @@ module TCellAgent
422
422
  }.to_json
423
423
  )
424
424
  expect(cache_file).to receive(:close)
425
- expect_any_instance_of(TCellAgent::Agent).to receive(:processPolicyJson).with(
425
+ expect_any_instance_of(TCellAgent::Agent).to receive(:process_policy_json).with(
426
426
  {
427
427
  'process_0' => {
428
428
  'app_id' => 'raftest-EyJZR',
@@ -6,7 +6,7 @@ module TCellAgent
6
6
  describe '.increment_session_info' do
7
7
  context 'when running the parent process' do
8
8
  it 'should increment the session info' do
9
- expect(TCellAgent::Agent).to receive(:is_parent_process?).and_return(true)
9
+ expect(TCellAgent::Agent).to receive(:parent_process?).and_return(true)
10
10
  expect(TCellAgent).to_not receive(:queue_metric)
11
11
  expect_any_instance_of(SessionsMetric).to receive(:add_session_info).with(
12
12
  'hmac_session_id', 'user_id', 'ip_address', 'user_agent'
@@ -19,7 +19,7 @@ module TCellAgent
19
19
 
20
20
  context 'and the session becomes full' do
21
21
  it 'should increment the session info and send the flush dummy event' do
22
- expect(TCellAgent::Agent).to receive(:is_parent_process?).and_return(true)
22
+ expect(TCellAgent::Agent).to receive(:parent_process?).and_return(true)
23
23
  expect(TCellAgent).to_not receive(:queue_metric)
24
24
  expect_any_instance_of(SessionsMetric).to receive(:add_session_info).with(
25
25
  'hmac_session_id', 'user_id', 'ip_address', 'user_agent'
@@ -36,7 +36,7 @@ module TCellAgent
36
36
 
37
37
  context 'when NOT running the parent process' do
38
38
  it 'should queue the metric' do
39
- expect(TCellAgent::Agent).to receive(:is_parent_process?).and_return(false)
39
+ expect(TCellAgent::Agent).to receive(:parent_process?).and_return(false)
40
40
  expect(TCellAgent).to receive(:queue_metric).with(
41
41
  {
42
42
  '_type' => 'increment_session_info',
@@ -66,7 +66,7 @@ module TCellAgent
66
66
 
67
67
  context 'with a route present' do
68
68
  it 'should increment the route info' do
69
- expect(TCellAgent::Agent).to receive(:is_parent_process?).and_return(true)
69
+ expect(TCellAgent::Agent).to receive(:parent_process?).and_return(true)
70
70
  expect(TCellAgent).to_not receive(:queue_metric)
71
71
 
72
72
  TCellAgent.increment_route('/ma_route', 20)
@@ -79,7 +79,7 @@ module TCellAgent
79
79
 
80
80
  context 'with an empty route' do
81
81
  it 'should increment the route info' do
82
- expect(TCellAgent::Agent).to receive(:is_parent_process?).and_return(true)
82
+ expect(TCellAgent::Agent).to receive(:parent_process?).and_return(true)
83
83
  expect(TCellAgent).to_not receive(:queue_metric)
84
84
 
85
85
  TCellAgent.increment_route('', 20)
@@ -92,7 +92,7 @@ module TCellAgent
92
92
 
93
93
  context 'with a nil route' do
94
94
  it 'should increment the route info' do
95
- expect(TCellAgent::Agent).to receive(:is_parent_process?).and_return(true)
95
+ expect(TCellAgent::Agent).to receive(:parent_process?).and_return(true)
96
96
  expect(TCellAgent).to_not receive(:queue_metric)
97
97
 
98
98
  TCellAgent.increment_route(nil, 20)
@@ -113,7 +113,7 @@ module TCellAgent
113
113
  end
114
114
 
115
115
  it 'should queue the metric' do
116
- expect(TCellAgent::Agent).to receive(:is_parent_process?).and_return(false)
116
+ expect(TCellAgent::Agent).to receive(:parent_process?).and_return(false)
117
117
  expect(TCellAgent).to receive(:queue_metric).with(
118
118
  {
119
119
  '_type' => 'increment_route',
@@ -204,7 +204,7 @@ module TCellAgent
204
204
  context 'with no command injection' do
205
205
  it 'should execute the command' do
206
206
  expect(TCellAgent).to receive(:policy).with(
207
- TCellAgent::PolicyTypes::Rust
207
+ TCellAgent::PolicyTypes::RUST
208
208
  ).and_return(nil)
209
209
  expect_any_instance_of(TCellAgent::Policies::RustPolicies).to_not receive(:cmdi_enabled)
210
210
  expect_any_instance_of(TCellAgent::Policies::RustPolicies).to_not receive(:block_command?)
@@ -218,7 +218,7 @@ module TCellAgent
218
218
  expect(@rust_policies.cmdi_enabled).to eq(false)
219
219
 
220
220
  expect(TCellAgent).to receive(:policy).with(
221
- TCellAgent::PolicyTypes::Rust
221
+ TCellAgent::PolicyTypes::RUST
222
222
  ).and_return(@rust_policies)
223
223
  expect(@rust_policies).to receive(:cmdi_enabled).and_call_original
224
224
  expect(@rust_policies).to_not receive(:block_command?)
@@ -230,7 +230,7 @@ module TCellAgent
230
230
  context 'with command injection enabled' do
231
231
  it 'should execute the command' do
232
232
  expect(TCellAgent).to receive(:policy).with(
233
- TCellAgent::PolicyTypes::Rust
233
+ TCellAgent::PolicyTypes::RUST
234
234
  ).and_return(@rust_policies)
235
235
  expect(@rust_policies).to receive(:cmdi_enabled).and_return(true)
236
236
  expect(@rust_policies).to receive(:block_command?).with('echo test', nil).and_return(false)
@@ -244,7 +244,7 @@ module TCellAgent
244
244
  context 'with command injection enabled' do
245
245
  it 'should raise a Errno::ENOENT' do
246
246
  expect(TCellAgent).to receive(:policy).with(
247
- TCellAgent::PolicyTypes::Rust
247
+ TCellAgent::PolicyTypes::RUST
248
248
  ).and_return(@rust_policies)
249
249
  expect(@rust_policies).to receive(:cmdi_enabled).and_return(true)
250
250
  expect(@rust_policies).to receive(:block_command?).with('echo test', nil).and_return(true)
@@ -426,7 +426,7 @@ module TCellAgent
426
426
  context 'with no command injection' do
427
427
  it 'should execute the command' do
428
428
  expect(TCellAgent).to receive(:policy).with(
429
- TCellAgent::PolicyTypes::Rust
429
+ TCellAgent::PolicyTypes::RUST
430
430
  ).and_return(nil)
431
431
  expect_any_instance_of(TCellAgent::Policies::RustPolicies).to_not receive(:cmdi_enabled)
432
432
  expect_any_instance_of(TCellAgent::Policies::RustPolicies).to_not receive(:block_command?)
@@ -438,7 +438,7 @@ module TCellAgent
438
438
  context 'with command injection disabled' do
439
439
  it 'should execute the command' do
440
440
  expect(TCellAgent).to receive(:policy).with(
441
- TCellAgent::PolicyTypes::Rust
441
+ TCellAgent::PolicyTypes::RUST
442
442
  ).and_return(@rust_policies)
443
443
  expect(@rust_policies).to receive(:cmdi_enabled).and_return(false)
444
444
  expect(@rust_policies).to_not receive(:block_command?)
@@ -450,7 +450,7 @@ module TCellAgent
450
450
  context 'with command injection enabled' do
451
451
  it 'should execute the command' do
452
452
  expect(TCellAgent).to receive(:policy).with(
453
- TCellAgent::PolicyTypes::Rust
453
+ TCellAgent::PolicyTypes::RUST
454
454
  ).and_return(@rust_policies)
455
455
  expect(@rust_policies).to receive(:cmdi_enabled).and_return(true)
456
456
  expect(@rust_policies).to receive(:block_command?).with('echo test', nil).and_return(false)
@@ -464,7 +464,7 @@ module TCellAgent
464
464
  context 'with command injection enabled' do
465
465
  it 'should raise a Errno::ENOENT' do
466
466
  expect(TCellAgent).to receive(:policy).with(
467
- TCellAgent::PolicyTypes::Rust
467
+ TCellAgent::PolicyTypes::RUST
468
468
  ).and_return(@rust_policies)
469
469
  expect(@rust_policies).to receive(:cmdi_enabled).and_return(true)
470
470
  expect(@rust_policies).to receive(:block_command?).with('echo test', nil).and_return(true)
@@ -490,7 +490,7 @@ module TCellAgent
490
490
  context 'with no command injection' do
491
491
  it 'should execute the command' do
492
492
  expect(TCellAgent).to receive(:policy).with(
493
- TCellAgent::PolicyTypes::Rust
493
+ TCellAgent::PolicyTypes::RUST
494
494
  ).and_return(nil)
495
495
  expect_any_instance_of(TCellAgent::Policies::RustPolicies).to_not receive(:cmdi_enabled)
496
496
  expect_any_instance_of(TCellAgent::Policies::RustPolicies).to_not receive(:block_command?)
@@ -502,7 +502,7 @@ module TCellAgent
502
502
  context 'with command injection disabled' do
503
503
  it 'should execute the command' do
504
504
  expect(TCellAgent).to receive(:policy).with(
505
- TCellAgent::PolicyTypes::Rust
505
+ TCellAgent::PolicyTypes::RUST
506
506
  ).and_return(@rust_policies)
507
507
  expect(@rust_policies).to receive(:cmdi_enabled).and_return(false)
508
508
  expect(@rust_policies).to_not receive(:block_command?)
@@ -514,7 +514,7 @@ module TCellAgent
514
514
  context 'with command injection enabled' do
515
515
  it 'should execute the command' do
516
516
  expect(TCellAgent).to receive(:policy).with(
517
- TCellAgent::PolicyTypes::Rust
517
+ TCellAgent::PolicyTypes::RUST
518
518
  ).and_return(@rust_policies)
519
519
  expect(@rust_policies).to receive(:cmdi_enabled).and_return(true)
520
520
  expect(@rust_policies).to receive(:block_command?).with('echo test', nil).and_return(false)
@@ -528,7 +528,7 @@ module TCellAgent
528
528
  context 'with command injection enabled' do
529
529
  it 'should raise a Errno::ENOENT' do
530
530
  expect(TCellAgent).to receive(:policy).with(
531
- TCellAgent::PolicyTypes::Rust
531
+ TCellAgent::PolicyTypes::RUST
532
532
  ).and_return(@rust_policies)
533
533
  expect(@rust_policies).to receive(:cmdi_enabled).and_return(true)
534
534
  expect(@rust_policies).to receive(:block_command?).with('echo test', nil).and_return(true)
@@ -575,7 +575,7 @@ module TCellAgent
575
575
  context 'with no command injection' do
576
576
  it 'should execute the command' do
577
577
  expect(TCellAgent).to receive(:policy).with(
578
- TCellAgent::PolicyTypes::Rust
578
+ TCellAgent::PolicyTypes::RUST
579
579
  ).and_return(nil)
580
580
  expect_any_instance_of(TCellAgent::Policies::RustPolicies).to_not receive(:cmdi_enabled)
581
581
  expect_any_instance_of(TCellAgent::Policies::RustPolicies).to_not receive(:block_command?)
@@ -587,7 +587,7 @@ module TCellAgent
587
587
  context 'with command injection disabled' do
588
588
  it 'should execute the command' do
589
589
  expect(TCellAgent).to receive(:policy).with(
590
- TCellAgent::PolicyTypes::Rust
590
+ TCellAgent::PolicyTypes::RUST
591
591
  ).and_return(@rust_policies)
592
592
  expect(@rust_policies).to receive(:cmdi_enabled).and_return(false)
593
593
  expect(@rust_policies).to_not receive(:block_command?)
@@ -599,7 +599,7 @@ module TCellAgent
599
599
  context 'with command injection enabled' do
600
600
  it 'should execute the command' do
601
601
  expect(TCellAgent).to receive(:policy).with(
602
- TCellAgent::PolicyTypes::Rust
602
+ TCellAgent::PolicyTypes::RUST
603
603
  ).and_return(@rust_policies)
604
604
  expect(@rust_policies).to receive(:cmdi_enabled).and_return(true)
605
605
  expect(@rust_policies).to receive(:block_command?).with('echo test > /dev/null 2>&1', nil).and_return(false)
@@ -613,7 +613,7 @@ module TCellAgent
613
613
  context 'with command injection enabled' do
614
614
  it 'should raise a Errno::ENOENT' do
615
615
  expect(TCellAgent).to receive(:policy).with(
616
- TCellAgent::PolicyTypes::Rust
616
+ TCellAgent::PolicyTypes::RUST
617
617
  ).and_return(@rust_policies)
618
618
  expect(@rust_policies).to receive(:cmdi_enabled).and_return(true)
619
619
  expect(@rust_policies).to receive(:block_command?).with('echo test', nil).and_return(true)
@@ -663,7 +663,7 @@ module TCellAgent
663
663
  context 'with no command injection' do
664
664
  it 'should execute the command' do
665
665
  expect(TCellAgent).to receive(:policy).with(
666
- TCellAgent::PolicyTypes::Rust
666
+ TCellAgent::PolicyTypes::RUST
667
667
  ).and_return(nil)
668
668
  expect_any_instance_of(TCellAgent::Policies::RustPolicies).to_not receive(:cmdi_enabled)
669
669
  expect_any_instance_of(TCellAgent::Policies::RustPolicies).to_not receive(:block_command?)
@@ -675,7 +675,7 @@ module TCellAgent
675
675
  context 'with command injection disabled' do
676
676
  it 'should execute the command' do
677
677
  expect(TCellAgent).to receive(:policy).with(
678
- TCellAgent::PolicyTypes::Rust
678
+ TCellAgent::PolicyTypes::RUST
679
679
  ).and_return(@rust_policies)
680
680
  expect(@rust_policies).to receive(:cmdi_enabled).and_return(false)
681
681
  expect(@rust_policies).to_not receive(:block_command?)
@@ -687,7 +687,7 @@ module TCellAgent
687
687
  context 'with command injection enabled' do
688
688
  it 'should execute the command' do
689
689
  expect(TCellAgent).to receive(:policy).with(
690
- TCellAgent::PolicyTypes::Rust
690
+ TCellAgent::PolicyTypes::RUST
691
691
  ).and_return(@rust_policies)
692
692
  expect(@rust_policies).to receive(:cmdi_enabled).and_return(true)
693
693
  expect(@rust_policies).to receive(:block_command?).with('echo test > /dev/null 2>&1', nil).and_return(false)
@@ -701,7 +701,7 @@ module TCellAgent
701
701
  context 'with command injection enabled' do
702
702
  it 'should raise a Errno::ENOENT' do
703
703
  expect(TCellAgent).to receive(:policy).with(
704
- TCellAgent::PolicyTypes::Rust
704
+ TCellAgent::PolicyTypes::RUST
705
705
  ).and_return(@rust_policies)
706
706
  expect(@rust_policies).to receive(:cmdi_enabled).and_return(true)
707
707
  expect(@rust_policies).to receive(:block_command?).with('echo test', nil).and_return(true)
@@ -720,7 +720,7 @@ module TCellAgent
720
720
  context 'with command injection enabled' do
721
721
  it 'should raise a Errno::ENOENT' do
722
722
  expect(TCellAgent).to receive(:policy).with(
723
- TCellAgent::PolicyTypes::Rust
723
+ TCellAgent::PolicyTypes::RUST
724
724
  ).and_return(@rust_policies)
725
725
  expect(@rust_policies).to receive(:cmdi_enabled).and_return(true)
726
726
  expect(@rust_policies).to receive(:block_command?).with('echo test', nil).and_return(true)