tcell_agent 0.2.29 → 0.4.0
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.
- checksums.yaml +4 -4
- data/Readme.txt +7 -0
- data/bin/tcell_agent +9 -0
- data/lib/tcell_agent/agent/policy_manager.rb +3 -0
- data/lib/tcell_agent/agent/policy_types.rb +4 -1
- data/lib/tcell_agent/appsensor/injections_matcher.rb +20 -0
- data/lib/tcell_agent/appsensor/injections_reporter.rb +15 -56
- data/lib/tcell_agent/appsensor/meta_data.rb +56 -2
- data/lib/tcell_agent/appsensor/rules/baserules.json +371 -138
- data/lib/tcell_agent/cmdi.rb +113 -0
- data/lib/tcell_agent/config/unknown_options.rb +2 -0
- data/lib/tcell_agent/configuration.rb +30 -16
- data/lib/tcell_agent/hooks/login_fraud.rb +79 -0
- data/lib/tcell_agent/instrumentation.rb +6 -11
- data/lib/tcell_agent/patches/meta_data.rb +14 -11
- data/lib/tcell_agent/policies/appsensor/injection_sensor.rb +5 -9
- data/lib/tcell_agent/policies/appsensor_policy.rb +22 -206
- data/lib/tcell_agent/policies/clickjacking_policy.rb +4 -2
- data/lib/tcell_agent/policies/command_injection_policy.rb +196 -0
- data/lib/tcell_agent/policies/content_security_policy.rb +3 -2
- data/lib/tcell_agent/policies/dataloss_policy.rb +3 -1
- data/lib/tcell_agent/policies/honeytokens_policy.rb +3 -1
- data/lib/tcell_agent/policies/http_redirect_policy.rb +51 -37
- data/lib/tcell_agent/policies/http_tx_policy.rb +5 -1
- data/lib/tcell_agent/policies/login_fraud_policy.rb +6 -1
- data/lib/tcell_agent/policies/patches_policy.rb +3 -1
- data/lib/tcell_agent/policies/policy.rb +10 -0
- data/lib/tcell_agent/policies/secure_headers_policy.rb +5 -2
- data/lib/tcell_agent/rails/auth/devise.rb +12 -23
- data/lib/tcell_agent/rails/csrf_exception.rb +1 -1
- data/lib/tcell_agent/rails/dlp.rb +50 -54
- data/lib/tcell_agent/rails/middleware/body_filter_middleware.rb +0 -1
- data/lib/tcell_agent/rails/middleware/context_middleware.rb +0 -1
- data/lib/tcell_agent/rails/middleware/global_middleware.rb +0 -1
- data/lib/tcell_agent/rails/middleware/headers_middleware.rb +7 -10
- data/lib/tcell_agent/rails/on_start.rb +0 -1
- data/lib/tcell_agent/rails/tcell_body_proxy.rb +4 -4
- data/lib/tcell_agent/rails.rb +0 -2
- data/lib/tcell_agent/rust/libtcellagent-0.6.1.dylib +0 -0
- data/lib/tcell_agent/rust/libtcellagent-0.6.1.so +0 -0
- data/lib/tcell_agent/rust/models.rb +61 -0
- data/lib/tcell_agent/rust/tcellagent-0.6.1.dll +0 -0
- data/lib/tcell_agent/rust/whisperer.rb +112 -0
- data/lib/tcell_agent/sensor_events/appsensor_event.rb +25 -21
- data/lib/tcell_agent/sensor_events/appsensor_meta_event.rb +31 -24
- data/lib/tcell_agent/sensor_events/command_injection.rb +58 -0
- data/lib/tcell_agent/sensor_events/discovery.rb +1 -1
- data/lib/tcell_agent/sensor_events/login_fraud.rb +3 -13
- data/lib/tcell_agent/sensor_events/sensor.rb +81 -77
- data/lib/tcell_agent/sensor_events/util/sanitizer_utilities.rb +8 -0
- data/lib/tcell_agent/start_background_thread.rb +12 -3
- data/lib/tcell_agent/utils/io.rb +4 -1
- data/lib/tcell_agent/utils/params.rb +1 -0
- data/lib/tcell_agent/version.rb +1 -1
- data/lib/tcell_agent.rb +0 -1
- data/spec/lib/tcell_agent/appsensor/injections_matcher_spec.rb +27 -9
- data/spec/lib/tcell_agent/appsensor/injections_reporter_spec.rb +143 -193
- data/spec/lib/tcell_agent/appsensor/meta_data_spec.rb +67 -0
- data/spec/lib/tcell_agent/appsensor/rules/appsensor_rule_manager_spec.rb +0 -10
- data/spec/lib/tcell_agent/cmdi_spec.rb +748 -0
- data/spec/lib/tcell_agent/config/unknown_options_spec.rb +8 -0
- data/spec/lib/tcell_agent/configuration_spec.rb +138 -6
- data/spec/lib/tcell_agent/hooks/login_fraud_spec.rb +357 -0
- data/spec/lib/tcell_agent/patches/block_rule_spec.rb +70 -87
- data/spec/lib/tcell_agent/patches_spec.rb +9 -4
- data/spec/lib/tcell_agent/policies/appsensor/xss_sensor_spec.rb +186 -9
- data/spec/lib/tcell_agent/policies/appsensor_policy_spec.rb +309 -484
- data/spec/lib/tcell_agent/policies/command_injection_policy_spec.rb +736 -0
- data/spec/lib/tcell_agent/policies/http_redirect_policy_spec.rb +222 -41
- data/spec/lib/tcell_agent/policies/patches_policy_spec.rb +56 -32
- data/spec/lib/tcell_agent/rails/middleware/appsensor_middleware_spec.rb +161 -85
- data/spec/lib/tcell_agent/rails/middleware/tcell_body_proxy_spec.rb +40 -72
- data/spec/lib/tcell_agent/rust/whisperer_spec.rb +267 -0
- data/spec/lib/tcell_agent/sensor_events/appsensor_meta_event_spec.rb +20 -15
- data/spec/spec_helper.rb +0 -9
- data/tcell_agent.gemspec +8 -3
- metadata +40 -39
- data/lib/tcell_agent/appsensor/sensor.rb +0 -52
- data/lib/tcell_agent/policies/appsensor/database_sensor.rb +0 -56
- data/lib/tcell_agent/policies/appsensor/misc_sensor.rb +0 -59
- data/lib/tcell_agent/policies/appsensor/payloads_policy.rb +0 -150
- data/lib/tcell_agent/policies/appsensor/request_size_sensor.rb +0 -25
- data/lib/tcell_agent/policies/appsensor/response_codes_sensor.rb +0 -73
- data/lib/tcell_agent/policies/appsensor/response_size_sensor.rb +0 -25
- data/lib/tcell_agent/policies/appsensor/size_sensor.rb +0 -71
- data/lib/tcell_agent/policies/appsensor/user_agent_sensor.rb +0 -47
- data/lib/tcell_agent/rails/auth/hooks.rb +0 -79
- data/lib/tcell_agent/sensor_events/util/redirect_utils.rb +0 -22
- data/spec/lib/tcell_agent/policies/appsensor/database_sensor_spec.rb +0 -165
- data/spec/lib/tcell_agent/policies/appsensor/misc_sensor_spec.rb +0 -429
- data/spec/lib/tcell_agent/policies/appsensor/payloads_policy_apply_spec.rb +0 -466
- data/spec/lib/tcell_agent/policies/appsensor/payloads_policy_from_json_spec.rb +0 -890
- data/spec/lib/tcell_agent/policies/appsensor/payloads_policy_log_spec.rb +0 -417
- data/spec/lib/tcell_agent/policies/appsensor/request_size_sensor_spec.rb +0 -236
- data/spec/lib/tcell_agent/policies/appsensor/response_codes_sensor_spec.rb +0 -297
- data/spec/lib/tcell_agent/policies/appsensor/response_size_sensor_spec.rb +0 -241
- data/spec/lib/tcell_agent/policies/appsensor/user_agent_sensor_spec.rb +0 -172
- data/spec/lib/tcell_agent/rails/auth/hooks_spec.rb +0 -246
- data/spec/lib/tcell_agent/sensor_events/util/redirect_utils_spec.rb +0 -25
- data/spec/support/resources/baserules.json +0 -155
|
@@ -4,219 +4,169 @@ module TCellAgent
|
|
|
4
4
|
module AppSensor
|
|
5
5
|
|
|
6
6
|
describe InjectionsReporter do
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
@payloads_policy = double("payloads_policy")
|
|
11
|
-
@injections_matcher = double("injections_matcher")
|
|
12
|
-
@injections_reporter = InjectionsReporter.new(@injections_matcher, @payloads_policy, false)
|
|
13
|
-
|
|
14
|
-
@appsensor_meta = TCellAgent::SensorEvents::AppSensorMetaEvent.new
|
|
15
|
-
@appsensor_meta.remote_address = "remote_address"
|
|
16
|
-
@appsensor_meta.method = "get"
|
|
17
|
-
@appsensor_meta.location = "location"
|
|
18
|
-
@appsensor_meta.route_id = "route_id"
|
|
19
|
-
@appsensor_meta.session_id = "session_id"
|
|
20
|
-
@appsensor_meta.user_id = "user_id"
|
|
21
|
-
@appsensor_meta.transaction_id = "transaction_id"
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
context "no matches" do
|
|
25
|
-
it "should not send any events" do
|
|
26
|
-
expect(@injections_matcher).to receive(:each_injection)
|
|
27
|
-
expect(@payloads_policy).to_not receive(:apply)
|
|
7
|
+
describe ".report_and_log" do
|
|
8
|
+
context "with nil events" do
|
|
9
|
+
it "should do nothing" do
|
|
28
10
|
expect(TCellAgent).to_not receive(:send_event)
|
|
11
|
+
expect(TCellAgent).to_not receive(:logger)
|
|
29
12
|
|
|
30
|
-
|
|
13
|
+
InjectionsReporter.report_and_log(nil)
|
|
31
14
|
end
|
|
32
15
|
end
|
|
33
16
|
|
|
34
|
-
context "with
|
|
35
|
-
it "should
|
|
36
|
-
expect(
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
{
|
|
41
|
-
"param" => "dirty",
|
|
42
|
-
"value" => "<script>",
|
|
43
|
-
"pattern" => "pattern_id"
|
|
44
|
-
}
|
|
45
|
-
)
|
|
46
|
-
|
|
47
|
-
block.call(injection_attempt)
|
|
48
|
-
end
|
|
49
|
-
expect(@payloads_policy).to receive(:apply).with(
|
|
50
|
-
"xss", {}, InjectionsReporter::GET_PARAM, "dirty", "<script>", {"l"=>"query"}, "pattern_id"
|
|
51
|
-
)
|
|
52
|
-
expect(TCellAgent).to receive(:send_event).with(
|
|
53
|
-
{
|
|
54
|
-
"event_type"=>"as",
|
|
55
|
-
"dp"=>"xss",
|
|
56
|
-
"param"=>"dirty",
|
|
57
|
-
"remote_addr"=>"remote_address",
|
|
58
|
-
"m"=>"get",
|
|
59
|
-
"pattern"=>"pattern_id",
|
|
60
|
-
"meta"=>{"l"=>"query"},
|
|
61
|
-
"rid"=>"route_id"
|
|
62
|
-
}
|
|
63
|
-
)
|
|
64
|
-
|
|
65
|
-
@injections_reporter.check(@appsensor_meta)
|
|
17
|
+
context "with empty events" do
|
|
18
|
+
it "should do nothing" do
|
|
19
|
+
expect(TCellAgent).to_not receive(:send_event)
|
|
20
|
+
expect(TCellAgent).to_not receive(:logger)
|
|
21
|
+
|
|
22
|
+
InjectionsReporter.report_and_log([])
|
|
66
23
|
end
|
|
67
24
|
end
|
|
68
25
|
|
|
69
|
-
context "with one
|
|
70
|
-
it "should send the
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
"
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
"
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
}
|
|
100
|
-
)
|
|
101
|
-
|
|
102
|
-
@injections_reporter.check(@appsensor_meta)
|
|
26
|
+
context "with one event" do
|
|
27
|
+
it "should send the event" do
|
|
28
|
+
events = [{
|
|
29
|
+
"pattern" => "1",
|
|
30
|
+
"method" => "request_method",
|
|
31
|
+
"uri" => "abosolute_uri",
|
|
32
|
+
"parameter" => "avatar",
|
|
33
|
+
"meta" => {"l" => "body"},
|
|
34
|
+
"session_id" => "session_id",
|
|
35
|
+
"route_id" => "route_id",
|
|
36
|
+
"detection_point" => "xss",
|
|
37
|
+
"user_id" => "user_id"
|
|
38
|
+
}]
|
|
39
|
+
|
|
40
|
+
expect(TCellAgent).to_not receive(:logger)
|
|
41
|
+
|
|
42
|
+
expect(TCellAgent).to receive(:send_event).with({
|
|
43
|
+
"event_type" => "as",
|
|
44
|
+
"dp" => "xss",
|
|
45
|
+
"param" => "avatar",
|
|
46
|
+
"m" => "request_method",
|
|
47
|
+
"pattern" => "1",
|
|
48
|
+
"meta" => {"l" => "body"},
|
|
49
|
+
"rid" => "route_id",
|
|
50
|
+
"uri" => "abosolute_uri",
|
|
51
|
+
"uid" => "user_id",
|
|
52
|
+
"sid" => "session_id"
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
InjectionsReporter.report_and_log(events)
|
|
103
56
|
end
|
|
104
57
|
end
|
|
105
58
|
|
|
106
|
-
context "with one
|
|
107
|
-
it "should send the
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
"
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
expect(
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
expect(TCellAgent).to receive(:send_event).with(
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
)
|
|
138
|
-
|
|
139
|
-
|
|
59
|
+
context "with one event with full payload" do
|
|
60
|
+
it "should send and log the event" do
|
|
61
|
+
events = [{
|
|
62
|
+
"pattern" => "1",
|
|
63
|
+
"method" => "request_method",
|
|
64
|
+
"uri" => "abosolute_uri",
|
|
65
|
+
"parameter" => "avatar",
|
|
66
|
+
"meta" => {"l" => "body"},
|
|
67
|
+
"session_id" => "session_id",
|
|
68
|
+
"route_id" => "route_id",
|
|
69
|
+
"detection_point" => "xss",
|
|
70
|
+
"user_id" => "user_id",
|
|
71
|
+
"full_payload" => "full_payload"
|
|
72
|
+
}]
|
|
73
|
+
|
|
74
|
+
logger = double("logger")
|
|
75
|
+
|
|
76
|
+
expect(TCellAgent).to receive(:logger).and_return(logger)
|
|
77
|
+
expect(logger).to receive(:info).with(/"payload":"full_payload"/)
|
|
78
|
+
|
|
79
|
+
expect(TCellAgent).to receive(:send_event).with({
|
|
80
|
+
"event_type" => "as",
|
|
81
|
+
"dp" => "xss",
|
|
82
|
+
"param" => "avatar",
|
|
83
|
+
"m" => "request_method",
|
|
84
|
+
"pattern" => "1",
|
|
85
|
+
"meta" => {"l" => "body"},
|
|
86
|
+
"rid" => "route_id",
|
|
87
|
+
"uri" => "abosolute_uri",
|
|
88
|
+
"uid" => "user_id",
|
|
89
|
+
"sid" => "session_id"
|
|
90
|
+
})
|
|
91
|
+
|
|
92
|
+
InjectionsReporter.report_and_log(events)
|
|
140
93
|
end
|
|
141
94
|
end
|
|
142
95
|
|
|
143
|
-
context "with one
|
|
144
|
-
it "should send the
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
"
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
expect(
|
|
161
|
-
"
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
)
|
|
175
|
-
|
|
176
|
-
@injections_reporter.check(@appsensor_meta)
|
|
96
|
+
context "with one event with payload" do
|
|
97
|
+
it "should send the event" do
|
|
98
|
+
events = [{
|
|
99
|
+
"pattern" => "1",
|
|
100
|
+
"method" => "request_method",
|
|
101
|
+
"uri" => "abosolute_uri",
|
|
102
|
+
"parameter" => "avatar",
|
|
103
|
+
"meta" => {"l" => "body"},
|
|
104
|
+
"session_id" => "session_id",
|
|
105
|
+
"route_id" => "route_id",
|
|
106
|
+
"detection_point" => "xss",
|
|
107
|
+
"user_id" => "user_id",
|
|
108
|
+
"payload" => "payload"
|
|
109
|
+
}]
|
|
110
|
+
|
|
111
|
+
expect(TCellAgent).to_not receive(:logger)
|
|
112
|
+
|
|
113
|
+
expect(TCellAgent).to receive(:send_event).with({
|
|
114
|
+
"event_type" => "as",
|
|
115
|
+
"dp" => "xss",
|
|
116
|
+
"param" => "avatar",
|
|
117
|
+
"m" => "request_method",
|
|
118
|
+
"pattern" => "1",
|
|
119
|
+
"meta" => {"l" => "body"},
|
|
120
|
+
"rid" => "route_id",
|
|
121
|
+
"uri" => "abosolute_uri",
|
|
122
|
+
"uid" => "user_id",
|
|
123
|
+
"sid" => "session_id",
|
|
124
|
+
"payload" => "payload"
|
|
125
|
+
})
|
|
126
|
+
|
|
127
|
+
InjectionsReporter.report_and_log(events)
|
|
177
128
|
end
|
|
178
129
|
end
|
|
179
130
|
|
|
180
|
-
context "with one
|
|
181
|
-
it "should send the
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
"
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
)
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
131
|
+
context "with one event with payload and full payload" do
|
|
132
|
+
it "should send and log the event" do
|
|
133
|
+
events = [{
|
|
134
|
+
"pattern" => "1",
|
|
135
|
+
"method" => "request_method",
|
|
136
|
+
"uri" => "abosolute_uri",
|
|
137
|
+
"parameter" => "avatar",
|
|
138
|
+
"meta" => {"l" => "body"},
|
|
139
|
+
"session_id" => "session_id",
|
|
140
|
+
"route_id" => "route_id",
|
|
141
|
+
"detection_point" => "xss",
|
|
142
|
+
"user_id" => "user_id",
|
|
143
|
+
"payload" => "payload",
|
|
144
|
+
"full_payload" => "full_payload"
|
|
145
|
+
}]
|
|
146
|
+
|
|
147
|
+
logger = double("logger")
|
|
148
|
+
|
|
149
|
+
expect(TCellAgent).to receive(:logger).and_return(logger)
|
|
150
|
+
expect(logger).to receive(:info).with(/"payload":"full_payload"/)
|
|
151
|
+
|
|
152
|
+
expect(TCellAgent).to receive(:send_event).with({
|
|
153
|
+
"event_type" => "as",
|
|
154
|
+
"dp" => "xss",
|
|
155
|
+
"param" => "avatar",
|
|
156
|
+
"m" => "request_method",
|
|
157
|
+
"pattern" => "1",
|
|
158
|
+
"meta" => {"l" => "body"},
|
|
159
|
+
"rid" => "route_id",
|
|
160
|
+
"uri" => "abosolute_uri",
|
|
161
|
+
"uid" => "user_id",
|
|
162
|
+
"sid" => "session_id",
|
|
163
|
+
"payload" => "payload"
|
|
164
|
+
})
|
|
165
|
+
|
|
166
|
+
InjectionsReporter.report_and_log(events)
|
|
214
167
|
end
|
|
215
168
|
end
|
|
216
|
-
|
|
217
169
|
end
|
|
218
|
-
|
|
219
170
|
end
|
|
220
|
-
|
|
221
171
|
end
|
|
222
172
|
end
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
module TCellAgent
|
|
4
|
+
module AppSensor
|
|
5
|
+
|
|
6
|
+
describe MetaData do
|
|
7
|
+
describe "#set_headers_dict" do
|
|
8
|
+
it "should set all headers that start with http and skip cookies" do
|
|
9
|
+
method = remote_address = route_id = session_id = user_id = transaction_id = nil
|
|
10
|
+
|
|
11
|
+
meta = MetaData.new(method, remote_address, route_id, session_id, user_id, transaction_id)
|
|
12
|
+
meta.set_headers_dict({
|
|
13
|
+
"rack.version" => [1, 2],
|
|
14
|
+
"REQUEST_METHOD" => "POST",
|
|
15
|
+
"SERVER_NAME" => "www.example.com",
|
|
16
|
+
"HTTP_USER_AGENT" => "Mozilla",
|
|
17
|
+
"HTTP_MY_CUSTOM_HTTP_HEADER" => "my value"
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
expect(meta.headers_dict).to eq({
|
|
22
|
+
"user-agent" => "Mozilla",
|
|
23
|
+
"my-custom-http-header" => "my value"
|
|
24
|
+
})
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
it "should set all headers that start with http and include content_length and content_type" do
|
|
28
|
+
method = remote_address = route_id = session_id = user_id = transaction_id = nil
|
|
29
|
+
|
|
30
|
+
meta = MetaData.new(method, remote_address, route_id, session_id, user_id, transaction_id)
|
|
31
|
+
meta.set_headers_dict({
|
|
32
|
+
"REQUEST_METHOD" => "POST",
|
|
33
|
+
"HTTP_VERSION" => "HTTP/1.1",
|
|
34
|
+
"HTTP_CONNECTION" => "keep-alive",
|
|
35
|
+
"CONTENT_LENGTH" => "85",
|
|
36
|
+
"HTTP_CACHE_CONTROL" => "max-age=0",
|
|
37
|
+
"HTTP_ORIGIN" => "http://192.168.99.100:3000",
|
|
38
|
+
"HTTP_UPGRADE_INSECURE_REQUESTS" => "1",
|
|
39
|
+
"HTTP_USER_AGENT" => "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_5)",
|
|
40
|
+
"CONTENT_TYPE" => "application/x-www-form-urlencoded",
|
|
41
|
+
"HTTP_ACCEPT" => "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",
|
|
42
|
+
"HTTP_ACCEPT_ENCODING" => "gzip, deflate",
|
|
43
|
+
"HTTP_ACCEPT_LANGUAGE" => "en-US,en;q=0.8",
|
|
44
|
+
"HTTP_MY_CUSTOM_HTTP_HEADER" => "my value"
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
expect(meta.headers_dict).to eq({
|
|
49
|
+
"version" => "HTTP/1.1",
|
|
50
|
+
"connection" => "keep-alive",
|
|
51
|
+
"content-length" => "85",
|
|
52
|
+
"cache-control" => "max-age=0",
|
|
53
|
+
"origin" => "http://192.168.99.100:3000",
|
|
54
|
+
"upgrade-insecure-requests" => "1",
|
|
55
|
+
"user-agent" => "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_5)",
|
|
56
|
+
"content-type" => "application/x-www-form-urlencoded",
|
|
57
|
+
"accept" => "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",
|
|
58
|
+
"accept-encoding" => "gzip, deflate",
|
|
59
|
+
"accept-language" => "en-US,en;q=0.8",
|
|
60
|
+
"my-custom-http-header" => "my value"
|
|
61
|
+
})
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
end
|
|
67
|
+
end
|
|
@@ -7,16 +7,6 @@ module TCellAgent
|
|
|
7
7
|
# since rule manager is a singleton, load default rules so rest of the specs work properly
|
|
8
8
|
AppSensorRuleManager.instance.load_default_rules_file
|
|
9
9
|
end
|
|
10
|
-
describe "#initialize" do
|
|
11
|
-
context "loading default baserules" do
|
|
12
|
-
it "should initialize all the sensors" do
|
|
13
|
-
rule_manager = AppSensorRuleManager.instance
|
|
14
|
-
rule_manager.load_rules_file(get_test_resource_path("baserules.json"))
|
|
15
|
-
|
|
16
|
-
expect(rule_manager.rule_info.empty?).to eq(false)
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
10
|
|
|
21
11
|
describe "#load_rules_file" do
|
|
22
12
|
context "with nonexistent file" do
|