tcell_agent 0.4.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +9 -22
- data/bin/tcell_agent +127 -132
- data/lib/tcell_agent/agent/event_processor.rb +23 -22
- data/lib/tcell_agent/agent/fork_pipe_manager.rb +7 -7
- data/lib/tcell_agent/agent/policy_manager.rb +20 -15
- data/lib/tcell_agent/agent/policy_types.rb +5 -11
- data/lib/tcell_agent/agent/static_agent.rb +5 -1
- data/lib/tcell_agent/agent.rb +6 -4
- data/lib/tcell_agent/api.rb +7 -9
- data/lib/tcell_agent/appsensor/meta_data.rb +11 -4
- data/lib/tcell_agent/authlogic.rb +3 -3
- data/lib/tcell_agent/cmdi.rb +6 -4
- data/lib/tcell_agent/config/unknown_options.rb +3 -1
- data/lib/tcell_agent/configuration.rb +47 -49
- data/lib/tcell_agent/devise.rb +2 -2
- data/lib/tcell_agent/hooks/login_fraud.rb +58 -29
- data/lib/tcell_agent/instrumentation.rb +11 -10
- data/lib/tcell_agent/logger.rb +2 -2
- data/lib/tcell_agent/patches/meta_data.rb +9 -13
- data/lib/tcell_agent/patches.rb +7 -10
- data/lib/tcell_agent/policies/clickjacking_policy.rb +4 -5
- data/lib/tcell_agent/policies/content_security_policy.rb +6 -12
- data/lib/tcell_agent/policies/dataloss_policy.rb +2 -2
- data/lib/tcell_agent/policies/http_redirect_policy.rb +2 -2
- data/lib/tcell_agent/policies/policy.rb +0 -2
- data/lib/tcell_agent/policies/rust_policies.rb +90 -0
- data/lib/tcell_agent/policies/secure_headers_policy.rb +2 -2
- data/lib/tcell_agent/rails/auth/authlogic.rb +42 -24
- data/lib/tcell_agent/rails/auth/devise.rb +44 -23
- data/lib/tcell_agent/rails/auth/doorkeeper.rb +33 -15
- data/lib/tcell_agent/rails/better_ip.rb +1 -1
- data/lib/tcell_agent/rails/csrf_exception.rb +2 -2
- data/lib/tcell_agent/rails/dlp/process_request.rb +1 -1
- data/lib/tcell_agent/rails/dlp.rb +6 -6
- data/lib/tcell_agent/rails/dlp_handler.rb +1 -1
- data/lib/tcell_agent/rails/js_agent_insert.rb +1 -1
- data/lib/tcell_agent/rails/middleware/body_filter_middleware.rb +1 -1
- data/lib/tcell_agent/rails/middleware/context_middleware.rb +3 -2
- data/lib/tcell_agent/rails/middleware/headers_middleware.rb +10 -9
- data/lib/tcell_agent/rails/routes/grape.rb +6 -6
- data/lib/tcell_agent/rails/routes.rb +8 -11
- data/lib/tcell_agent/rust/libtcellagent-0.11.1.dylib +0 -0
- data/lib/tcell_agent/rust/{libtcellagent-0.6.1.so → libtcellagent-0.11.1.so} +0 -0
- data/lib/tcell_agent/rust/models.rb +16 -0
- data/lib/tcell_agent/rust/tcellagent-0.11.1.dll +0 -0
- data/lib/tcell_agent/rust/whisperer.rb +119 -48
- data/lib/tcell_agent/sensor_events/appsensor_meta_event.rb +17 -20
- data/lib/tcell_agent/sensor_events/command_injection.rb +50 -5
- data/lib/tcell_agent/sensor_events/login_fraud.rb +34 -18
- data/lib/tcell_agent/sensor_events/patches.rb +21 -0
- data/lib/tcell_agent/sensor_events/server_agent.rb +3 -3
- data/lib/tcell_agent/sensor_events/util/utils.rb +4 -3
- data/lib/tcell_agent/servers/puma.rb +2 -2
- data/lib/tcell_agent/servers/unicorn.rb +1 -1
- data/lib/tcell_agent/utils/passwords.rb +28 -0
- data/lib/tcell_agent/version.rb +1 -1
- data/lib/tcell_agent.rb +1 -5
- data/spec/apps/rails-3.2/config/tcell_agent.config +15 -0
- data/spec/apps/rails-3.2/log/development.log +0 -0
- data/spec/apps/rails-3.2/log/test.log +12 -0
- data/spec/apps/rails-4.1/log/test.log +0 -0
- data/spec/lib/tcell_agent/agent/fork_pipe_manager_spec.rb +46 -45
- data/spec/lib/tcell_agent/agent/policy_manager_spec.rb +276 -164
- data/spec/lib/tcell_agent/agent/static_agent_spec.rb +44 -47
- data/spec/lib/tcell_agent/api/api_spec.rb +16 -16
- data/spec/lib/tcell_agent/appsensor/injections_reporter_spec.rb +131 -116
- data/spec/lib/tcell_agent/appsensor/meta_data_spec.rb +55 -51
- data/spec/lib/tcell_agent/cmdi_spec.rb +413 -436
- data/spec/lib/tcell_agent/config/unknown_options_spec.rb +145 -128
- data/spec/lib/tcell_agent/configuration_spec.rb +165 -169
- data/spec/lib/tcell_agent/hooks/login_fraud_spec.rb +144 -153
- data/spec/lib/tcell_agent/instrumentation_spec.rb +84 -85
- data/spec/lib/tcell_agent/patches_spec.rb +70 -111
- data/spec/lib/tcell_agent/policies/appsensor_policy_spec.rb +313 -244
- data/spec/lib/tcell_agent/policies/clickjacking_policy_spec.rb +28 -28
- data/spec/lib/tcell_agent/policies/command_injection_policy_spec.rb +643 -513
- data/spec/lib/tcell_agent/policies/content_security_policy_spec.rb +55 -102
- data/spec/lib/tcell_agent/policies/dataloss_policy_spec.rb +111 -134
- data/spec/lib/tcell_agent/policies/http_redirect_policy_spec.rb +141 -146
- data/spec/lib/tcell_agent/policies/http_tx_policy_spec.rb +8 -8
- data/spec/lib/tcell_agent/policies/login_policy_spec.rb +15 -17
- data/spec/lib/tcell_agent/policies/patches_policy_spec.rb +231 -559
- data/spec/lib/tcell_agent/policies/secure_headers_policy_spec.rb +27 -27
- data/spec/lib/tcell_agent/rails/better_ip_spec.rb +30 -34
- data/spec/lib/tcell_agent/rails/logger_spec.rb +50 -49
- data/spec/lib/tcell_agent/rails/middleware/appsensor_middleware_spec.rb +182 -199
- data/spec/lib/tcell_agent/rails/middleware/dlp_middleware_spec.rb +110 -84
- data/spec/lib/tcell_agent/rails/middleware/global_middleware_spec.rb +107 -85
- data/spec/lib/tcell_agent/rails/middleware/redirect_middleware_spec.rb +68 -40
- data/spec/lib/tcell_agent/rails/middleware/tcell_body_proxy_spec.rb +81 -67
- data/spec/lib/tcell_agent/rails/responses_spec.rb +33 -37
- data/spec/lib/tcell_agent/rails/routes/grape_spec.rb +116 -121
- data/spec/lib/tcell_agent/rails/routes/route_id_spec.rb +25 -28
- data/spec/lib/tcell_agent/rails/routes/routes_spec.rb +87 -85
- data/spec/lib/tcell_agent/rails_spec.rb +1 -6
- data/spec/lib/tcell_agent/rust/models_spec.rb +112 -0
- data/spec/lib/tcell_agent/rust/whisperer_spec.rb +502 -179
- data/spec/lib/tcell_agent/sensor_events/appsensor_meta_event_spec.rb +44 -33
- data/spec/lib/tcell_agent/sensor_events/dlp_spec.rb +4 -4
- data/spec/lib/tcell_agent/sensor_events/sessions_metric_spec.rb +183 -169
- data/spec/lib/tcell_agent/sensor_events/util/sanitizer_utilities_spec.rb +25 -25
- data/spec/lib/tcell_agent/utils/bounded_queue_spec.rb +17 -20
- data/spec/lib/tcell_agent/utils/params_spec.rb +28 -28
- data/spec/lib/tcell_agent/utils/passwords_spec.rb +143 -0
- data/spec/lib/tcell_agent/utils/strings_spec.rb +35 -35
- data/spec/lib/tcell_agent_spec.rb +8 -8
- data/spec/spec_helper.rb +4 -4
- data/spec/support/middleware_helper.rb +10 -10
- data/spec/support/static_agent_overrides.rb +16 -12
- data/tcell_agent.gemspec +17 -33
- metadata +43 -198
- data/LICENSE_libinjection +0 -32
- data/Readme.txt +0 -7
- data/ext/libinjection/extconf.rb +0 -3
- data/ext/libinjection/libinjection.h +0 -65
- data/ext/libinjection/libinjection_html5.c +0 -847
- data/ext/libinjection/libinjection_html5.h +0 -54
- data/ext/libinjection/libinjection_sqli.c +0 -2317
- data/ext/libinjection/libinjection_sqli.h +0 -295
- data/ext/libinjection/libinjection_sqli_data.h +0 -9004
- data/ext/libinjection/libinjection_wrap.c +0 -3525
- data/ext/libinjection/libinjection_xss.c +0 -531
- data/ext/libinjection/libinjection_xss.h +0 -21
- data/lib/tcell_agent/appsensor/injections_matcher.rb +0 -155
- data/lib/tcell_agent/appsensor/rules/appsensor_rule_manager.rb +0 -49
- data/lib/tcell_agent/appsensor/rules/appsensor_rule_set.rb +0 -67
- data/lib/tcell_agent/appsensor/rules/baserules.json +0 -467
- data/lib/tcell_agent/patches/block_rule.rb +0 -93
- data/lib/tcell_agent/patches/sensors_matcher.rb +0 -31
- data/lib/tcell_agent/policies/appsensor/cmdi_sensor.rb +0 -23
- data/lib/tcell_agent/policies/appsensor/fpt_sensor.rb +0 -23
- data/lib/tcell_agent/policies/appsensor/injection_sensor.rb +0 -117
- data/lib/tcell_agent/policies/appsensor/nullbyte_sensor.rb +0 -26
- data/lib/tcell_agent/policies/appsensor/retr_sensor.rb +0 -22
- data/lib/tcell_agent/policies/appsensor/sqli_sensor.rb +0 -34
- data/lib/tcell_agent/policies/appsensor/xss_sensor.rb +0 -34
- data/lib/tcell_agent/policies/appsensor_policy.rb +0 -49
- data/lib/tcell_agent/policies/command_injection_policy.rb +0 -196
- data/lib/tcell_agent/policies/honeytokens_policy.rb +0 -69
- data/lib/tcell_agent/policies/patches_policy.rb +0 -84
- data/lib/tcell_agent/rust/libtcellagent-0.6.1.dylib +0 -0
- data/lib/tcell_agent/rust/tcellagent-0.6.1.dll +0 -0
- data/spec/apps/rails-3.2/Gemfile +0 -25
- data/spec/apps/rails-3.2/Gemfile.lock +0 -126
- data/spec/apps/rails-3.2/Rakefile +0 -7
- data/spec/apps/rails-3.2/app/assets/images/rails.png +0 -0
- data/spec/apps/rails-3.2/app/assets/javascripts/application.js +0 -15
- data/spec/apps/rails-3.2/app/assets/stylesheets/application.css +0 -13
- data/spec/apps/rails-3.2/app/controllers/application_controller.rb +0 -3
- data/spec/apps/rails-3.2/app/controllers/t_cell_app_controller.rb +0 -5
- data/spec/apps/rails-3.2/app/helpers/application_helper.rb +0 -2
- data/spec/apps/rails-3.2/app/views/layouts/application.html.erb +0 -14
- data/spec/apps/rails-3.2/app/views/t_cell_app/index.html.erb +0 -1
- data/spec/apps/rails-3.2/config/application.rb +0 -63
- data/spec/apps/rails-3.2/config/boot.rb +0 -6
- data/spec/apps/rails-3.2/config/environment.rb +0 -5
- data/spec/apps/rails-3.2/config/environments/test.rb +0 -37
- data/spec/apps/rails-3.2/config/routes.rb +0 -11
- data/spec/apps/rails-3.2/config.ru +0 -4
- data/spec/apps/rails-4.1/Gemfile +0 -7
- data/spec/apps/rails-4.1/Gemfile.lock +0 -114
- data/spec/apps/rails-4.1/Rakefile +0 -6
- data/spec/apps/rails-4.1/app/assets/javascripts/application.js +0 -16
- data/spec/apps/rails-4.1/app/assets/stylesheets/application.css +0 -15
- data/spec/apps/rails-4.1/app/controllers/application_controller.rb +0 -5
- data/spec/apps/rails-4.1/app/controllers/t_cell_app_controller.rb +0 -5
- data/spec/apps/rails-4.1/app/helpers/application_helper.rb +0 -2
- data/spec/apps/rails-4.1/app/views/layouts/application.html.erb +0 -14
- data/spec/apps/rails-4.1/app/views/t_cell_app/index.html.erb +0 -1
- data/spec/apps/rails-4.1/config/application.rb +0 -24
- data/spec/apps/rails-4.1/config/boot.rb +0 -4
- data/spec/apps/rails-4.1/config/environment.rb +0 -5
- data/spec/apps/rails-4.1/config/environments/test.rb +0 -41
- data/spec/apps/rails-4.1/config/initializers/assets.rb +0 -8
- data/spec/apps/rails-4.1/config/initializers/backtrace_silencers.rb +0 -7
- data/spec/apps/rails-4.1/config/initializers/cookies_serializer.rb +0 -3
- data/spec/apps/rails-4.1/config/initializers/filter_parameter_logging.rb +0 -4
- data/spec/apps/rails-4.1/config/initializers/inflections.rb +0 -16
- data/spec/apps/rails-4.1/config/initializers/mime_types.rb +0 -4
- data/spec/apps/rails-4.1/config/initializers/session_store.rb +0 -3
- data/spec/apps/rails-4.1/config/initializers/wrap_parameters.rb +0 -14
- data/spec/apps/rails-4.1/config/locales/en.yml +0 -23
- data/spec/apps/rails-4.1/config/routes.rb +0 -12
- data/spec/apps/rails-4.1/config/secrets.yml +0 -22
- data/spec/apps/rails-4.1/config.ru +0 -4
- data/spec/controllers/application_controller.rb +0 -12
- data/spec/lib/tcell_agent/appsensor/injections_matcher_spec.rb +0 -522
- data/spec/lib/tcell_agent/appsensor/rules/appsensor_rule_manager_spec.rb +0 -23
- data/spec/lib/tcell_agent/appsensor/rules/appsensor_rule_set_spec.rb +0 -159
- data/spec/lib/tcell_agent/patches/block_rule_spec.rb +0 -458
- data/spec/lib/tcell_agent/patches/sensors_matcher_spec.rb +0 -35
- data/spec/lib/tcell_agent/policies/appsensor/cmdi_sensor_spec.rb +0 -139
- data/spec/lib/tcell_agent/policies/appsensor/fpt_sensor_spec.rb +0 -139
- data/spec/lib/tcell_agent/policies/appsensor/nullbyte_sensor_spec.rb +0 -167
- data/spec/lib/tcell_agent/policies/appsensor/retr_sensor_spec.rb +0 -139
- data/spec/lib/tcell_agent/policies/appsensor/sqli_sensor_spec.rb +0 -246
- data/spec/lib/tcell_agent/policies/appsensor/xss_sensor_spec.rb +0 -882
- data/spec/lib/tcell_agent/policies/honeytokens_policy_spec.rb +0 -22
@@ -1,882 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
module TCellAgent
|
6
|
-
module Policies
|
7
|
-
|
8
|
-
describe XssSensor do
|
9
|
-
describe "#initialize" do
|
10
|
-
context "default sensor" do
|
11
|
-
it "should have properties set to defaults" do
|
12
|
-
sensor = XssSensor.new
|
13
|
-
expect(sensor.enabled).to eq(false)
|
14
|
-
expect(sensor.libinjection).to eq(false)
|
15
|
-
expect(sensor.detection_point).to eq("xss")
|
16
|
-
expect(sensor.exclude_headers).to eq(false)
|
17
|
-
expect(sensor.exclude_forms).to eq(false)
|
18
|
-
expect(sensor.exclude_cookies).to eq(false)
|
19
|
-
expect(sensor.exclusions).to eq({})
|
20
|
-
expect(sensor.active_pattern_ids).to eq(Set.new)
|
21
|
-
expect(sensor.v1_compatability_enabled).to eq(false)
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
context "setting enabled on sensor" do
|
26
|
-
it "should be enabled" do
|
27
|
-
sensor = XssSensor.new({"enabled" => true})
|
28
|
-
expect(sensor.enabled).to eq(true)
|
29
|
-
expect(sensor.libinjection).to eq(false)
|
30
|
-
expect(sensor.detection_point).to eq("xss")
|
31
|
-
expect(sensor.exclude_headers).to eq(false)
|
32
|
-
expect(sensor.exclude_forms).to eq(false)
|
33
|
-
expect(sensor.exclude_cookies).to eq(false)
|
34
|
-
expect(sensor.exclusions).to eq({})
|
35
|
-
expect(sensor.active_pattern_ids).to eq(Set.new)
|
36
|
-
expect(sensor.v1_compatability_enabled).to eq(false)
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
context "setting libinjection on sensor" do
|
41
|
-
it "should have libinjection" do
|
42
|
-
sensor = XssSensor.new({"libinjection" => true})
|
43
|
-
expect(sensor.enabled).to eq(false)
|
44
|
-
expect(sensor.libinjection).to eq(true)
|
45
|
-
expect(sensor.detection_point).to eq("xss")
|
46
|
-
expect(sensor.exclude_headers).to eq(false)
|
47
|
-
expect(sensor.exclude_forms).to eq(false)
|
48
|
-
expect(sensor.exclude_cookies).to eq(false)
|
49
|
-
expect(sensor.exclusions).to eq({})
|
50
|
-
expect(sensor.active_pattern_ids).to eq(Set.new)
|
51
|
-
expect(sensor.v1_compatability_enabled).to eq(false)
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
context "setting exclude_headers on sensor" do
|
56
|
-
it "should have exclude_headers" do
|
57
|
-
sensor = XssSensor.new({"exclude_headers" => true})
|
58
|
-
expect(sensor.enabled).to eq(false)
|
59
|
-
expect(sensor.libinjection).to eq(false)
|
60
|
-
expect(sensor.detection_point).to eq("xss")
|
61
|
-
expect(sensor.exclude_headers).to eq(true)
|
62
|
-
expect(sensor.exclude_forms).to eq(false)
|
63
|
-
expect(sensor.exclude_cookies).to eq(false)
|
64
|
-
expect(sensor.exclusions).to eq({})
|
65
|
-
expect(sensor.active_pattern_ids).to eq(Set.new)
|
66
|
-
expect(sensor.v1_compatability_enabled).to eq(false)
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
context "setting exclude_forms on sensor" do
|
71
|
-
it "should have exclude_forms" do
|
72
|
-
sensor = XssSensor.new({"exclude_forms" => true})
|
73
|
-
expect(sensor.enabled).to eq(false)
|
74
|
-
expect(sensor.libinjection).to eq(false)
|
75
|
-
expect(sensor.detection_point).to eq("xss")
|
76
|
-
expect(sensor.exclude_headers).to eq(false)
|
77
|
-
expect(sensor.exclude_forms).to eq(true)
|
78
|
-
expect(sensor.exclude_cookies).to eq(false)
|
79
|
-
expect(sensor.exclusions).to eq({})
|
80
|
-
expect(sensor.active_pattern_ids).to eq(Set.new)
|
81
|
-
expect(sensor.v1_compatability_enabled).to eq(false)
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
context "setting exclude_cookies on sensor" do
|
86
|
-
it "should have exclude_cookies" do
|
87
|
-
sensor = XssSensor.new({"exclude_cookies" => true})
|
88
|
-
expect(sensor.enabled).to eq(false)
|
89
|
-
expect(sensor.libinjection).to eq(false)
|
90
|
-
expect(sensor.detection_point).to eq("xss")
|
91
|
-
expect(sensor.exclude_headers).to eq(false)
|
92
|
-
expect(sensor.exclude_forms).to eq(false)
|
93
|
-
expect(sensor.exclude_cookies).to eq(true)
|
94
|
-
expect(sensor.exclusions).to eq({})
|
95
|
-
expect(sensor.active_pattern_ids).to eq(Set.new)
|
96
|
-
expect(sensor.v1_compatability_enabled).to eq(false)
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
100
|
-
context "setting exclusions on sensor" do
|
101
|
-
it "should have exclude_cookies" do
|
102
|
-
sensor = XssSensor.new({"exclusions" => {"word" => ["form", "header"]}})
|
103
|
-
expect(sensor.enabled).to eq(false)
|
104
|
-
expect(sensor.libinjection).to eq(false)
|
105
|
-
expect(sensor.detection_point).to eq("xss")
|
106
|
-
expect(sensor.exclude_headers).to eq(false)
|
107
|
-
expect(sensor.exclude_forms).to eq(false)
|
108
|
-
expect(sensor.exclude_cookies).to eq(false)
|
109
|
-
expect(sensor.exclusions).to eq(
|
110
|
-
{"word"=>Set.new(["form", "header"])}
|
111
|
-
)
|
112
|
-
expect(sensor.active_pattern_ids).to eq(Set.new)
|
113
|
-
expect(sensor.v1_compatability_enabled).to eq(false)
|
114
|
-
end
|
115
|
-
end
|
116
|
-
|
117
|
-
context "setting active_pattern_ids on sensor" do
|
118
|
-
it "should have active_pattern_ids" do
|
119
|
-
sensor = XssSensor.new({"patterns" => ["1", "2", "3"]})
|
120
|
-
expect(sensor.enabled).to eq(false)
|
121
|
-
expect(sensor.libinjection).to eq(false)
|
122
|
-
expect(sensor.detection_point).to eq("xss")
|
123
|
-
expect(sensor.exclude_headers).to eq(false)
|
124
|
-
expect(sensor.exclude_forms).to eq(false)
|
125
|
-
expect(sensor.exclude_cookies).to eq(false)
|
126
|
-
expect(sensor.exclusions).to eq({})
|
127
|
-
expect(sensor.active_pattern_ids).to eq(
|
128
|
-
Set.new(["1", "2", "3"])
|
129
|
-
)
|
130
|
-
expect(sensor.v1_compatability_enabled).to eq(false)
|
131
|
-
end
|
132
|
-
end
|
133
|
-
|
134
|
-
context "setting v1_compatability_enabled on sensor" do
|
135
|
-
it "should have v1_compatability_enabled" do
|
136
|
-
sensor = XssSensor.new({"v1_compatability_enabled" => true})
|
137
|
-
expect(sensor.enabled).to eq(false)
|
138
|
-
expect(sensor.libinjection).to eq(false)
|
139
|
-
expect(sensor.detection_point).to eq("xss")
|
140
|
-
expect(sensor.exclude_headers).to eq(false)
|
141
|
-
expect(sensor.exclude_forms).to eq(false)
|
142
|
-
expect(sensor.exclude_cookies).to eq(false)
|
143
|
-
expect(sensor.exclusions).to eq({})
|
144
|
-
expect(sensor.active_pattern_ids).to eq(Set.new)
|
145
|
-
expect(sensor.v1_compatability_enabled).to eq(true)
|
146
|
-
end
|
147
|
-
end
|
148
|
-
|
149
|
-
context "setting excluded_route_ids on sensor" do
|
150
|
-
it "should have excluded_route_ids" do
|
151
|
-
sensor = XssSensor.new({"exclude_routes" => ["excluded_route_id"]})
|
152
|
-
expect(sensor.enabled).to eq(false)
|
153
|
-
expect(sensor.libinjection).to eq(false)
|
154
|
-
expect(sensor.detection_point).to eq("xss")
|
155
|
-
expect(sensor.exclude_headers).to eq(false)
|
156
|
-
expect(sensor.exclude_forms).to eq(false)
|
157
|
-
expect(sensor.exclude_cookies).to eq(false)
|
158
|
-
expect(sensor.exclusions).to eq({})
|
159
|
-
expect(sensor.active_pattern_ids).to eq(Set.new)
|
160
|
-
expect(sensor.v1_compatability_enabled).to eq(false)
|
161
|
-
expect(sensor.excluded_route_ids).to eq(Set.new(["excluded_route_id"]))
|
162
|
-
end
|
163
|
-
end
|
164
|
-
end
|
165
|
-
|
166
|
-
describe "#find_vulnerability" do
|
167
|
-
before(:each) do
|
168
|
-
@sensor = XssSensor.new({"enabled" => true})
|
169
|
-
end
|
170
|
-
|
171
|
-
context "with libinjection enabled" do
|
172
|
-
context "with param value that doesn't match any vulnerabilities" do
|
173
|
-
it "should return nil" do
|
174
|
-
@sensor.libinjection = true
|
175
|
-
|
176
|
-
ruleset = double("ruleset")
|
177
|
-
expect(@sensor).to receive(:get_ruleset).and_return(ruleset)
|
178
|
-
expect(ruleset).to receive(:check_violation).with(
|
179
|
-
"param", "value", Set.new, false
|
180
|
-
).and_return(nil)
|
181
|
-
|
182
|
-
expect(@sensor.find_vulnerability("param", "value")).to eq(nil)
|
183
|
-
end
|
184
|
-
|
185
|
-
context "and it has utf-8 chars" do
|
186
|
-
it "should return nil but not fail miserably" do
|
187
|
-
@sensor.libinjection = true
|
188
|
-
|
189
|
-
ruleset = double("ruleset")
|
190
|
-
expect(@sensor).to receive(:get_ruleset).and_return(ruleset)
|
191
|
-
expect(ruleset).to receive(:check_violation).with(
|
192
|
-
"param", "Müller", Set.new, false
|
193
|
-
).and_return(nil)
|
194
|
-
|
195
|
-
expect(@sensor.find_vulnerability("param", "Müller")).to eq(nil)
|
196
|
-
end
|
197
|
-
end
|
198
|
-
end
|
199
|
-
|
200
|
-
context "with param value that matches a vulnerability" do
|
201
|
-
it "should return the param and it's value" do
|
202
|
-
@sensor.libinjection = true
|
203
|
-
|
204
|
-
expect(@sensor).to_not receive(:get_ruleset)
|
205
|
-
|
206
|
-
expect(@sensor.find_vulnerability("param_name", "<script>")).to eq(
|
207
|
-
{"param"=>"param_name", "value"=>"<script>", "pattern"=>"li"}
|
208
|
-
)
|
209
|
-
end
|
210
|
-
end
|
211
|
-
end
|
212
|
-
|
213
|
-
context "with no ruleset" do
|
214
|
-
it "should return nil" do
|
215
|
-
expect(@sensor).to receive(:get_ruleset).and_return(nil)
|
216
|
-
|
217
|
-
expect(@sensor.find_vulnerability("param", "value")).to eq(nil)
|
218
|
-
end
|
219
|
-
end
|
220
|
-
|
221
|
-
context "with ruletset" do
|
222
|
-
context "with param value that doesn't match any vulnerabilities" do
|
223
|
-
it "should return nil" do
|
224
|
-
ruleset = double("ruleset")
|
225
|
-
expect(@sensor).to receive(:get_ruleset).and_return(ruleset)
|
226
|
-
expect(ruleset).to receive(:check_violation).with(
|
227
|
-
"param", "value", Set.new, false
|
228
|
-
).and_return(nil)
|
229
|
-
|
230
|
-
expect(@sensor.find_vulnerability("param", "value")).to eq(nil)
|
231
|
-
end
|
232
|
-
end
|
233
|
-
|
234
|
-
context "with param value that matches a vulnerability" do
|
235
|
-
it "should return the param and it's value" do
|
236
|
-
ruleset = double("ruleset")
|
237
|
-
expect(@sensor).to receive(:get_ruleset).and_return(ruleset)
|
238
|
-
expect(ruleset).to receive(:check_violation).with(
|
239
|
-
"param", "value", Set.new, false
|
240
|
-
).and_return(true)
|
241
|
-
|
242
|
-
expect(@sensor.find_vulnerability("param", "value")).to eq(true)
|
243
|
-
end
|
244
|
-
end
|
245
|
-
end
|
246
|
-
end
|
247
|
-
|
248
|
-
describe "#get_injection_attempt" do
|
249
|
-
before(:each) do
|
250
|
-
@appsensor_meta = TCellAgent::SensorEvents::AppSensorMetaEvent.new(
|
251
|
-
"get",
|
252
|
-
"remote_address",
|
253
|
-
"route_id",
|
254
|
-
"session_id",
|
255
|
-
"user_id",
|
256
|
-
"transaction_id")
|
257
|
-
end
|
258
|
-
|
259
|
-
context "enabled sensor" do
|
260
|
-
context "param has NO vulnerability" do
|
261
|
-
it "should return false" do
|
262
|
-
sensor = XssSensor.new({"enabled" => true})
|
263
|
-
result = sensor.get_injection_attempt(
|
264
|
-
XssSensor::GET_PARAM,
|
265
|
-
@appsensor_meta,
|
266
|
-
"param_name",
|
267
|
-
"param_value"
|
268
|
-
)
|
269
|
-
|
270
|
-
expect(result).to eq(false)
|
271
|
-
end
|
272
|
-
|
273
|
-
context "no excluded routes" do
|
274
|
-
it "should return false" do
|
275
|
-
sensor = XssSensor.new({"enabled" => true, "exclude_routes" => []})
|
276
|
-
result = sensor.get_injection_attempt(
|
277
|
-
XssSensor::GET_PARAM,
|
278
|
-
@appsensor_meta,
|
279
|
-
"param_name",
|
280
|
-
"param_value"
|
281
|
-
)
|
282
|
-
|
283
|
-
expect(result).to eq(false)
|
284
|
-
end
|
285
|
-
end
|
286
|
-
|
287
|
-
context "has excluded routes" do
|
288
|
-
context "route id matches" do
|
289
|
-
it "should return false" do
|
290
|
-
sensor = XssSensor.new({"enabled" => true, "exclude_routes" => ["route_id"]})
|
291
|
-
result = sensor.get_injection_attempt(
|
292
|
-
XssSensor::GET_PARAM,
|
293
|
-
@appsensor_meta,
|
294
|
-
"param_name",
|
295
|
-
"param_value"
|
296
|
-
)
|
297
|
-
|
298
|
-
expect(result).to eq(false)
|
299
|
-
end
|
300
|
-
end
|
301
|
-
context "route id does not match" do
|
302
|
-
it "should return false" do
|
303
|
-
sensor = XssSensor.new({"enabled" => true, "exclude_routes" => ["unmatching_route_id"]})
|
304
|
-
result = sensor.get_injection_attempt(
|
305
|
-
XssSensor::GET_PARAM,
|
306
|
-
@appsensor_meta,
|
307
|
-
"param_name",
|
308
|
-
"param_value"
|
309
|
-
)
|
310
|
-
|
311
|
-
expect(result).to eq(false)
|
312
|
-
end
|
313
|
-
end
|
314
|
-
end
|
315
|
-
end
|
316
|
-
|
317
|
-
context "param has a vulnerability" do
|
318
|
-
context "param is a URI param" do
|
319
|
-
context "exclude forms sensor" do
|
320
|
-
it "should return false" do
|
321
|
-
sensor = XssSensor.new({"enabled" => true, "exclude_forms" => true})
|
322
|
-
|
323
|
-
expect(sensor).to_not receive(:find_vulnerability)
|
324
|
-
|
325
|
-
result = sensor.get_injection_attempt(
|
326
|
-
XssSensor::URI_PARAM,
|
327
|
-
@appsensor_meta,
|
328
|
-
"param_name",
|
329
|
-
"param_value"
|
330
|
-
)
|
331
|
-
|
332
|
-
expect(result).to eq(false)
|
333
|
-
end
|
334
|
-
end
|
335
|
-
|
336
|
-
context "exclude cookies sensor" do
|
337
|
-
it "should return the injection attempt" do
|
338
|
-
sensor = XssSensor.new({"enabled" => true, "exclude_cookies" => true})
|
339
|
-
|
340
|
-
expect(sensor).to receive(:find_vulnerability).and_return(
|
341
|
-
{"param" => "vuln_param", "value" => "vuln_value", "pattern" => "1"}
|
342
|
-
)
|
343
|
-
|
344
|
-
result = sensor.get_injection_attempt(
|
345
|
-
XssSensor::URI_PARAM,
|
346
|
-
@appsensor_meta,
|
347
|
-
"param_name",
|
348
|
-
"param_value"
|
349
|
-
)
|
350
|
-
|
351
|
-
expect(result.type_of_param).to eq(XssSensor::URI_PARAM)
|
352
|
-
expect(result.detection_point).to eq(sensor.detection_point)
|
353
|
-
expect(result.param_name).to eq("vuln_param")
|
354
|
-
expect(result.param_value).to eq("vuln_value")
|
355
|
-
expect(result.pattern).to eq("1")
|
356
|
-
end
|
357
|
-
end
|
358
|
-
end
|
359
|
-
|
360
|
-
context "param is a GET param" do
|
361
|
-
context "exclude forms sensor" do
|
362
|
-
it "should return false" do
|
363
|
-
sensor = XssSensor.new({"enabled" => true, "exclude_forms" => true})
|
364
|
-
|
365
|
-
expect(sensor).to_not receive(:find_vulnerability)
|
366
|
-
|
367
|
-
result = sensor.get_injection_attempt(
|
368
|
-
XssSensor::GET_PARAM,
|
369
|
-
@appsensor_meta,
|
370
|
-
"param_name",
|
371
|
-
"param_value"
|
372
|
-
)
|
373
|
-
|
374
|
-
expect(result).to eq(false)
|
375
|
-
end
|
376
|
-
|
377
|
-
context "no excluded routes" do
|
378
|
-
it "should return false" do
|
379
|
-
sensor = XssSensor.new({"enabled" => true, "exclude_forms" => true, "exclude_routes" => []})
|
380
|
-
|
381
|
-
expect(sensor).to_not receive(:find_vulnerability)
|
382
|
-
|
383
|
-
result = sensor.get_injection_attempt(
|
384
|
-
XssSensor::GET_PARAM,
|
385
|
-
@appsensor_meta,
|
386
|
-
"param_name",
|
387
|
-
"param_value"
|
388
|
-
)
|
389
|
-
|
390
|
-
expect(result).to eq(false)
|
391
|
-
end
|
392
|
-
end
|
393
|
-
|
394
|
-
context "has excluded routes" do
|
395
|
-
context "route id matches" do
|
396
|
-
it "should return false" do
|
397
|
-
sensor = XssSensor.new({
|
398
|
-
"enabled" => true,
|
399
|
-
"exclude_forms" => true,
|
400
|
-
"exclude_routes" => ["route_id"]
|
401
|
-
})
|
402
|
-
|
403
|
-
expect(sensor).to_not receive(:find_vulnerability)
|
404
|
-
|
405
|
-
result = sensor.get_injection_attempt(
|
406
|
-
XssSensor::GET_PARAM,
|
407
|
-
@appsensor_meta,
|
408
|
-
"param_name",
|
409
|
-
"param_value"
|
410
|
-
)
|
411
|
-
|
412
|
-
expect(result).to eq(false)
|
413
|
-
end
|
414
|
-
end
|
415
|
-
|
416
|
-
context "route id does not match" do
|
417
|
-
it "should return false" do
|
418
|
-
sensor = XssSensor.new({
|
419
|
-
"enabled" => true,
|
420
|
-
"exclude_forms" => true,
|
421
|
-
"exclude_routes" => ["unmatching_route_id"]
|
422
|
-
})
|
423
|
-
|
424
|
-
expect(sensor).to_not receive(:find_vulnerability)
|
425
|
-
|
426
|
-
result = sensor.get_injection_attempt(
|
427
|
-
XssSensor::GET_PARAM,
|
428
|
-
@appsensor_meta,
|
429
|
-
"param_name",
|
430
|
-
"param_value"
|
431
|
-
)
|
432
|
-
|
433
|
-
expect(result).to eq(false)
|
434
|
-
end
|
435
|
-
end
|
436
|
-
end
|
437
|
-
end
|
438
|
-
|
439
|
-
context "exclude cookies sensor" do
|
440
|
-
it "should return true" do
|
441
|
-
sensor = XssSensor.new({
|
442
|
-
"enabled" => true,
|
443
|
-
"exclude_cookies" => true,
|
444
|
-
})
|
445
|
-
|
446
|
-
expect(sensor).to receive(:find_vulnerability).and_return(
|
447
|
-
{"param" => "vuln_param", "value" => "vuln_value", "pattern" => "1"}
|
448
|
-
)
|
449
|
-
|
450
|
-
result = sensor.get_injection_attempt(
|
451
|
-
XssSensor::GET_PARAM,
|
452
|
-
@appsensor_meta,
|
453
|
-
"param_name",
|
454
|
-
"param_value",
|
455
|
-
)
|
456
|
-
|
457
|
-
expect(result.type_of_param).to eq(XssSensor::GET_PARAM)
|
458
|
-
expect(result.detection_point).to eq(sensor.detection_point)
|
459
|
-
expect(result.param_name).to eq("vuln_param")
|
460
|
-
expect(result.param_value).to eq("vuln_value")
|
461
|
-
expect(result.pattern).to eq("1")
|
462
|
-
end
|
463
|
-
|
464
|
-
context "no excluded routes" do
|
465
|
-
it "should return true" do
|
466
|
-
sensor = XssSensor.new({
|
467
|
-
"enabled" => true,
|
468
|
-
"exclude_cookies" => true,
|
469
|
-
"exclude_routes" => []
|
470
|
-
})
|
471
|
-
|
472
|
-
expect(sensor).to receive(:find_vulnerability).and_return(
|
473
|
-
{"param" => "vuln_param", "value" => "vuln_value", "pattern" => "1"}
|
474
|
-
)
|
475
|
-
|
476
|
-
result = sensor.get_injection_attempt(
|
477
|
-
XssSensor::GET_PARAM,
|
478
|
-
@appsensor_meta,
|
479
|
-
"param_name",
|
480
|
-
"param_value"
|
481
|
-
)
|
482
|
-
|
483
|
-
expect(result.type_of_param).to eq(XssSensor::GET_PARAM)
|
484
|
-
expect(result.detection_point).to eq(sensor.detection_point)
|
485
|
-
expect(result.param_name).to eq("vuln_param")
|
486
|
-
expect(result.param_value).to eq("vuln_value")
|
487
|
-
expect(result.pattern).to eq("1")
|
488
|
-
end
|
489
|
-
end
|
490
|
-
|
491
|
-
context "has excluded routes" do
|
492
|
-
context "route id matches" do
|
493
|
-
it "should return false" do
|
494
|
-
sensor = XssSensor.new({
|
495
|
-
"enabled" => true,
|
496
|
-
"exclude_cookies" => true,
|
497
|
-
"exclude_routes" => ["route_id"]
|
498
|
-
})
|
499
|
-
|
500
|
-
expect(sensor).to_not receive(:find_vulnerability)
|
501
|
-
|
502
|
-
result = sensor.get_injection_attempt(
|
503
|
-
XssSensor::GET_PARAM,
|
504
|
-
@appsensor_meta,
|
505
|
-
"param_name",
|
506
|
-
"param_value"
|
507
|
-
)
|
508
|
-
|
509
|
-
expect(result).to eq(false)
|
510
|
-
end
|
511
|
-
end
|
512
|
-
|
513
|
-
context "route id does not match" do
|
514
|
-
it "should return true" do
|
515
|
-
sensor = XssSensor.new({
|
516
|
-
"enabled" => true,
|
517
|
-
"exclude_cookies" => true,
|
518
|
-
"exclude_routes" => ["unmatching_route_id"]
|
519
|
-
})
|
520
|
-
|
521
|
-
expect(sensor).to receive(:find_vulnerability).and_return(
|
522
|
-
{"param" => "vuln_param", "value" => "vuln_value", "pattern" => "1"}
|
523
|
-
)
|
524
|
-
|
525
|
-
result = sensor.get_injection_attempt(
|
526
|
-
XssSensor::GET_PARAM,
|
527
|
-
@appsensor_meta,
|
528
|
-
"param_name",
|
529
|
-
"param_value"
|
530
|
-
)
|
531
|
-
|
532
|
-
expect(result.type_of_param).to eq(XssSensor::GET_PARAM)
|
533
|
-
expect(result.detection_point).to eq(sensor.detection_point)
|
534
|
-
expect(result.param_name).to eq("vuln_param")
|
535
|
-
expect(result.param_value).to eq("vuln_value")
|
536
|
-
expect(result.pattern).to eq("1")
|
537
|
-
end
|
538
|
-
end
|
539
|
-
end
|
540
|
-
end
|
541
|
-
|
542
|
-
context "exclude headers sensor" do
|
543
|
-
it "should return true" do
|
544
|
-
sensor = XssSensor.new({
|
545
|
-
"enabled" => true,
|
546
|
-
"exclude_headers" => true,
|
547
|
-
})
|
548
|
-
|
549
|
-
expect(sensor).to receive(:find_vulnerability).and_return(
|
550
|
-
{"param" => "vuln_param", "value" => "vuln_value", "pattern" => "1"}
|
551
|
-
)
|
552
|
-
|
553
|
-
result = sensor.get_injection_attempt(
|
554
|
-
XssSensor::GET_PARAM,
|
555
|
-
@appsensor_meta,
|
556
|
-
"param_name",
|
557
|
-
"param_value",
|
558
|
-
)
|
559
|
-
|
560
|
-
expect(result.type_of_param).to eq(XssSensor::GET_PARAM)
|
561
|
-
expect(result.detection_point).to eq(sensor.detection_point)
|
562
|
-
expect(result.param_name).to eq("vuln_param")
|
563
|
-
expect(result.param_value).to eq("vuln_value")
|
564
|
-
expect(result.pattern).to eq("1")
|
565
|
-
end
|
566
|
-
end
|
567
|
-
end
|
568
|
-
|
569
|
-
context "param is a POST param" do
|
570
|
-
context "exclude forms sensor" do
|
571
|
-
it "should return false" do
|
572
|
-
sensor = XssSensor.new({
|
573
|
-
"enabled" => true,
|
574
|
-
"exclude_forms" => true
|
575
|
-
})
|
576
|
-
|
577
|
-
expect(sensor).to_not receive(:find_vulnerability)
|
578
|
-
|
579
|
-
result = sensor.get_injection_attempt(
|
580
|
-
XssSensor::POST_PARAM,
|
581
|
-
@appsensor_meta,
|
582
|
-
"param_name",
|
583
|
-
"param_value",
|
584
|
-
)
|
585
|
-
|
586
|
-
expect(result).to eq(false)
|
587
|
-
end
|
588
|
-
end
|
589
|
-
|
590
|
-
context "exclude cookies sensor" do
|
591
|
-
it "should return true" do
|
592
|
-
sensor = XssSensor.new({
|
593
|
-
"enabled" => true,
|
594
|
-
"exclude_cookies" => true
|
595
|
-
})
|
596
|
-
|
597
|
-
expect(sensor).to receive(:find_vulnerability).and_return(
|
598
|
-
{"param" => "vuln_param", "value" => "vuln_value", "pattern" => "1"}
|
599
|
-
)
|
600
|
-
|
601
|
-
result = sensor.get_injection_attempt(
|
602
|
-
XssSensor::POST_PARAM,
|
603
|
-
@appsensor_meta,
|
604
|
-
"param_name",
|
605
|
-
"param_value",
|
606
|
-
)
|
607
|
-
|
608
|
-
expect(result.type_of_param).to eq(XssSensor::POST_PARAM)
|
609
|
-
expect(result.detection_point).to eq(sensor.detection_point)
|
610
|
-
expect(result.param_name).to eq("vuln_param")
|
611
|
-
expect(result.param_value).to eq("vuln_value")
|
612
|
-
expect(result.pattern).to eq("1")
|
613
|
-
end
|
614
|
-
end
|
615
|
-
|
616
|
-
context "exclude headers sensor" do
|
617
|
-
it "should return true" do
|
618
|
-
sensor = XssSensor.new({
|
619
|
-
"enabled" => true,
|
620
|
-
"exclude_headers" => true,
|
621
|
-
})
|
622
|
-
|
623
|
-
expect(sensor).to receive(:find_vulnerability).and_return(
|
624
|
-
{"param" => "vuln_param", "value" => "vuln_value", "pattern" => "1"}
|
625
|
-
)
|
626
|
-
|
627
|
-
result = sensor.get_injection_attempt(
|
628
|
-
XssSensor::POST_PARAM,
|
629
|
-
@appsensor_meta,
|
630
|
-
"param_name",
|
631
|
-
"param_value",
|
632
|
-
)
|
633
|
-
|
634
|
-
expect(result.type_of_param).to eq(XssSensor::POST_PARAM)
|
635
|
-
expect(result.detection_point).to eq(sensor.detection_point)
|
636
|
-
expect(result.param_name).to eq("vuln_param")
|
637
|
-
expect(result.param_value).to eq("vuln_value")
|
638
|
-
expect(result.pattern).to eq("1")
|
639
|
-
end
|
640
|
-
end
|
641
|
-
end
|
642
|
-
|
643
|
-
context "param is a JSON param" do
|
644
|
-
context "exclude forms sensor" do
|
645
|
-
it "should return false" do
|
646
|
-
sensor = XssSensor.new({
|
647
|
-
"enabled" => true,
|
648
|
-
"exclude_forms" => true
|
649
|
-
})
|
650
|
-
|
651
|
-
expect(sensor).to_not receive(:find_vulnerability)
|
652
|
-
|
653
|
-
result = sensor.get_injection_attempt(
|
654
|
-
XssSensor::JSON_PARAM,
|
655
|
-
@appsensor_meta,
|
656
|
-
"param_name",
|
657
|
-
"param_value",
|
658
|
-
)
|
659
|
-
|
660
|
-
expect(result).to eq(false)
|
661
|
-
end
|
662
|
-
end
|
663
|
-
|
664
|
-
context "exclude cookies sensor" do
|
665
|
-
it "should return true" do
|
666
|
-
sensor = XssSensor.new({
|
667
|
-
"enabled" => true,
|
668
|
-
"exclude_cookies" => true
|
669
|
-
})
|
670
|
-
|
671
|
-
expect(sensor).to receive(:find_vulnerability).and_return(
|
672
|
-
{"param" => "vuln_param", "value" => "vuln_value", "pattern" => "1"}
|
673
|
-
)
|
674
|
-
|
675
|
-
result = sensor.get_injection_attempt(
|
676
|
-
XssSensor::JSON_PARAM,
|
677
|
-
@appsensor_meta,
|
678
|
-
"param_name",
|
679
|
-
"param_value",
|
680
|
-
)
|
681
|
-
|
682
|
-
expect(result.type_of_param).to eq(XssSensor::JSON_PARAM)
|
683
|
-
expect(result.detection_point).to eq(sensor.detection_point)
|
684
|
-
expect(result.param_name).to eq("vuln_param")
|
685
|
-
expect(result.param_value).to eq("vuln_value")
|
686
|
-
expect(result.pattern).to eq("1")
|
687
|
-
end
|
688
|
-
end
|
689
|
-
|
690
|
-
context "exclude headers sensor" do
|
691
|
-
it "should return true" do
|
692
|
-
sensor = XssSensor.new({
|
693
|
-
"enabled" => true,
|
694
|
-
"exclude_headers" => true,
|
695
|
-
})
|
696
|
-
|
697
|
-
expect(sensor).to receive(:find_vulnerability).and_return(
|
698
|
-
{"param" => "vuln_param", "value" => "vuln_value", "pattern" => "1"}
|
699
|
-
)
|
700
|
-
|
701
|
-
result = sensor.get_injection_attempt(
|
702
|
-
XssSensor::JSON_PARAM,
|
703
|
-
@appsensor_meta,
|
704
|
-
"param_name",
|
705
|
-
"param_value",
|
706
|
-
)
|
707
|
-
|
708
|
-
expect(result.type_of_param).to eq(XssSensor::JSON_PARAM)
|
709
|
-
expect(result.detection_point).to eq(sensor.detection_point)
|
710
|
-
expect(result.param_name).to eq("vuln_param")
|
711
|
-
expect(result.param_value).to eq("vuln_value")
|
712
|
-
expect(result.pattern).to eq("1")
|
713
|
-
end
|
714
|
-
end
|
715
|
-
end
|
716
|
-
|
717
|
-
context "param is a COOKIE param" do
|
718
|
-
context "exclude forms sensor" do
|
719
|
-
it "should return true" do
|
720
|
-
sensor = XssSensor.new({
|
721
|
-
"enabled" => true,
|
722
|
-
"exclude_forms" => true
|
723
|
-
})
|
724
|
-
|
725
|
-
expect(sensor).to receive(:find_vulnerability).and_return(
|
726
|
-
{"param" => "vuln_param", "value" => "vuln_value", "pattern" => "1"}
|
727
|
-
)
|
728
|
-
|
729
|
-
result = sensor.get_injection_attempt(
|
730
|
-
XssSensor::COOKIE_PARAM,
|
731
|
-
@appsensor_meta,
|
732
|
-
"param_name",
|
733
|
-
"param_value",
|
734
|
-
)
|
735
|
-
|
736
|
-
expect(result.type_of_param).to eq(XssSensor::COOKIE_PARAM)
|
737
|
-
expect(result.detection_point).to eq(sensor.detection_point)
|
738
|
-
expect(result.param_name).to eq("vuln_param")
|
739
|
-
expect(result.param_value).to eq("vuln_value")
|
740
|
-
expect(result.pattern).to eq("1")
|
741
|
-
end
|
742
|
-
end
|
743
|
-
|
744
|
-
context "exclude cookies sensor" do
|
745
|
-
it "should return false" do
|
746
|
-
sensor = XssSensor.new({
|
747
|
-
"enabled" => true,
|
748
|
-
"exclude_cookies" => true
|
749
|
-
})
|
750
|
-
|
751
|
-
expect(sensor).to_not receive(:find_vulnerability)
|
752
|
-
|
753
|
-
result = sensor.get_injection_attempt(
|
754
|
-
XssSensor::COOKIE_PARAM,
|
755
|
-
@appsensor_meta,
|
756
|
-
"param_name",
|
757
|
-
"param_value",
|
758
|
-
)
|
759
|
-
|
760
|
-
expect(result).to eq(false)
|
761
|
-
end
|
762
|
-
end
|
763
|
-
|
764
|
-
context "exclude headers sensor" do
|
765
|
-
it "should return true" do
|
766
|
-
sensor = XssSensor.new({
|
767
|
-
"enabled" => true,
|
768
|
-
"exclude_headers" => true,
|
769
|
-
})
|
770
|
-
|
771
|
-
expect(sensor).to receive(:find_vulnerability).and_return(
|
772
|
-
{"param" => "vuln_param", "value" => "vuln_value", "pattern" => "1"}
|
773
|
-
)
|
774
|
-
|
775
|
-
result = sensor.get_injection_attempt(
|
776
|
-
XssSensor::COOKIE_PARAM,
|
777
|
-
@appsensor_meta,
|
778
|
-
"param_name",
|
779
|
-
"param_value",
|
780
|
-
)
|
781
|
-
|
782
|
-
expect(result.type_of_param).to eq(XssSensor::COOKIE_PARAM)
|
783
|
-
expect(result.detection_point).to eq(sensor.detection_point)
|
784
|
-
expect(result.param_name).to eq("vuln_param")
|
785
|
-
expect(result.param_value).to eq("vuln_value")
|
786
|
-
expect(result.pattern).to eq("1")
|
787
|
-
end
|
788
|
-
end
|
789
|
-
end
|
790
|
-
|
791
|
-
context "param is a HEADER param" do
|
792
|
-
context "exclude forms sensor" do
|
793
|
-
it "should return true" do
|
794
|
-
sensor = XssSensor.new({
|
795
|
-
"enabled" => true,
|
796
|
-
"exclude_forms" => true
|
797
|
-
})
|
798
|
-
|
799
|
-
expect(sensor).to receive(:find_vulnerability).and_return(
|
800
|
-
{"param" => "vuln_param", "value" => "vuln_value", "pattern" => "1"}
|
801
|
-
)
|
802
|
-
|
803
|
-
result = sensor.get_injection_attempt(
|
804
|
-
XssSensor::HEADER_PARAM,
|
805
|
-
@appsensor_meta,
|
806
|
-
"param_name",
|
807
|
-
"param_value",
|
808
|
-
)
|
809
|
-
|
810
|
-
expect(result.type_of_param).to eq(XssSensor::HEADER_PARAM)
|
811
|
-
expect(result.detection_point).to eq(sensor.detection_point)
|
812
|
-
expect(result.param_name).to eq("vuln_param")
|
813
|
-
expect(result.param_value).to eq("vuln_value")
|
814
|
-
expect(result.pattern).to eq("1")
|
815
|
-
end
|
816
|
-
end
|
817
|
-
|
818
|
-
context "exclude cookies sensor" do
|
819
|
-
it "should return true" do
|
820
|
-
sensor = XssSensor.new({
|
821
|
-
"enabled" => true,
|
822
|
-
"exclude_cookies" => true
|
823
|
-
})
|
824
|
-
|
825
|
-
expect(sensor).to receive(:find_vulnerability).and_return(
|
826
|
-
{"param" => "vuln_param", "value" => "vuln_value", "pattern" => "1"}
|
827
|
-
)
|
828
|
-
|
829
|
-
result = sensor.get_injection_attempt(
|
830
|
-
XssSensor::HEADER_PARAM,
|
831
|
-
@appsensor_meta,
|
832
|
-
"param_name",
|
833
|
-
"param_value",
|
834
|
-
)
|
835
|
-
|
836
|
-
expect(result.type_of_param).to eq(XssSensor::HEADER_PARAM)
|
837
|
-
expect(result.detection_point).to eq(sensor.detection_point)
|
838
|
-
expect(result.param_name).to eq("vuln_param")
|
839
|
-
expect(result.param_value).to eq("vuln_value")
|
840
|
-
expect(result.pattern).to eq("1")
|
841
|
-
end
|
842
|
-
end
|
843
|
-
|
844
|
-
context "exclude headers sensor" do
|
845
|
-
it "should return true" do
|
846
|
-
sensor = XssSensor.new({
|
847
|
-
"enabled" => true,
|
848
|
-
"exclude_headers" => true,
|
849
|
-
})
|
850
|
-
|
851
|
-
expect(sensor).to_not receive(:find_vulnerability)
|
852
|
-
|
853
|
-
result = sensor.get_injection_attempt(
|
854
|
-
XssSensor::HEADER_PARAM,
|
855
|
-
@appsensor_meta,
|
856
|
-
"param_name",
|
857
|
-
"param_value",
|
858
|
-
)
|
859
|
-
|
860
|
-
expect(result).to eq(false)
|
861
|
-
end
|
862
|
-
end
|
863
|
-
end
|
864
|
-
end
|
865
|
-
end
|
866
|
-
|
867
|
-
end
|
868
|
-
|
869
|
-
describe "#applicable_for_param_type?" do
|
870
|
-
it "should be applicable for all param types" do
|
871
|
-
sensor = XssSensor.new
|
872
|
-
expect(sensor.applicable_for_param_type?(InjectionSensor::GET_PARAM)).to eq(true)
|
873
|
-
expect(sensor.applicable_for_param_type?(InjectionSensor::POST_PARAM)).to eq(true)
|
874
|
-
expect(sensor.applicable_for_param_type?(InjectionSensor::JSON_PARAM)).to eq(true)
|
875
|
-
expect(sensor.applicable_for_param_type?(InjectionSensor::COOKIE_PARAM)).to eq(true)
|
876
|
-
expect(sensor.applicable_for_param_type?(InjectionSensor::URI_PARAM)).to eq(true)
|
877
|
-
end
|
878
|
-
end
|
879
|
-
end
|
880
|
-
|
881
|
-
end
|
882
|
-
end
|