contrast-agent 6.7.0 → 6.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +0 -2
- data/.simplecov +0 -1
- data/Rakefile +0 -1
- data/ext/cs__assess_array/cs__assess_array.c +41 -10
- data/ext/cs__assess_array/cs__assess_array.h +4 -1
- data/lib/contrast/agent/assess/policy/trigger_method.rb +2 -2
- data/lib/contrast/agent/assess/policy/trigger_validation/redos_validator.rb +1 -1
- data/lib/contrast/agent/assess/policy/trigger_validation/ssrf_validator.rb +1 -1
- data/lib/contrast/agent/assess/policy/trigger_validation/xss_validator.rb +1 -1
- data/lib/contrast/agent/excluder.rb +52 -34
- data/lib/contrast/agent/exclusion_matcher.rb +21 -9
- data/lib/contrast/agent/middleware.rb +4 -4
- data/lib/contrast/agent/patching/policy/after_load_patcher.rb +6 -0
- data/lib/contrast/agent/protect/input_analyzer/input_analyzer.rb +146 -127
- data/lib/contrast/agent/protect/policy/applies_path_traversal_rule.rb +20 -0
- data/lib/contrast/agent/protect/policy/rule_applicator.rb +1 -1
- data/lib/contrast/agent/protect/rule/base.rb +45 -53
- data/lib/contrast/agent/protect/rule/base_service.rb +48 -24
- data/lib/contrast/agent/protect/rule/bot_blocker/bot_blocker_input_classification.rb +98 -0
- data/lib/contrast/agent/protect/rule/bot_blocker.rb +81 -0
- data/lib/contrast/agent/protect/rule/cmd_injection.rb +18 -1
- data/lib/contrast/agent/protect/rule/cmdi/cmdi_backdoors.rb +8 -5
- data/lib/contrast/agent/protect/rule/cmdi/cmdi_base_rule.rb +22 -22
- data/lib/contrast/agent/protect/rule/cmdi/cmdi_chained_command.rb +69 -0
- data/lib/contrast/agent/protect/rule/cmdi/cmdi_dangerous_path.rb +68 -0
- data/lib/contrast/agent/protect/rule/cmdi/cmdi_input_classification.rb +2 -58
- data/lib/contrast/agent/protect/rule/default_scanner.rb +1 -1
- data/lib/contrast/agent/protect/rule/deserialization.rb +3 -14
- data/lib/contrast/agent/protect/rule/http_method_tampering/http_method_tampering_input_classification.rb +2 -2
- data/lib/contrast/agent/protect/rule/http_method_tampering.rb +0 -11
- data/lib/contrast/agent/protect/rule/no_sqli/no_sqli_input_classification.rb +29 -34
- data/lib/contrast/agent/protect/rule/no_sqli.rb +25 -18
- data/lib/contrast/agent/protect/rule/path_traversal/path_traversal_input_classification.rb +61 -0
- data/lib/contrast/agent/protect/rule/path_traversal/path_traversal_semantic_security_bypass.rb +114 -0
- data/lib/contrast/agent/protect/rule/path_traversal.rb +38 -12
- data/lib/contrast/agent/protect/rule/sql_sample_builder.rb +33 -15
- data/lib/contrast/agent/protect/rule/sqli/sqli_base_rule.rb +0 -14
- data/lib/contrast/agent/protect/rule/sqli/sqli_input_classification.rb +2 -62
- data/lib/contrast/agent/protect/rule/sqli.rb +70 -0
- data/lib/contrast/agent/protect/rule/unsafe_file_upload/unsafe_file_upload_input_classification.rb +39 -63
- data/lib/contrast/agent/protect/rule/unsafe_file_upload.rb +6 -33
- data/lib/contrast/agent/protect/rule/xss/reflected_xss_input_classification.rb +58 -0
- data/lib/contrast/agent/protect/rule/xss.rb +14 -20
- data/lib/contrast/agent/protect/rule/xxe.rb +4 -24
- data/lib/contrast/agent/reporting/attack_result/rasp_rule_sample.rb +18 -39
- data/lib/contrast/agent/reporting/attack_result/response_type.rb +9 -9
- data/lib/contrast/agent/reporting/details/ip_denylist_details.rb +10 -2
- data/lib/contrast/agent/reporting/details/virtual_patch_details.rb +8 -2
- data/lib/contrast/agent/reporting/input_analysis/details/bot_blocker_details.rb +27 -0
- data/lib/contrast/agent/reporting/input_analysis/details/protect_rule_details.rb +15 -0
- data/lib/contrast/agent/reporting/input_analysis/input_analysis.rb +1 -2
- data/lib/contrast/agent/reporting/input_analysis/input_analysis_result.rb +16 -2
- data/lib/contrast/agent/reporting/masker/masker.rb +2 -0
- data/lib/contrast/agent/reporting/reporter.rb +1 -14
- data/lib/contrast/agent/reporting/reporting_events/application_activity.rb +15 -12
- data/lib/contrast/agent/reporting/reporting_events/application_defend_attack_activity.rb +3 -3
- data/lib/contrast/agent/reporting/reporting_events/application_defend_attack_sample.rb +1 -2
- data/lib/contrast/agent/reporting/reporting_events/application_update.rb +0 -2
- data/lib/contrast/agent/reporting/reporting_events/architecture_component.rb +0 -1
- data/lib/contrast/agent/reporting/reporting_events/finding.rb +4 -4
- data/lib/contrast/agent/reporting/reporting_events/finding_request.rb +0 -5
- data/lib/contrast/agent/reporting/reporting_events/library_discovery.rb +0 -1
- data/lib/contrast/agent/reporting/reporting_events/poll.rb +1 -11
- data/lib/contrast/agent/reporting/reporting_events/route_discovery.rb +0 -1
- data/lib/contrast/agent/reporting/reporting_events/route_discovery_observation.rb +0 -1
- data/lib/contrast/agent/reporting/reporting_utilities/audit.rb +2 -2
- data/lib/contrast/agent/reporting/reporting_utilities/response.rb +1 -1
- data/lib/contrast/agent/reporting/reporting_utilities/response_handler.rb +0 -3
- data/lib/contrast/agent/reporting/reporting_utilities/response_handler_utils.rb +1 -0
- data/lib/contrast/agent/reporting/settings/code_exclusion.rb +6 -1
- data/lib/contrast/agent/reporting/settings/exclusion_base.rb +18 -0
- data/lib/contrast/agent/reporting/settings/exclusions.rb +2 -1
- data/lib/contrast/agent/reporting/settings/input_exclusion.rb +9 -3
- data/lib/contrast/agent/reporting/settings/protect.rb +15 -15
- data/lib/contrast/agent/request.rb +2 -14
- data/lib/contrast/agent/request_context.rb +6 -9
- data/lib/contrast/agent/request_context_extend.rb +9 -148
- data/lib/contrast/agent/thread_watcher.rb +3 -18
- data/lib/contrast/agent/version.rb +1 -1
- data/lib/contrast/agent.rb +0 -11
- data/lib/contrast/agent_lib/api/command_injection.rb +46 -0
- data/lib/contrast/agent_lib/api/init.rb +101 -0
- data/lib/contrast/agent_lib/api/input_tracing.rb +267 -0
- data/lib/contrast/agent_lib/api/method_tempering.rb +29 -0
- data/lib/contrast/agent_lib/api/panic.rb +87 -0
- data/lib/contrast/agent_lib/api/path_semantic_file_security_bypass.rb +40 -0
- data/lib/contrast/agent_lib/interface.rb +260 -0
- data/lib/contrast/agent_lib/interface_base.rb +118 -0
- data/lib/contrast/agent_lib/return_types/eval_result.rb +44 -0
- data/lib/contrast/agent_lib/test.rb +29 -0
- data/lib/contrast/api/communication/connection_status.rb +5 -5
- data/lib/contrast/components/agent.rb +0 -14
- data/lib/contrast/components/app_context.rb +0 -2
- data/lib/contrast/components/app_context_extend.rb +0 -25
- data/lib/contrast/components/config.rb +1 -18
- data/lib/contrast/components/protect.rb +4 -1
- data/lib/contrast/components/ruby_component.rb +1 -1
- data/lib/contrast/components/settings.rb +37 -89
- data/lib/contrast/config/protect_rule_configuration.rb +7 -7
- data/lib/contrast/config/protect_rules_configuration.rb +20 -58
- data/lib/contrast/configuration.rb +1 -10
- data/lib/contrast/extension/assess/array.rb +9 -0
- data/lib/contrast/extension/delegator.rb +2 -0
- data/lib/contrast/framework/manager.rb +3 -1
- data/lib/contrast/framework/rails/railtie.rb +0 -1
- data/lib/contrast/framework/rails/support.rb +0 -1
- data/lib/contrast/tasks/config.rb +1 -8
- data/lib/contrast/utils/duck_utils.rb +1 -0
- data/lib/contrast/utils/input_classification_base.rb +156 -0
- data/lib/contrast/utils/os.rb +0 -20
- data/lib/contrast/utils/response_utils.rb +0 -16
- data/lib/contrast/utils/stack_trace_utils.rb +3 -15
- data/lib/contrast/utils/string_utils.rb +10 -7
- data/lib/contrast.rb +2 -3
- data/resources/protect/policy.json +1 -2
- data/ruby-agent.gemspec +2 -5
- metadata +42 -112
- data/exe/contrast_service +0 -23
- data/lib/contrast/agent/protect/rule/cmdi/cmdi_worth_watching.rb +0 -64
- data/lib/contrast/agent/protect/rule/sqli/sqli_worth_watching.rb +0 -118
- data/lib/contrast/agent/protect/rule/unsafe_file_upload/unsafe_file_upload_matcher.rb +0 -45
- data/lib/contrast/agent/reaction_processor.rb +0 -47
- data/lib/contrast/agent/service_heartbeat.rb +0 -35
- data/lib/contrast/api/communication/messaging_queue.rb +0 -128
- data/lib/contrast/api/communication/response_processor.rb +0 -90
- data/lib/contrast/api/communication/service_lifecycle.rb +0 -77
- data/lib/contrast/api/communication/socket.rb +0 -44
- data/lib/contrast/api/communication/socket_client.rb +0 -130
- data/lib/contrast/api/communication/speedracer.rb +0 -138
- data/lib/contrast/api/communication/tcp_socket.rb +0 -32
- data/lib/contrast/api/communication/unix_socket.rb +0 -28
- data/lib/contrast/api/communication.rb +0 -20
- data/lib/contrast/api/decorators/address.rb +0 -59
- data/lib/contrast/api/decorators/agent_startup.rb +0 -56
- data/lib/contrast/api/decorators/application_settings.rb +0 -43
- data/lib/contrast/api/decorators/application_startup.rb +0 -56
- data/lib/contrast/api/decorators/bot_blocker.rb +0 -37
- data/lib/contrast/api/decorators/http_request.rb +0 -137
- data/lib/contrast/api/decorators/input_analysis.rb +0 -18
- data/lib/contrast/api/decorators/instrumentation_mode.rb +0 -35
- data/lib/contrast/api/decorators/ip_denylist.rb +0 -37
- data/lib/contrast/api/decorators/message.rb +0 -67
- data/lib/contrast/api/decorators/rasp_rule_sample.rb +0 -52
- data/lib/contrast/api/decorators/response_type.rb +0 -17
- data/lib/contrast/api/decorators/server_features.rb +0 -25
- data/lib/contrast/api/decorators/user_input.rb +0 -51
- data/lib/contrast/api/decorators/virtual_patch.rb +0 -34
- data/lib/contrast/api/decorators.rb +0 -22
- data/lib/contrast/api/dtm.pb.rb +0 -363
- data/lib/contrast/api/settings.pb.rb +0 -500
- data/lib/contrast/api.rb +0 -16
- data/lib/contrast/components/contrast_service.rb +0 -88
- data/lib/contrast/components/service.rb +0 -55
- data/lib/contrast/tasks/service.rb +0 -84
- data/lib/contrast/utils/input_classification.rb +0 -73
- data/lib/protobuf/code_generator.rb +0 -129
- data/lib/protobuf/decoder.rb +0 -28
- data/lib/protobuf/deprecation.rb +0 -117
- data/lib/protobuf/descriptors/google/protobuf/compiler/plugin.pb.rb +0 -79
- data/lib/protobuf/descriptors/google/protobuf/descriptor.pb.rb +0 -360
- data/lib/protobuf/descriptors.rb +0 -3
- data/lib/protobuf/encoder.rb +0 -11
- data/lib/protobuf/enum.rb +0 -365
- data/lib/protobuf/exceptions.rb +0 -9
- data/lib/protobuf/field/base_field.rb +0 -380
- data/lib/protobuf/field/base_field_object_definitions.rb +0 -504
- data/lib/protobuf/field/bool_field.rb +0 -64
- data/lib/protobuf/field/bytes_field.rb +0 -67
- data/lib/protobuf/field/double_field.rb +0 -25
- data/lib/protobuf/field/enum_field.rb +0 -56
- data/lib/protobuf/field/field_array.rb +0 -102
- data/lib/protobuf/field/field_hash.rb +0 -122
- data/lib/protobuf/field/fixed32_field.rb +0 -25
- data/lib/protobuf/field/fixed64_field.rb +0 -28
- data/lib/protobuf/field/float_field.rb +0 -43
- data/lib/protobuf/field/int32_field.rb +0 -21
- data/lib/protobuf/field/int64_field.rb +0 -34
- data/lib/protobuf/field/integer_field.rb +0 -23
- data/lib/protobuf/field/message_field.rb +0 -51
- data/lib/protobuf/field/sfixed32_field.rb +0 -27
- data/lib/protobuf/field/sfixed64_field.rb +0 -28
- data/lib/protobuf/field/signed_integer_field.rb +0 -29
- data/lib/protobuf/field/sint32_field.rb +0 -21
- data/lib/protobuf/field/sint64_field.rb +0 -21
- data/lib/protobuf/field/string_field.rb +0 -51
- data/lib/protobuf/field/uint32_field.rb +0 -21
- data/lib/protobuf/field/uint64_field.rb +0 -21
- data/lib/protobuf/field/varint_field.rb +0 -77
- data/lib/protobuf/field.rb +0 -74
- data/lib/protobuf/generators/base.rb +0 -85
- data/lib/protobuf/generators/enum_generator.rb +0 -39
- data/lib/protobuf/generators/extension_generator.rb +0 -27
- data/lib/protobuf/generators/field_generator.rb +0 -193
- data/lib/protobuf/generators/file_generator.rb +0 -262
- data/lib/protobuf/generators/group_generator.rb +0 -122
- data/lib/protobuf/generators/message_generator.rb +0 -104
- data/lib/protobuf/generators/option_generator.rb +0 -17
- data/lib/protobuf/generators/printable.rb +0 -160
- data/lib/protobuf/generators/service_generator.rb +0 -50
- data/lib/protobuf/lifecycle.rb +0 -33
- data/lib/protobuf/logging.rb +0 -39
- data/lib/protobuf/message/fields.rb +0 -233
- data/lib/protobuf/message/serialization.rb +0 -85
- data/lib/protobuf/message.rb +0 -241
- data/lib/protobuf/optionable.rb +0 -72
- data/lib/protobuf/tasks/compile.rake +0 -80
- data/lib/protobuf/tasks.rb +0 -1
- data/lib/protobuf/varint.rb +0 -20
- data/lib/protobuf/varint_pure.rb +0 -31
- data/lib/protobuf/version.rb +0 -3
- data/lib/protobuf/wire_type.rb +0 -10
- data/lib/protobuf.rb +0 -91
- data/proto/dynamic_discovery.proto +0 -46
- data/proto/google/protobuf/compiler/plugin.proto +0 -183
- data/proto/google/protobuf/descriptor.proto +0 -911
- data/proto/rpc.proto +0 -71
- data/service_executables/.gitkeep +0 -0
- data/service_executables/VERSION +0 -1
- data/service_executables/linux/contrast-service +0 -0
- data/service_executables/mac/contrast-service +0 -0
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: contrast-agent
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 6.
|
4
|
+
version: 6.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- galen.palmer@contrastsecurity.com
|
@@ -13,7 +13,7 @@ authors:
|
|
13
13
|
autorequire:
|
14
14
|
bindir: exe
|
15
15
|
cert_chain: []
|
16
|
-
date: 2022-08
|
16
|
+
date: 2022-09-08 00:00:00.000000000 Z
|
17
17
|
dependencies:
|
18
18
|
- !ruby/object:Gem::Dependency
|
19
19
|
name: bundler
|
@@ -644,25 +644,38 @@ dependencies:
|
|
644
644
|
- !ruby/object:Gem::Version
|
645
645
|
version: '2.0'
|
646
646
|
- !ruby/object:Gem::Dependency
|
647
|
-
name:
|
647
|
+
name: contrast-agent-lib
|
648
648
|
requirement: !ruby/object:Gem::Requirement
|
649
649
|
requirements:
|
650
|
-
- - "
|
650
|
+
- - "~>"
|
651
651
|
- !ruby/object:Gem::Version
|
652
|
-
version:
|
652
|
+
version: 0.1.0
|
653
653
|
type: :runtime
|
654
654
|
prerelease: false
|
655
655
|
version_requirements: !ruby/object:Gem::Requirement
|
656
656
|
requirements:
|
657
|
-
- - "
|
657
|
+
- - "~>"
|
658
|
+
- !ruby/object:Gem::Version
|
659
|
+
version: 0.1.0
|
660
|
+
- !ruby/object:Gem::Dependency
|
661
|
+
name: ffi
|
662
|
+
requirement: !ruby/object:Gem::Requirement
|
663
|
+
requirements:
|
664
|
+
- - "~>"
|
665
|
+
- !ruby/object:Gem::Version
|
666
|
+
version: '1.0'
|
667
|
+
type: :runtime
|
668
|
+
prerelease: false
|
669
|
+
version_requirements: !ruby/object:Gem::Requirement
|
670
|
+
requirements:
|
671
|
+
- - "~>"
|
658
672
|
- !ruby/object:Gem::Version
|
659
|
-
version: '
|
673
|
+
version: '1.0'
|
660
674
|
description: This gem instantiates a Rack middleware for rack-based web applications
|
661
675
|
in order to provide Interactive Application Security Testing and Protection.
|
662
676
|
email:
|
663
677
|
- ruby@contrastsecurity.com
|
664
|
-
executables:
|
665
|
-
- contrast_service
|
678
|
+
executables: []
|
666
679
|
extensions:
|
667
680
|
- ext/cs__common/extconf.rb
|
668
681
|
- ext/cs__assess_hash/extconf.rb
|
@@ -694,7 +707,6 @@ files:
|
|
694
707
|
- Gemfile
|
695
708
|
- LICENSE.txt
|
696
709
|
- Rakefile
|
697
|
-
- exe/contrast_service
|
698
710
|
- ext/build_funchook.rb
|
699
711
|
- ext/cs__assess_array/cs__assess_array.c
|
700
712
|
- ext/cs__assess_array/cs__assess_array.h
|
@@ -997,11 +1009,14 @@ files:
|
|
997
1009
|
- lib/contrast/agent/protect/rule.rb
|
998
1010
|
- lib/contrast/agent/protect/rule/base.rb
|
999
1011
|
- lib/contrast/agent/protect/rule/base_service.rb
|
1012
|
+
- lib/contrast/agent/protect/rule/bot_blocker.rb
|
1013
|
+
- lib/contrast/agent/protect/rule/bot_blocker/bot_blocker_input_classification.rb
|
1000
1014
|
- lib/contrast/agent/protect/rule/cmd_injection.rb
|
1001
1015
|
- lib/contrast/agent/protect/rule/cmdi/cmdi_backdoors.rb
|
1002
1016
|
- lib/contrast/agent/protect/rule/cmdi/cmdi_base_rule.rb
|
1017
|
+
- lib/contrast/agent/protect/rule/cmdi/cmdi_chained_command.rb
|
1018
|
+
- lib/contrast/agent/protect/rule/cmdi/cmdi_dangerous_path.rb
|
1003
1019
|
- lib/contrast/agent/protect/rule/cmdi/cmdi_input_classification.rb
|
1004
|
-
- lib/contrast/agent/protect/rule/cmdi/cmdi_worth_watching.rb
|
1005
1020
|
- lib/contrast/agent/protect/rule/default_scanner.rb
|
1006
1021
|
- lib/contrast/agent/protect/rule/deserialization.rb
|
1007
1022
|
- lib/contrast/agent/protect/rule/http_method_tampering.rb
|
@@ -1010,6 +1025,8 @@ files:
|
|
1010
1025
|
- lib/contrast/agent/protect/rule/no_sqli/mongo_no_sql_scanner.rb
|
1011
1026
|
- lib/contrast/agent/protect/rule/no_sqli/no_sqli_input_classification.rb
|
1012
1027
|
- lib/contrast/agent/protect/rule/path_traversal.rb
|
1028
|
+
- lib/contrast/agent/protect/rule/path_traversal/path_traversal_input_classification.rb
|
1029
|
+
- lib/contrast/agent/protect/rule/path_traversal/path_traversal_semantic_security_bypass.rb
|
1013
1030
|
- lib/contrast/agent/protect/rule/sql_sample_builder.rb
|
1014
1031
|
- lib/contrast/agent/protect/rule/sqli.rb
|
1015
1032
|
- lib/contrast/agent/protect/rule/sqli/default_sql_scanner.rb
|
@@ -1018,15 +1035,13 @@ files:
|
|
1018
1035
|
- lib/contrast/agent/protect/rule/sqli/sqli_base_rule.rb
|
1019
1036
|
- lib/contrast/agent/protect/rule/sqli/sqli_input_classification.rb
|
1020
1037
|
- lib/contrast/agent/protect/rule/sqli/sqli_semantic/sqli_dangerous_functions.rb
|
1021
|
-
- lib/contrast/agent/protect/rule/sqli/sqli_worth_watching.rb
|
1022
1038
|
- lib/contrast/agent/protect/rule/sqli/sqlite_sql_scanner.rb
|
1023
1039
|
- lib/contrast/agent/protect/rule/unsafe_file_upload.rb
|
1024
1040
|
- lib/contrast/agent/protect/rule/unsafe_file_upload/unsafe_file_upload_input_classification.rb
|
1025
|
-
- lib/contrast/agent/protect/rule/unsafe_file_upload/unsafe_file_upload_matcher.rb
|
1026
1041
|
- lib/contrast/agent/protect/rule/xss.rb
|
1042
|
+
- lib/contrast/agent/protect/rule/xss/reflected_xss_input_classification.rb
|
1027
1043
|
- lib/contrast/agent/protect/rule/xxe.rb
|
1028
1044
|
- lib/contrast/agent/protect/rule/xxe/entity_wrapper.rb
|
1029
|
-
- lib/contrast/agent/reaction_processor.rb
|
1030
1045
|
- lib/contrast/agent/reporting/attack_result/attack_result.rb
|
1031
1046
|
- lib/contrast/agent/reporting/attack_result/rasp_rule_sample.rb
|
1032
1047
|
- lib/contrast/agent/reporting/attack_result/response_type.rb
|
@@ -1049,6 +1064,8 @@ files:
|
|
1049
1064
|
- lib/contrast/agent/reporting/details/xxe_details.rb
|
1050
1065
|
- lib/contrast/agent/reporting/details/xxe_match.rb
|
1051
1066
|
- lib/contrast/agent/reporting/details/xxe_wrapper.rb
|
1067
|
+
- lib/contrast/agent/reporting/input_analysis/details/bot_blocker_details.rb
|
1068
|
+
- lib/contrast/agent/reporting/input_analysis/details/protect_rule_details.rb
|
1052
1069
|
- lib/contrast/agent/reporting/input_analysis/input_analysis.rb
|
1053
1070
|
- lib/contrast/agent/reporting/input_analysis/input_analysis_result.rb
|
1054
1071
|
- lib/contrast/agent/reporting/input_analysis/input_type.rb
|
@@ -1141,7 +1158,6 @@ files:
|
|
1141
1158
|
- lib/contrast/agent/response.rb
|
1142
1159
|
- lib/contrast/agent/rule_set.rb
|
1143
1160
|
- lib/contrast/agent/scope.rb
|
1144
|
-
- lib/contrast/agent/service_heartbeat.rb
|
1145
1161
|
- lib/contrast/agent/static_analysis.rb
|
1146
1162
|
- lib/contrast/agent/telemetry/base.rb
|
1147
1163
|
- lib/contrast/agent/telemetry/events/event.rb
|
@@ -1159,36 +1175,18 @@ files:
|
|
1159
1175
|
- lib/contrast/agent/tracepoint_hook.rb
|
1160
1176
|
- lib/contrast/agent/version.rb
|
1161
1177
|
- lib/contrast/agent/worker_thread.rb
|
1162
|
-
- lib/contrast/api.rb
|
1178
|
+
- lib/contrast/agent_lib/api/command_injection.rb
|
1179
|
+
- lib/contrast/agent_lib/api/init.rb
|
1180
|
+
- lib/contrast/agent_lib/api/input_tracing.rb
|
1181
|
+
- lib/contrast/agent_lib/api/method_tempering.rb
|
1182
|
+
- lib/contrast/agent_lib/api/panic.rb
|
1183
|
+
- lib/contrast/agent_lib/api/path_semantic_file_security_bypass.rb
|
1184
|
+
- lib/contrast/agent_lib/interface.rb
|
1185
|
+
- lib/contrast/agent_lib/interface_base.rb
|
1186
|
+
- lib/contrast/agent_lib/return_types/eval_result.rb
|
1187
|
+
- lib/contrast/agent_lib/test.rb
|
1163
1188
|
- lib/contrast/api/.gitkeep
|
1164
|
-
- lib/contrast/api/communication.rb
|
1165
1189
|
- lib/contrast/api/communication/connection_status.rb
|
1166
|
-
- lib/contrast/api/communication/messaging_queue.rb
|
1167
|
-
- lib/contrast/api/communication/response_processor.rb
|
1168
|
-
- lib/contrast/api/communication/service_lifecycle.rb
|
1169
|
-
- lib/contrast/api/communication/socket.rb
|
1170
|
-
- lib/contrast/api/communication/socket_client.rb
|
1171
|
-
- lib/contrast/api/communication/speedracer.rb
|
1172
|
-
- lib/contrast/api/communication/tcp_socket.rb
|
1173
|
-
- lib/contrast/api/communication/unix_socket.rb
|
1174
|
-
- lib/contrast/api/decorators.rb
|
1175
|
-
- lib/contrast/api/decorators/address.rb
|
1176
|
-
- lib/contrast/api/decorators/agent_startup.rb
|
1177
|
-
- lib/contrast/api/decorators/application_settings.rb
|
1178
|
-
- lib/contrast/api/decorators/application_startup.rb
|
1179
|
-
- lib/contrast/api/decorators/bot_blocker.rb
|
1180
|
-
- lib/contrast/api/decorators/http_request.rb
|
1181
|
-
- lib/contrast/api/decorators/input_analysis.rb
|
1182
|
-
- lib/contrast/api/decorators/instrumentation_mode.rb
|
1183
|
-
- lib/contrast/api/decorators/ip_denylist.rb
|
1184
|
-
- lib/contrast/api/decorators/message.rb
|
1185
|
-
- lib/contrast/api/decorators/rasp_rule_sample.rb
|
1186
|
-
- lib/contrast/api/decorators/response_type.rb
|
1187
|
-
- lib/contrast/api/decorators/server_features.rb
|
1188
|
-
- lib/contrast/api/decorators/user_input.rb
|
1189
|
-
- lib/contrast/api/decorators/virtual_patch.rb
|
1190
|
-
- lib/contrast/api/dtm.pb.rb
|
1191
|
-
- lib/contrast/api/settings.pb.rb
|
1192
1190
|
- lib/contrast/components/agent.rb
|
1193
1191
|
- lib/contrast/components/api.rb
|
1194
1192
|
- lib/contrast/components/app_context.rb
|
@@ -1197,7 +1195,6 @@ files:
|
|
1197
1195
|
- lib/contrast/components/assess_rules.rb
|
1198
1196
|
- lib/contrast/components/base.rb
|
1199
1197
|
- lib/contrast/components/config.rb
|
1200
|
-
- lib/contrast/components/contrast_service.rb
|
1201
1198
|
- lib/contrast/components/heap_dump.rb
|
1202
1199
|
- lib/contrast/components/inventory.rb
|
1203
1200
|
- lib/contrast/components/logger.rb
|
@@ -1206,7 +1203,6 @@ files:
|
|
1206
1203
|
- lib/contrast/components/sampling.rb
|
1207
1204
|
- lib/contrast/components/scope.rb
|
1208
1205
|
- lib/contrast/components/security_logger.rb
|
1209
|
-
- lib/contrast/components/service.rb
|
1210
1206
|
- lib/contrast/components/settings.rb
|
1211
1207
|
- lib/contrast/config.rb
|
1212
1208
|
- lib/contrast/config/api_proxy_configuration.rb
|
@@ -1262,7 +1258,6 @@ files:
|
|
1262
1258
|
- lib/contrast/logger/time.rb
|
1263
1259
|
- lib/contrast/security_exception.rb
|
1264
1260
|
- lib/contrast/tasks/config.rb
|
1265
|
-
- lib/contrast/tasks/service.rb
|
1266
1261
|
- lib/contrast/utils/assess/event_limit_utils.rb
|
1267
1262
|
- lib/contrast/utils/assess/object_store.rb
|
1268
1263
|
- lib/contrast/utils/assess/propagation_method_utils.rb
|
@@ -1280,7 +1275,7 @@ files:
|
|
1280
1275
|
- lib/contrast/utils/hash_digest_extend.rb
|
1281
1276
|
- lib/contrast/utils/head_dump_utils_extend.rb
|
1282
1277
|
- lib/contrast/utils/heap_dump_util.rb
|
1283
|
-
- lib/contrast/utils/
|
1278
|
+
- lib/contrast/utils/input_classification_base.rb
|
1284
1279
|
- lib/contrast/utils/invalid_configuration_util.rb
|
1285
1280
|
- lib/contrast/utils/io_util.rb
|
1286
1281
|
- lib/contrast/utils/job_servers_running.rb
|
@@ -1306,77 +1301,12 @@ files:
|
|
1306
1301
|
- lib/contrast/utils/telemetry_identifier.rb
|
1307
1302
|
- lib/contrast/utils/thread_tracker.rb
|
1308
1303
|
- lib/contrast/utils/timer.rb
|
1309
|
-
- lib/protobuf.rb
|
1310
|
-
- lib/protobuf/code_generator.rb
|
1311
|
-
- lib/protobuf/decoder.rb
|
1312
|
-
- lib/protobuf/deprecation.rb
|
1313
|
-
- lib/protobuf/descriptors.rb
|
1314
|
-
- lib/protobuf/descriptors/google/protobuf/compiler/plugin.pb.rb
|
1315
|
-
- lib/protobuf/descriptors/google/protobuf/descriptor.pb.rb
|
1316
|
-
- lib/protobuf/encoder.rb
|
1317
|
-
- lib/protobuf/enum.rb
|
1318
|
-
- lib/protobuf/exceptions.rb
|
1319
|
-
- lib/protobuf/field.rb
|
1320
|
-
- lib/protobuf/field/base_field.rb
|
1321
|
-
- lib/protobuf/field/base_field_object_definitions.rb
|
1322
|
-
- lib/protobuf/field/bool_field.rb
|
1323
|
-
- lib/protobuf/field/bytes_field.rb
|
1324
|
-
- lib/protobuf/field/double_field.rb
|
1325
|
-
- lib/protobuf/field/enum_field.rb
|
1326
|
-
- lib/protobuf/field/field_array.rb
|
1327
|
-
- lib/protobuf/field/field_hash.rb
|
1328
|
-
- lib/protobuf/field/fixed32_field.rb
|
1329
|
-
- lib/protobuf/field/fixed64_field.rb
|
1330
|
-
- lib/protobuf/field/float_field.rb
|
1331
|
-
- lib/protobuf/field/int32_field.rb
|
1332
|
-
- lib/protobuf/field/int64_field.rb
|
1333
|
-
- lib/protobuf/field/integer_field.rb
|
1334
|
-
- lib/protobuf/field/message_field.rb
|
1335
|
-
- lib/protobuf/field/sfixed32_field.rb
|
1336
|
-
- lib/protobuf/field/sfixed64_field.rb
|
1337
|
-
- lib/protobuf/field/signed_integer_field.rb
|
1338
|
-
- lib/protobuf/field/sint32_field.rb
|
1339
|
-
- lib/protobuf/field/sint64_field.rb
|
1340
|
-
- lib/protobuf/field/string_field.rb
|
1341
|
-
- lib/protobuf/field/uint32_field.rb
|
1342
|
-
- lib/protobuf/field/uint64_field.rb
|
1343
|
-
- lib/protobuf/field/varint_field.rb
|
1344
|
-
- lib/protobuf/generators/base.rb
|
1345
|
-
- lib/protobuf/generators/enum_generator.rb
|
1346
|
-
- lib/protobuf/generators/extension_generator.rb
|
1347
|
-
- lib/protobuf/generators/field_generator.rb
|
1348
|
-
- lib/protobuf/generators/file_generator.rb
|
1349
|
-
- lib/protobuf/generators/group_generator.rb
|
1350
|
-
- lib/protobuf/generators/message_generator.rb
|
1351
|
-
- lib/protobuf/generators/option_generator.rb
|
1352
|
-
- lib/protobuf/generators/printable.rb
|
1353
|
-
- lib/protobuf/generators/service_generator.rb
|
1354
|
-
- lib/protobuf/lifecycle.rb
|
1355
|
-
- lib/protobuf/logging.rb
|
1356
|
-
- lib/protobuf/message.rb
|
1357
|
-
- lib/protobuf/message/fields.rb
|
1358
|
-
- lib/protobuf/message/serialization.rb
|
1359
|
-
- lib/protobuf/optionable.rb
|
1360
|
-
- lib/protobuf/tasks.rb
|
1361
|
-
- lib/protobuf/tasks/compile.rake
|
1362
|
-
- lib/protobuf/varint.rb
|
1363
|
-
- lib/protobuf/varint_pure.rb
|
1364
|
-
- lib/protobuf/version.rb
|
1365
|
-
- lib/protobuf/wire_type.rb
|
1366
|
-
- proto/dynamic_discovery.proto
|
1367
|
-
- proto/google/protobuf/compiler/plugin.proto
|
1368
|
-
- proto/google/protobuf/descriptor.proto
|
1369
|
-
- proto/rpc.proto
|
1370
1304
|
- resources/assess/policy.json
|
1371
1305
|
- resources/deadzone/policy.json
|
1372
1306
|
- resources/inventory/policy.json
|
1373
1307
|
- resources/protect/policy.json
|
1374
1308
|
- resources/test_marker.txt
|
1375
1309
|
- ruby-agent.gemspec
|
1376
|
-
- service_executables/.gitkeep
|
1377
|
-
- service_executables/VERSION
|
1378
|
-
- service_executables/linux/contrast-service
|
1379
|
-
- service_executables/mac/contrast-service
|
1380
1310
|
- shared_libraries/.gitkeep
|
1381
1311
|
- sonar-project.properties
|
1382
1312
|
homepage: https://www.contrastsecurity.com
|
data/exe/contrast_service
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# Copyright (c) 2022 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
|
3
|
-
# frozen_string_literal: true
|
4
|
-
|
5
|
-
def mac?
|
6
|
-
RUBY_PLATFORM.include?('darwin')
|
7
|
-
end
|
8
|
-
|
9
|
-
def path
|
10
|
-
base_path = "#{ File.dirname(__FILE__) }/.."
|
11
|
-
if mac?
|
12
|
-
"#{ base_path }/service_executables/mac/contrast-service"
|
13
|
-
else
|
14
|
-
"#{ base_path }/service_executables/linux/contrast-service"
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
executable_path = path
|
19
|
-
if File.exist?(executable_path)
|
20
|
-
Kernel.exec(executable_path)
|
21
|
-
else
|
22
|
-
puts "Service executable not found at: #{ executable_path }"
|
23
|
-
end
|
@@ -1,64 +0,0 @@
|
|
1
|
-
# Copyright (c) 2022 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
require 'contrast/utils/object_share'
|
5
|
-
|
6
|
-
module Contrast
|
7
|
-
module Agent
|
8
|
-
module Protect
|
9
|
-
module Rule
|
10
|
-
# This module implements the cmdi-worth-watching-v2 check to determine whether input
|
11
|
-
# is IGNORED or WORTH_WATCHING. If WORTH_WATCHING => analyze at sink level.
|
12
|
-
# https://protect-spec.prod.dotnet.contsec.com/rules/cmd-injection.html#input-tracing
|
13
|
-
module CmdiWorthWatching
|
14
|
-
POSSIBLE_CHAINING_ELEMENTS = %w[& ; | $ < > `].cs__freeze
|
15
|
-
UNIX_COMMANDS = %w[
|
16
|
-
uname echo cat ping nestat nc whoami wget curl dir ls ps rm chmod cp kill
|
17
|
-
grep sleep mkdir pwd shutdown system touch timeout fetch bash sh
|
18
|
-
].cs__freeze
|
19
|
-
UNIX_PATHS = %w[tmp opt etc home mnt proc lib bin sbin sys usr var root run].cs__freeze
|
20
|
-
WINDOWS_COMMANDS = %w[
|
21
|
-
sc net reg cmd query cmd.exe powershell powershell.exe hostname ifconfig ipconfig netsh
|
22
|
-
netstat systeminfo sysinfo whoami wscript cscript wmic PowerShell_ISE pskill psexec qprocess
|
23
|
-
regedit regini rename winrm wpeutil ntdsutil taskkill certutil mapisend shellrunas
|
24
|
-
].cs__freeze
|
25
|
-
# This method will determine if a user input is Worth watching and return true if it is.
|
26
|
-
# This is done by running checks, and if the inputs is worth to watch it would be
|
27
|
-
# saved for the later sink cmdi input analysis.
|
28
|
-
#
|
29
|
-
# @param input [String] the user input to be inspected
|
30
|
-
# @return true | false
|
31
|
-
def cmdi_worth_watching? input
|
32
|
-
return false if input.nil? || input.empty? || input.length < 3
|
33
|
-
|
34
|
-
exploitable?(input) && worth_watching?(input)
|
35
|
-
end
|
36
|
-
|
37
|
-
private
|
38
|
-
|
39
|
-
# This method will check if the input is exploitable
|
40
|
-
#
|
41
|
-
# @param input [String] the user input to be inspected
|
42
|
-
def exploitable? input
|
43
|
-
contains_substring?(input, POSSIBLE_CHAINING_ELEMENTS)
|
44
|
-
end
|
45
|
-
|
46
|
-
def worth_watching? input
|
47
|
-
return true if contains_substring?(input, UNIX_COMMANDS)
|
48
|
-
return true if contains_substring?(input, UNIX_PATHS)
|
49
|
-
return true if contains_substring?(input, WINDOWS_COMMANDS)
|
50
|
-
|
51
|
-
false
|
52
|
-
end
|
53
|
-
|
54
|
-
def contains_substring? input, values
|
55
|
-
return true if values.any? { |val| input.include?(val) }
|
56
|
-
return true if values.include?(Contrast::Utils::ObjectShare::SPACE)
|
57
|
-
|
58
|
-
false
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
@@ -1,118 +0,0 @@
|
|
1
|
-
# Copyright (c) 2022 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
require 'contrast/utils/object_share'
|
5
|
-
|
6
|
-
module Contrast
|
7
|
-
module Agent
|
8
|
-
module Protect
|
9
|
-
module Rule
|
10
|
-
# This module implements the sqli-worth-watching-v2 check to determine whether input
|
11
|
-
# is IGNORED or WORTH_WATCHING. If WORTH_WATCHING => analyze at sink level.
|
12
|
-
# https://protect-spec.prod.dotnet.contsec.com/rules/sql-injection.html#input-tracing
|
13
|
-
module SqliWorthWatching
|
14
|
-
COLOR_CODE = /^#[0-9A-Fa-f]{6}$/.cs__freeze
|
15
|
-
ALPHA_NUMERIC_AND_SPACES = /^+[a-zA-Z\d\s]+$/.cs__freeze
|
16
|
-
OR_CLAUSE = /[oO][rR]/.cs__freeze
|
17
|
-
EXPLOITABLE_SUBSTRING = %w[# -- // /*].cs__freeze
|
18
|
-
SUSPICIOUS_CHARS = %w[` " \' ; - % , ( ) | { } =].cs__freeze
|
19
|
-
SQL_COMMENTS = %w[# /* */ // -- @@].cs__freeze
|
20
|
-
BLOCK_START = '/*'.cs__freeze
|
21
|
-
BLOCK_END = '*/'.cs__freeze
|
22
|
-
SQL_KEYWORDS = %w[
|
23
|
-
alter begin between create case column_name
|
24
|
-
current_user delete drop exec execute from
|
25
|
-
group insert limit like merge order outfile
|
26
|
-
select session_user syslogins update union
|
27
|
-
UTL_INADDR UTL_HTTP
|
28
|
-
].cs__freeze
|
29
|
-
|
30
|
-
# This method will determine if a user input is Worth watching and return true if it is.
|
31
|
-
# This is done by running checks, and if the inputs is worth to watch it would be
|
32
|
-
# saved for the later sink sqli input analysis.
|
33
|
-
#
|
34
|
-
# @param input [String] the user input to be inspected
|
35
|
-
# @return true | false
|
36
|
-
def sqli_worth_watching? input
|
37
|
-
return false if input.nil? || input.empty?
|
38
|
-
|
39
|
-
exploitable?(input) && (
|
40
|
-
input.match?(OR_CLAUSE) || sql_comments?(input) || suspicious_chars?(input) || language_keywords?(input)
|
41
|
-
)
|
42
|
-
end
|
43
|
-
|
44
|
-
private
|
45
|
-
|
46
|
-
# Check if input is exploitable, with min length set to 3 chars
|
47
|
-
#
|
48
|
-
# @param input [String] the user input to be inspected
|
49
|
-
# @return true | false
|
50
|
-
def exploitable? input
|
51
|
-
return false if input.length < 3 && input.match?(ALPHA_NUMERIC_AND_SPACES)
|
52
|
-
return false if input.length == 3 && !contains_substring?(input, EXPLOITABLE_SUBSTRING)
|
53
|
-
return false if input.length == 7 && input.match?(COLOR_CODE)
|
54
|
-
|
55
|
-
true
|
56
|
-
end
|
57
|
-
|
58
|
-
# Check if input contains sqli comments:
|
59
|
-
# '# /* */ // -- @@'
|
60
|
-
#
|
61
|
-
# @param input [String] the user input to be inspected
|
62
|
-
# @return true | false
|
63
|
-
def sql_comments? input
|
64
|
-
input.length >= 3 && contains_substring?(input, SQL_COMMENTS)
|
65
|
-
end
|
66
|
-
|
67
|
-
# Check if input contains block comments starting and
|
68
|
-
# ending with '/*..*/'
|
69
|
-
#
|
70
|
-
# @param input [String] the user input to be inspected
|
71
|
-
# @return true | false
|
72
|
-
def block_comments? input
|
73
|
-
idx1 = input.index(BLOCK_START)
|
74
|
-
idx2 = input.index(BLOCK_END)
|
75
|
-
|
76
|
-
return false if idx1.nil? || idx2.nil?
|
77
|
-
|
78
|
-
(idx1 >= 0 && idx2 >= 2 && (idx1 < idx2))
|
79
|
-
end
|
80
|
-
|
81
|
-
# Runs the input against suspicious chars array.
|
82
|
-
#
|
83
|
-
# @param input [String] the user input to be inspected
|
84
|
-
# @return true | false
|
85
|
-
def suspicious_chars? input
|
86
|
-
input.length >= 7 && (number_of_substrings(input, SUSPICIOUS_CHARS) >= 2 || block_comments?(input))
|
87
|
-
end
|
88
|
-
|
89
|
-
# Runs the input against SQL language preserved words.
|
90
|
-
#
|
91
|
-
# @param input [String] the user input to be inspected
|
92
|
-
# @return true | false
|
93
|
-
def language_keywords? input
|
94
|
-
contains_substring?(input, SQL_KEYWORDS)
|
95
|
-
end
|
96
|
-
|
97
|
-
# Helper method to find a substrings in given input.
|
98
|
-
#
|
99
|
-
# @param substrings [Array] set of substrings to inspect.
|
100
|
-
# @return true | false
|
101
|
-
def contains_substring? input, substrings
|
102
|
-
substrings.any? { |sub| input.include?(sub) }
|
103
|
-
end
|
104
|
-
|
105
|
-
# Helper method to find the number of substrings.
|
106
|
-
#
|
107
|
-
# @param input [String] the user input to be inspected
|
108
|
-
# @return number [Integer] Number of substrings
|
109
|
-
def number_of_substrings input, substring
|
110
|
-
number = 0
|
111
|
-
input.each_char.reduce(0) { |_acc, elem| number += 1 if contains_substring?(elem, substring) }
|
112
|
-
number
|
113
|
-
end
|
114
|
-
end
|
115
|
-
end
|
116
|
-
end
|
117
|
-
end
|
118
|
-
end
|
@@ -1,45 +0,0 @@
|
|
1
|
-
# Copyright (c) 2022 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
module Contrast
|
5
|
-
module Agent
|
6
|
-
module Protect
|
7
|
-
module Rule
|
8
|
-
# Here will be made the match of the user input provided by the
|
9
|
-
# Agent InputAnalysis.
|
10
|
-
module UnsafeFileUploadMatcher
|
11
|
-
# EXPLOIT_CHARS = %w[.. ; � < > ~ *].cs__freeze # rubocop:disable Style/AsciiComments
|
12
|
-
# # Extensions that can be executed on the server side or can be dangerous on the client side:
|
13
|
-
# # https://owasp.org/www-community/vulnerabilities/Unrestricted_File_Upload
|
14
|
-
# EXPLOITABLE_EXTENSIONS = %w[.php .exe .rb .jsp .pht .phtml .shtml .asa .cer .asax .swf .xap].cs__freeze
|
15
|
-
#
|
16
|
-
# # Match the user input to see if the filename
|
17
|
-
# # contains malicious file extension.
|
18
|
-
# #
|
19
|
-
# # @param input [String] The filename
|
20
|
-
# # extracted from the current request
|
21
|
-
# # @return true | false
|
22
|
-
# def unsafe_match? input
|
23
|
-
# suspicious_chars?(input) || suspicious_extensions?(input)
|
24
|
-
# end
|
25
|
-
#
|
26
|
-
# private
|
27
|
-
#
|
28
|
-
# # @param input [String] The filename
|
29
|
-
# # extracted from the current request
|
30
|
-
# # @return true | false
|
31
|
-
# def suspicious_chars? input
|
32
|
-
# input.chars.any? { |c| EXPLOIT_CHARS.include? c }
|
33
|
-
# end
|
34
|
-
#
|
35
|
-
# # @param input [String] The filename
|
36
|
-
# # extracted from the current request
|
37
|
-
# # @return true | false
|
38
|
-
# def suspicious_extensions? input
|
39
|
-
# EXPLOITABLE_EXTENSIONS.include? File.extname(input).downcase
|
40
|
-
# end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
@@ -1,47 +0,0 @@
|
|
1
|
-
# Copyright (c) 2022 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
require 'contrast/agent/disable_reaction'
|
5
|
-
require 'contrast/components/logger'
|
6
|
-
|
7
|
-
module Contrast
|
8
|
-
module Agent
|
9
|
-
# Because communication between the Agent/Service and TeamServer can only be initiated by outbound connections
|
10
|
-
# from the Agent/Service, we must provide a mechanism for the TeamServer to direct the Agent to take a specific
|
11
|
-
# action. This action is referred to as a Reaction. This class is how we handle those Reaction messages.
|
12
|
-
module ReactionProcessor
|
13
|
-
extend Contrast::Components::Logger::InstanceMethods
|
14
|
-
|
15
|
-
# Process the given Reactions from the application settings based on what
|
16
|
-
# TeamServer has indicated. Each Reaction will result in a log message
|
17
|
-
# and, optionally, an action.
|
18
|
-
#
|
19
|
-
# @param application_settings [Contrast::Api::Settings::ApplicationSettings]
|
20
|
-
# those settings which the Service has relayed from TeamServer.
|
21
|
-
def self.process application_settings
|
22
|
-
return unless application_settings&.reactions&.any?
|
23
|
-
|
24
|
-
application_settings.reactions.each do |reaction|
|
25
|
-
# The enums are all uppercase, we need to downcase them before attempting to log.
|
26
|
-
level = if reaction.log_level.nil?
|
27
|
-
:error
|
28
|
-
else
|
29
|
-
reaction.log_level.name.downcase # rubocop:disable Security/Module/Name -- ruby logger builtin.
|
30
|
-
end
|
31
|
-
|
32
|
-
logger.with_level(level, reaction.message) if reaction.message
|
33
|
-
|
34
|
-
case reaction.operation
|
35
|
-
when Contrast::Api::Settings::Reaction::Operation::DISABLE
|
36
|
-
Contrast::Agent::DisableReaction.run(reaction, level)
|
37
|
-
when Contrast::Api::Settings::Reaction::Operation::NOOP
|
38
|
-
# NOOP
|
39
|
-
else
|
40
|
-
logger.warn('ReactionProcessor received a reaction with an unknown operation',
|
41
|
-
operation: reaction.operation)
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
@@ -1,35 +0,0 @@
|
|
1
|
-
# Copyright (c) 2022 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
require 'contrast/agent/worker_thread'
|
5
|
-
require 'contrast/agent/reporting/report'
|
6
|
-
|
7
|
-
module Contrast
|
8
|
-
module Agent
|
9
|
-
# The ServiceHeartbeat functions to keep the Contrast Service alive and ensure that it maintains this Agent's
|
10
|
-
# ApplicationContext.
|
11
|
-
class ServiceHeartbeat < WorkerThread
|
12
|
-
# Spec recommends 30 seconds, we're going with 15.
|
13
|
-
REFRESH_INTERVAL_SEC = 15
|
14
|
-
|
15
|
-
def start_thread!
|
16
|
-
return if ::Contrast::CONTRAST_SERVICE.unnecessary?
|
17
|
-
return if running?
|
18
|
-
|
19
|
-
@_thread = Contrast::Agent::Thread.new do
|
20
|
-
logger.info('Starting heartbeat thread.')
|
21
|
-
loop do
|
22
|
-
logger.info("Queue Size: #{ Contrast::Agent.messaging_queue&.queue&.length }")
|
23
|
-
Contrast::Agent.messaging_queue&.send_event_eventually(poll_message)
|
24
|
-
clean_properties
|
25
|
-
sleep(REFRESH_INTERVAL_SEC)
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
def poll_message
|
31
|
-
@_poll_message ||= Contrast::Api::Dtm::Poll.new
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|