contrast-agent 6.6.4 → 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 +3 -2
- data/.gitmodules +0 -3
- 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/ext/cs__scope/cs__scope.c +1 -1
- data/lib/contrast/agent/assess/contrast_event.rb +2 -24
- data/lib/contrast/agent/assess/events/source_event.rb +7 -61
- data/lib/contrast/agent/assess/finalizers/hash.rb +11 -0
- data/lib/contrast/agent/assess/policy/dynamic_source_factory.rb +0 -55
- data/lib/contrast/agent/assess/policy/policy_node.rb +3 -3
- data/lib/contrast/agent/assess/policy/policy_node_utils.rb +0 -1
- data/lib/contrast/agent/assess/policy/propagation_node.rb +4 -4
- data/lib/contrast/agent/assess/policy/source_method.rb +24 -1
- data/lib/contrast/agent/assess/policy/trigger/reflected_xss.rb +7 -5
- data/lib/contrast/agent/assess/policy/trigger/xpath.rb +6 -1
- data/lib/contrast/agent/assess/policy/trigger_method.rb +40 -121
- data/lib/contrast/agent/assess/policy/trigger_node.rb +3 -3
- 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/assess/property/evented.rb +2 -12
- data/lib/contrast/agent/assess/rule/provider/hardcoded_value_rule.rb +42 -82
- data/lib/contrast/agent/assess/rule/response/base_rule.rb +11 -27
- data/lib/contrast/agent/assess/rule/response/body_rule.rb +1 -3
- data/lib/contrast/agent/assess/rule/response/cache_control_header_rule.rb +77 -62
- data/lib/contrast/agent/assess/rule/response/csp_header_insecure_rule.rb +1 -1
- data/lib/contrast/agent/assess/rule/response/framework/rails_support.rb +6 -1
- data/lib/contrast/agent/assess/rule/response/header_rule.rb +5 -5
- data/lib/contrast/agent/assess/rule/response/hsts_header_rule.rb +1 -1
- data/lib/contrast/agent/assess/rule/response/x_xss_protection_header_rule.rb +1 -1
- data/lib/contrast/agent/assess/tracker.rb +1 -7
- data/lib/contrast/agent/at_exit_hook.rb +1 -7
- data/lib/contrast/agent/excluder.rb +224 -0
- data/lib/contrast/agent/exclusion_matcher.rb +25 -7
- data/lib/contrast/agent/inventory/database_config.rb +18 -23
- data/lib/contrast/agent/middleware.rb +4 -5
- 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_command_injection_rule.rb +4 -0
- data/lib/contrast/agent/protect/policy/applies_path_traversal_rule.rb +20 -0
- data/lib/contrast/agent/protect/policy/applies_sqli_rule.rb +1 -0
- data/lib/contrast/agent/protect/policy/rule_applicator.rb +1 -1
- data/lib/contrast/agent/protect/rule/base.rb +98 -66
- data/lib/contrast/agent/protect/rule/base_service.rb +49 -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 +30 -99
- data/lib/contrast/agent/protect/rule/cmdi/cmdi_backdoors.rb +132 -0
- data/lib/contrast/agent/protect/rule/cmdi/cmdi_base_rule.rb +169 -0
- 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 +10 -19
- 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 +46 -18
- data/lib/contrast/agent/protect/rule/sql_sample_builder.rb +49 -29
- data/lib/contrast/agent/protect/rule/sqli/sqli_base_rule.rb +37 -0
- data/lib/contrast/agent/protect/rule/sqli/sqli_input_classification.rb +2 -62
- data/lib/contrast/agent/protect/rule/sqli/sqli_semantic/sqli_dangerous_functions.rb +67 -0
- data/lib/contrast/agent/protect/rule/sqli.rb +67 -22
- 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 +15 -30
- data/lib/contrast/agent/protect/rule.rb +3 -1
- data/lib/contrast/agent/reporting/attack_result/attack_result.rb +8 -0
- data/lib/contrast/agent/reporting/attack_result/rasp_rule_sample.rb +70 -36
- data/lib/contrast/agent/reporting/attack_result/response_type.rb +9 -9
- data/lib/contrast/agent/reporting/attack_result/user_input.rb +11 -0
- data/lib/contrast/agent/reporting/details/bot_blocker_details.rb +29 -0
- data/lib/contrast/agent/reporting/details/cmd_injection_details.rb +30 -0
- data/lib/contrast/agent/reporting/details/details.rb +18 -0
- data/lib/contrast/agent/reporting/details/http_method_tempering_details.rb +27 -0
- data/lib/contrast/agent/reporting/details/ip_denylist_details.rb +35 -0
- data/lib/contrast/agent/reporting/details/no_sqli_details.rb +36 -0
- data/lib/contrast/agent/reporting/details/path_traversal_details.rb +24 -0
- data/lib/contrast/agent/reporting/details/path_traversal_semantic_analysis_details.rb +32 -0
- data/lib/contrast/agent/reporting/details/protect_rule_details.rb +17 -0
- data/lib/contrast/agent/reporting/details/sqli_dangerous_functions.rb +22 -0
- data/lib/contrast/agent/reporting/details/sqli_details.rb +36 -0
- data/lib/contrast/agent/reporting/details/untrusted_deserialization_details.rb +27 -0
- data/lib/contrast/agent/reporting/details/virtual_patch_details.rb +30 -0
- data/lib/contrast/agent/reporting/details/xss_details.rb +33 -0
- data/lib/contrast/agent/reporting/details/xss_match.rb +30 -0
- data/lib/contrast/agent/reporting/details/xxe_details.rb +36 -0
- data/lib/contrast/agent/reporting/details/xxe_match.rb +25 -0
- data/lib/contrast/agent/reporting/details/xxe_wrapper.rb +25 -0
- 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 +17 -3
- data/lib/contrast/agent/reporting/masker/masker.rb +80 -65
- data/lib/contrast/agent/reporting/masker/masker_utils.rb +1 -30
- data/lib/contrast/agent/reporting/reporter.rb +1 -15
- data/lib/contrast/agent/reporting/reporting_events/agent_startup.rb +2 -2
- data/lib/contrast/agent/reporting/reporting_events/application_activity.rb +84 -15
- data/lib/contrast/agent/reporting/reporting_events/application_defend_activity.rb +13 -25
- data/lib/contrast/agent/reporting/reporting_events/application_defend_attack_activity.rb +19 -24
- data/lib/contrast/agent/reporting/reporting_events/application_defend_attack_sample.rb +46 -126
- data/lib/contrast/agent/reporting/reporting_events/application_defend_attack_sample_activity.rb +5 -16
- data/lib/contrast/agent/reporting/reporting_events/application_defend_attacker_activity.rb +10 -18
- data/lib/contrast/agent/reporting/reporting_events/application_inventory_activity.rb +6 -14
- data/lib/contrast/agent/reporting/reporting_events/application_startup.rb +1 -1
- data/lib/contrast/agent/reporting/reporting_events/application_update.rb +0 -2
- data/lib/contrast/agent/reporting/reporting_events/architecture_component.rb +7 -22
- data/lib/contrast/agent/reporting/reporting_events/finding.rb +23 -53
- data/lib/contrast/agent/reporting/reporting_events/finding_event.rb +12 -9
- data/lib/contrast/agent/reporting/reporting_events/finding_event_signature.rb +1 -1
- data/lib/contrast/agent/reporting/reporting_events/finding_event_source.rb +23 -21
- data/lib/contrast/agent/reporting/reporting_events/finding_event_stack.rb +5 -18
- data/lib/contrast/agent/reporting/reporting_events/finding_event_taint_range.rb +1 -0
- data/lib/contrast/{api/decorators/trace_taint_range_tags.rb → agent/reporting/reporting_events/finding_event_taint_range_tags.rb} +7 -6
- data/lib/contrast/agent/reporting/reporting_events/finding_request.rb +40 -10
- data/lib/contrast/agent/reporting/reporting_events/library_discovery.rb +0 -1
- data/lib/contrast/agent/reporting/reporting_events/library_usage_observation.rb +1 -1
- data/lib/contrast/agent/reporting/reporting_events/observed_route.rb +2 -2
- data/lib/contrast/agent/reporting/reporting_events/poll.rb +1 -11
- data/lib/contrast/agent/reporting/reporting_events/preflight_message.rb +10 -14
- data/lib/contrast/agent/reporting/reporting_events/reporting_event.rb +11 -0
- data/lib/contrast/agent/reporting/reporting_events/route_coverage.rb +3 -1
- data/lib/contrast/agent/reporting/reporting_events/route_discovery.rb +12 -25
- data/lib/contrast/agent/reporting/reporting_events/route_discovery_observation.rb +8 -27
- data/lib/contrast/agent/reporting/reporting_utilities/audit.rb +3 -3
- data/lib/contrast/agent/reporting/reporting_utilities/build_preflight.rb +4 -7
- data/lib/contrast/agent/reporting/reporting_utilities/headers.rb +1 -1
- data/lib/contrast/agent/reporting/reporting_utilities/reporter_client.rb +2 -1
- data/lib/contrast/agent/reporting/reporting_utilities/reporter_client_utils.rb +3 -3
- 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 +4 -14
- data/lib/contrast/agent/request_context.rb +18 -24
- data/lib/contrast/agent/request_context_extend.rb +23 -164
- data/lib/contrast/agent/request_handler.rb +1 -11
- data/lib/contrast/agent/response.rb +0 -18
- data/lib/contrast/agent/telemetry/events/event.rb +1 -1
- data/lib/contrast/agent/telemetry/events/metric_event.rb +1 -1
- data/lib/contrast/agent/telemetry/events/startup_metrics_event.rb +3 -3
- 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 +13 -23
- data/lib/contrast/components/api.rb +10 -10
- data/lib/contrast/components/app_context.rb +9 -11
- data/lib/contrast/components/app_context_extend.rb +1 -26
- data/lib/contrast/components/assess.rb +92 -38
- data/lib/contrast/components/assess_rules.rb +36 -0
- data/lib/contrast/components/config.rb +49 -24
- data/lib/contrast/components/heap_dump.rb +1 -1
- data/lib/contrast/components/protect.rb +9 -6
- data/lib/contrast/components/ruby_component.rb +81 -0
- data/lib/contrast/components/sampling.rb +1 -1
- data/lib/contrast/components/security_logger.rb +23 -0
- data/lib/contrast/components/settings.rb +41 -85
- data/lib/contrast/config/base_configuration.rb +1 -1
- data/lib/contrast/config/protect_rule_configuration.rb +7 -7
- data/lib/contrast/config/protect_rules_configuration.rb +24 -48
- data/lib/contrast/config/server_configuration.rb +1 -1
- data/lib/contrast/config.rb +0 -6
- data/lib/contrast/configuration.rb +73 -18
- data/lib/contrast/extension/assess/array.rb +9 -0
- data/lib/contrast/extension/assess/exec_trigger.rb +3 -1
- data/lib/contrast/extension/assess/marshal.rb +3 -2
- data/lib/contrast/extension/assess/string.rb +0 -1
- data/lib/contrast/extension/delegator.rb +2 -0
- data/lib/contrast/extension/extension.rb +1 -1
- data/lib/contrast/framework/base_support.rb +0 -5
- data/lib/contrast/framework/grape/support.rb +1 -23
- data/lib/contrast/framework/manager.rb +3 -11
- data/lib/contrast/framework/rails/patch/action_controller_live_buffer.rb +1 -6
- data/lib/contrast/framework/rails/railtie.rb +0 -1
- data/lib/contrast/framework/rails/support.rb +5 -59
- data/lib/contrast/framework/sinatra/support.rb +2 -21
- data/lib/contrast/logger/cef_log.rb +21 -3
- data/lib/contrast/logger/log.rb +1 -11
- data/lib/contrast/tasks/config.rb +5 -10
- data/lib/contrast/utils/assess/event_limit_utils.rb +28 -12
- data/lib/contrast/utils/assess/trigger_method_utils.rb +10 -18
- data/lib/contrast/utils/duck_utils.rb +1 -0
- data/lib/contrast/utils/findings.rb +6 -5
- data/lib/contrast/utils/hash_digest.rb +9 -24
- data/lib/contrast/utils/hash_digest_extend.rb +6 -6
- data/lib/contrast/utils/input_classification_base.rb +156 -0
- data/lib/contrast/utils/invalid_configuration_util.rb +21 -58
- data/lib/contrast/utils/log_utils.rb +47 -17
- data/lib/contrast/utils/net_http_base.rb +2 -2
- data/lib/contrast/utils/os.rb +0 -20
- data/lib/contrast/utils/patching/policy/patch_utils.rb +3 -2
- data/lib/contrast/utils/response_utils.rb +0 -16
- data/lib/contrast/utils/stack_trace_utils.rb +3 -40
- data/lib/contrast/utils/string_utils.rb +19 -7
- data/lib/contrast/utils/telemetry_client.rb +13 -7
- data/lib/contrast.rb +7 -13
- data/resources/protect/policy.json +1 -2
- data/ruby-agent.gemspec +2 -5
- metadata +78 -137
- 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/reporting/reporting_events/trace_event_source.rb +0 -30
- data/lib/contrast/agent/reporting/reporting_utilities/dtm_message.rb +0 -43
- data/lib/contrast/agent/service_heartbeat.rb +0 -35
- data/lib/contrast/api/communication/messaging_queue.rb +0 -129
- 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 -142
- 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/activity.rb +0 -33
- data/lib/contrast/api/decorators/address.rb +0 -59
- data/lib/contrast/api/decorators/agent_startup.rb +0 -57
- data/lib/contrast/api/decorators/application_settings.rb +0 -42
- data/lib/contrast/api/decorators/application_startup.rb +0 -56
- data/lib/contrast/api/decorators/architecture_component.rb +0 -36
- data/lib/contrast/api/decorators/bot_blocker.rb +0 -37
- data/lib/contrast/api/decorators/finding.rb +0 -29
- 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 -71
- data/lib/contrast/api/decorators/rasp_rule_sample.rb +0 -58
- data/lib/contrast/api/decorators/response_type.rb +0 -17
- data/lib/contrast/api/decorators/route_coverage.rb +0 -91
- data/lib/contrast/api/decorators/server_features.rb +0 -25
- data/lib/contrast/api/decorators/trace_event.rb +0 -120
- data/lib/contrast/api/decorators/trace_event_object.rb +0 -63
- data/lib/contrast/api/decorators/trace_event_signature.rb +0 -69
- data/lib/contrast/api/decorators/trace_taint_range.rb +0 -52
- 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 -28
- data/lib/contrast/api/dtm.pb.rb +0 -852
- 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/config/assess_configuration.rb +0 -93
- data/lib/contrast/config/assess_rules_configuration.rb +0 -32
- data/lib/contrast/config/root_configuration.rb +0 -90
- data/lib/contrast/config/ruby_configuration.rb +0 -81
- data/lib/contrast/config/service_configuration.rb +0 -49
- data/lib/contrast/tasks/service.rb +0 -84
- data/lib/contrast/utils/input_classification.rb +0 -73
- data/lib/contrast/utils/preflight_util.rb +0 -13
- 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
@@ -2,6 +2,7 @@
|
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
4
|
require 'contrast/components/logger'
|
5
|
+
require 'contrast/utils/object_share'
|
5
6
|
require 'contrast/agent/reporting/reporting_events/application_defend_attack_activity'
|
6
7
|
|
7
8
|
module Contrast
|
@@ -12,7 +13,7 @@ module Contrast
|
|
12
13
|
class ApplicationDefendAttackerActivity
|
13
14
|
# @return [Hash<String,Contrast::Agent::Reporting::ApplicationDefendAttackActivity>] map of rule-id to violated
|
14
15
|
# samples for that rule
|
15
|
-
|
16
|
+
attr_accessor :protection_rules
|
16
17
|
# @return [String, nil] the IP address of the request from which the attack originated; used to identify unique
|
17
18
|
# attackers
|
18
19
|
attr_reader :source_ip
|
@@ -20,25 +21,14 @@ module Contrast
|
|
20
21
|
# identify unique attackers
|
21
22
|
attr_reader :source_forwarded_for
|
22
23
|
|
23
|
-
class << self
|
24
|
-
# @param attack_result_dtm [Contrast::Api::Dtm::AttackResult]
|
25
|
-
# @return [Contrast::Agent::Reporting::ApplicationDefendAttackerActivity]
|
26
|
-
def convert attack_result_dtm
|
27
|
-
activity = new
|
28
|
-
activity.attach_data(attack_result_dtm)
|
29
|
-
activity
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
24
|
def initialize
|
34
25
|
@protection_rules = {}
|
35
|
-
req = Contrast::Agent::REQUEST_TRACKER.current
|
26
|
+
req = Contrast::Agent::REQUEST_TRACKER.current&.request
|
36
27
|
if req
|
37
|
-
@source_ip = req.
|
38
|
-
@source_forwarded_for = req.
|
28
|
+
@source_ip = req.ip || Contrast::Utils::ObjectShare::EMPTY_STRING
|
29
|
+
@source_forwarded_for = req.headers['X-Forwarded-For']
|
39
30
|
end
|
40
31
|
@event_type = :application_defend_attacker_activity
|
41
|
-
super
|
42
32
|
end
|
43
33
|
|
44
34
|
def to_controlled_hash
|
@@ -51,10 +41,12 @@ module Contrast
|
|
51
41
|
}
|
52
42
|
end
|
53
43
|
|
54
|
-
# @param attack_result [Contrast::
|
44
|
+
# @param attack_result [Contrast::Agent::Reporting::AttackResult]
|
55
45
|
def attach_data attack_result
|
56
|
-
@protection_rules[attack_result.rule_id] =
|
57
|
-
|
46
|
+
@protection_rules[attack_result.rule_id] = Contrast::Agent::Reporting::ApplicationDefendAttackActivity.new.
|
47
|
+
tap do |activity|
|
48
|
+
activity.attach_data(attack_result)
|
49
|
+
end
|
58
50
|
end
|
59
51
|
|
60
52
|
def process_protection_rules
|
@@ -18,16 +18,6 @@ module Contrast
|
|
18
18
|
# @ return [Array<String>, nil] - User-Agent Header value
|
19
19
|
attr_reader :browsers
|
20
20
|
|
21
|
-
class << self
|
22
|
-
# @param activity_dtm [Contrast::Api::Dtm::ApplicationActivity]
|
23
|
-
# @return [Contrast::Agent::Reporting::ApplicationInventoryActivity]
|
24
|
-
def convert activity_dtm
|
25
|
-
inventory = new
|
26
|
-
inventory.attach_data(activity_dtm)
|
27
|
-
inventory
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
21
|
def initialize
|
32
22
|
@event_type = :application_inventory_activity
|
33
23
|
@browsers = []
|
@@ -43,11 +33,13 @@ module Contrast
|
|
43
33
|
}
|
44
34
|
end
|
45
35
|
|
46
|
-
|
47
|
-
|
48
|
-
|
36
|
+
# @param architectures [Array<Contrast::Agent::Reporting::ArchitectureComponent>,
|
37
|
+
# Contrast::Agent::Reporting::ArchitectureComponent]
|
38
|
+
def attach_data architectures
|
39
|
+
Array(architectures).each do |architecture|
|
40
|
+
@components << architecture
|
49
41
|
end
|
50
|
-
request_headers =
|
42
|
+
request_headers = Contrast::Agent::REQUEST_TRACKER.current&.request&.headers
|
51
43
|
@browsers << request_headers['USER_AGENT'] if request_headers
|
52
44
|
end
|
53
45
|
|
@@ -6,9 +6,7 @@ require 'contrast/agent/reporting/reporting_events/application_reporting_event'
|
|
6
6
|
require 'contrast/agent/reporting/reporting_events/library_discovery'
|
7
7
|
require 'contrast/agent/reporting/reporting_events/reporting_event'
|
8
8
|
require 'contrast/agent/reporting/reporting_events/route_discovery'
|
9
|
-
require 'contrast/api/dtm.pb'
|
10
9
|
require 'contrast/components/logger'
|
11
|
-
require 'json'
|
12
10
|
|
13
11
|
module Contrast
|
14
12
|
module Agent
|
@@ -1,7 +1,6 @@
|
|
1
1
|
# Copyright (c) 2022 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
|
-
require 'contrast/api/dtm.pb'
|
5
4
|
require 'contrast/components/logger'
|
6
5
|
|
7
6
|
module Contrast
|
@@ -20,37 +19,23 @@ module Contrast
|
|
20
19
|
class ArchitectureComponent
|
21
20
|
include Contrast::Components::Logger::InstanceMethods
|
22
21
|
# required attributes
|
23
|
-
|
22
|
+
attr_accessor :type, :url
|
24
23
|
# optional attributes
|
25
|
-
|
24
|
+
attr_accessor :remote_host, :remote_port, :vendor
|
26
25
|
|
27
26
|
# TeamServer only treats these specific values as valid for Architecture Components. It does not know how to
|
28
27
|
# process a message with a different type.
|
28
|
+
AC_TYPE_DB = 'db'
|
29
29
|
VALID_TYPES = %w[db ldap ws].cs__freeze
|
30
30
|
|
31
31
|
class << self
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
def convert component_dtm
|
37
|
-
report = new
|
38
|
-
report.attach_data(component_dtm)
|
39
|
-
report
|
32
|
+
def build_database
|
33
|
+
msg = new
|
34
|
+
msg.type = AC_TYPE_DB
|
35
|
+
msg
|
40
36
|
end
|
41
37
|
end
|
42
38
|
|
43
|
-
# Attach the data from the protobuf models to this reporter so that it can be sent to TeamServer directly.
|
44
|
-
#
|
45
|
-
# @param component_dtm [Contrast::Api::Dtm::ArchitectureComponent]
|
46
|
-
def attach_data component_dtm
|
47
|
-
@remote_host = component_dtm.remote_host
|
48
|
-
@remote_port = component_dtm.remote_port
|
49
|
-
@type = component_dtm.type
|
50
|
-
@url = component_dtm.url
|
51
|
-
@vendor = component_dtm.vendor
|
52
|
-
end
|
53
|
-
|
54
39
|
# Convert the instance variables on the class, and other information, into the identifiers required for
|
55
40
|
# TeamServer to process the JSON form of this message.
|
56
41
|
#
|
@@ -29,14 +29,14 @@ module Contrast
|
|
29
29
|
# @return [Array<Contrast::Agent::Reporting::FindingEvent>] the events associated with this finding, if the
|
30
30
|
# finding is event (dataflow) based.
|
31
31
|
attr_reader :events
|
32
|
-
# @return [String] the evidence associated with this finding, if the finding is event based. deprecated in
|
33
|
-
# favor of properties
|
32
|
+
# # @return [String] the evidence associated with this finding, if the finding is event based. deprecated in
|
33
|
+
# # favor of properties
|
34
34
|
# attr_reader :evidence
|
35
35
|
# @return [Hash<String,String>] properties that prove the violation of the rule for this finding
|
36
36
|
attr_reader :properties
|
37
37
|
# @return [Contrast::Agent::Reporting::FindingRequest] the request associated with this finding, if the finding
|
38
38
|
# is request based
|
39
|
-
|
39
|
+
attr_accessor :request
|
40
40
|
# @return [String] the uniquely identifying hash of this finding
|
41
41
|
attr_accessor :hash_code
|
42
42
|
|
@@ -54,16 +54,6 @@ module Contrast
|
|
54
54
|
xxssprotection-header-disabled
|
55
55
|
].cs__freeze
|
56
56
|
|
57
|
-
class << self
|
58
|
-
# @param finding_dtm [Contrast::Api::Dtm::Finding]
|
59
|
-
# @return [Contrast::Agent::Reporting::Finding]
|
60
|
-
def convert finding_dtm
|
61
|
-
report = new(finding_dtm.rule_id)
|
62
|
-
report.attach_property_data(finding_dtm)
|
63
|
-
report
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
57
|
def initialize rule_id
|
68
58
|
@event_method = :PUT
|
69
59
|
@event_endpoint = "#{ Contrast::API.api_url }/api/ng/traces"
|
@@ -100,28 +90,10 @@ module Contrast
|
|
100
90
|
event_data = Contrast::Agent::Assess::Events::EventData.new(trigger_node, source, object, ret, args)
|
101
91
|
contrast_event = Contrast::Agent::Assess::ContrastEvent.new(event_data)
|
102
92
|
events << Contrast::Agent::Reporting::FindingEvent.convert(contrast_event)
|
103
|
-
attach_properties
|
104
93
|
return unless request
|
105
94
|
|
106
95
|
@request = Contrast::Agent::Reporting::FindingRequest.convert(request)
|
107
|
-
@routes <<
|
108
|
-
end
|
109
|
-
|
110
|
-
# Attach the data from a Contrast::Api::Dtm::Finding required for property based findings generated during
|
111
|
-
# response analysis.
|
112
|
-
#
|
113
|
-
# @param finding_dtm [Contrast::Api::Dtm::Finding]
|
114
|
-
def attach_property_data finding_dtm
|
115
|
-
@hash_code = finding_dtm.hash_code
|
116
|
-
@rule_id = finding_dtm.rule_id
|
117
|
-
finding_dtm.properties.each_pair do |key, value|
|
118
|
-
@properties[key] = value
|
119
|
-
end
|
120
|
-
finding_dtm.routes.each do |route|
|
121
|
-
@routes << Contrast::Agent::Reporting::RouteDiscovery.convert(route)
|
122
|
-
end
|
123
|
-
request = Contrast::Agent::REQUEST_TRACKER.current&.request
|
124
|
-
@request = Contrast::Agent::Reporting::FindingRequest.convert(request) if request
|
96
|
+
@routes << request.discovered_route if request.discovered_route
|
125
97
|
end
|
126
98
|
|
127
99
|
# Convert the instance variables on the class, and other information, into the identifiers required for
|
@@ -137,16 +109,9 @@ module Contrast
|
|
137
109
|
return
|
138
110
|
end
|
139
111
|
|
140
|
-
hsh =
|
141
|
-
|
142
|
-
|
143
|
-
ruleId: rule_id,
|
144
|
-
session_id: ::Contrast::ASSESS.session_id,
|
145
|
-
version: 4
|
146
|
-
}
|
147
|
-
hsh[:events] = events.map(&:to_controlled_hash) if event_based?
|
148
|
-
# hsh[:evidence] = evidence unless event_based? || property_based?
|
149
|
-
hsh[:properties] = properties if property_based?
|
112
|
+
hsh = base_hash
|
113
|
+
hsh[:events] = events.map(&:to_controlled_hash) if events.any?
|
114
|
+
hsh[:properties] = properties if properties.any?
|
150
115
|
hsh[:tags] = Contrast::ASSESS.tags if Contrast::ASSESS.tags
|
151
116
|
return hsh unless request_based?
|
152
117
|
|
@@ -155,6 +120,17 @@ module Contrast
|
|
155
120
|
hsh
|
156
121
|
end
|
157
122
|
|
123
|
+
# @return [Hash] the base of every finding, regardless of type
|
124
|
+
def base_hash
|
125
|
+
{
|
126
|
+
created: created,
|
127
|
+
hash: hash_code.to_s,
|
128
|
+
ruleId: rule_id,
|
129
|
+
session_id: ::Contrast::ASSESS.session_id,
|
130
|
+
version: 4
|
131
|
+
}
|
132
|
+
end
|
133
|
+
|
158
134
|
# @raise [ArgumentError]
|
159
135
|
def validate
|
160
136
|
raise(ArgumentError, "#{ self } did not have a proper rule. Unable to continue.") unless @rule_id
|
@@ -174,12 +150,6 @@ module Contrast
|
|
174
150
|
|
175
151
|
private
|
176
152
|
|
177
|
-
# Our events have properties on them. To report them to TeamServer, we need to pull them from our object up to
|
178
|
-
# the Contrast::Agent::Reporting::Finding level.
|
179
|
-
#
|
180
|
-
# TODO: RUBY-99999 put properties on events, not just on DTM
|
181
|
-
def attach_properties; end
|
182
|
-
|
183
153
|
def build_events events, event
|
184
154
|
return unless event
|
185
155
|
|
@@ -192,16 +162,16 @@ module Contrast
|
|
192
162
|
# Rules which are event based must have an event to be sent to TeamServer. They include the Trigger, Regexp,
|
193
163
|
# and Data flow type Rules, meaning all those which are not Properties based. Eventually, we may have
|
194
164
|
# validation for each of those types; however, that's a refactor for after we've translated all rules from the
|
195
|
-
#
|
165
|
+
# TeamServer and have had time to build proper child structure.
|
196
166
|
#
|
197
167
|
# @return [Boolean]
|
198
168
|
def event_based?
|
199
|
-
!property_based? && !config_based?
|
169
|
+
!property_based? && !config_based? && !hardcoded?
|
200
170
|
end
|
201
171
|
|
202
172
|
# Rules which are property based must have a property to be sent to TeamServer. Eventually, each rule may own
|
203
173
|
# its own validation, as the properties each needs are different; however, that's a refactor for after we've
|
204
|
-
# translated all rules from
|
174
|
+
# translated all rules from TeamServer and have had time to build proper child structure.
|
205
175
|
#
|
206
176
|
# @return [Boolean]
|
207
177
|
def property_based?
|
@@ -210,7 +180,7 @@ module Contrast
|
|
210
180
|
|
211
181
|
# Rules which are config based must have a configuration to be sent to TeamServer. Eventually, each rule may own
|
212
182
|
# its own validation, as the properties each needs are different; however, that's a refactor for after we've
|
213
|
-
# translated all rules from
|
183
|
+
# translated all rules from TeamServer and have had time to build proper child structure.
|
214
184
|
#
|
215
185
|
# @return [Boolean]
|
216
186
|
def config_based?
|
@@ -219,7 +189,7 @@ module Contrast
|
|
219
189
|
|
220
190
|
# Rules which are hardcode based send properties to TeamServer. Eventually, each rule may own its own
|
221
191
|
# validation, as the properties each needs are different; however, that's a refactor for after we've
|
222
|
-
# translated all rules from
|
192
|
+
# translated all rules from TeamServer and have had time to build proper child structure.
|
223
193
|
#
|
224
194
|
# @return [Boolean]
|
225
195
|
def hardcoded?
|
@@ -100,6 +100,10 @@ module Contrast
|
|
100
100
|
end
|
101
101
|
end
|
102
102
|
|
103
|
+
def initialize
|
104
|
+
@event_sources = []
|
105
|
+
end
|
106
|
+
|
103
107
|
# Parse the data from a Contrast::Agent::Assess::ContrastEvent to attach what is required for reporting to
|
104
108
|
# TeamServer to this Contrast::Agent::Reporting::FindingEvent
|
105
109
|
#
|
@@ -208,11 +212,9 @@ module Contrast
|
|
208
212
|
#
|
209
213
|
# @param event [Contrast::Agent::Assess::ContrastEvent]
|
210
214
|
def event_sources! event
|
211
|
-
@event_sources = []
|
212
215
|
return unless event.cs__is_a?(Contrast::Agent::Assess::Events::SourceEvent)
|
213
216
|
|
214
|
-
|
215
|
-
event_sources << source if source
|
217
|
+
event_sources << event.event_source if event.event_source
|
216
218
|
end
|
217
219
|
|
218
220
|
# Convert the parent id's of the given ContrastEvent to the reportable form for this FindingEvent.
|
@@ -237,12 +239,13 @@ module Contrast
|
|
237
239
|
#
|
238
240
|
# @param event [Contrast::Agent::Assess::ContrastEvent]
|
239
241
|
def stack! event
|
240
|
-
@stack =
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
242
|
+
@stack = if event.stack_trace
|
243
|
+
event.stack_trace.compact.map! do |stack_event|
|
244
|
+
Contrast::Agent::Reporting::FindingEventStack.new(stack_event)
|
245
|
+
end
|
246
|
+
else
|
247
|
+
Contrast::Utils::ObjectShare::EMPTY_ARRAY
|
248
|
+
end
|
246
249
|
end
|
247
250
|
|
248
251
|
# Convert the taint ranges of the given ContrastEvent to the reportable form for this FindingEvent.
|
@@ -61,7 +61,7 @@ module Contrast
|
|
61
61
|
# 8 is STATIC in Java... we have to placate them for now it has been requested that flags be removed since it
|
62
62
|
# isn't used
|
63
63
|
@flags = 8 unless node.instance_method?
|
64
|
-
@method_name = node.method_name
|
64
|
+
@method_name = node.method_name.to_s
|
65
65
|
@return_type = type_name(event.ret)
|
66
66
|
# if there's a ret, then this method isn't nil. not 100% full proof since you can return nil, but this is the
|
67
67
|
# best we've got currently.
|
@@ -2,8 +2,6 @@
|
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
4
|
require 'base64'
|
5
|
-
require 'contrast/agent/assess/contrast_event'
|
6
|
-
require 'contrast/agent/assess/events/source_event'
|
7
5
|
require 'contrast/components/logger'
|
8
6
|
|
9
7
|
module Contrast
|
@@ -21,25 +19,11 @@ module Contrast
|
|
21
19
|
# @return [String] the type of the source
|
22
20
|
attr_reader :type
|
23
21
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
report = new
|
31
|
-
report.attach_data(event)
|
32
|
-
report
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
# Parse the data from a Contrast::Agent::Assess::Events::SourceEvent to attach what is required for reporting
|
37
|
-
# to TeamServer to this Contrast::Agent::Reporting::FindingEventSource
|
38
|
-
#
|
39
|
-
# @param event [Contrast::Agent::Assess::Events::SourceEvent] the event to pull the source off of
|
40
|
-
def attach_data event
|
41
|
-
@name = event.source_name
|
42
|
-
@type = event.source_type
|
22
|
+
# @param type [String]
|
23
|
+
# @param name [String]
|
24
|
+
def initialize type, name
|
25
|
+
@type = type
|
26
|
+
@name = name
|
43
27
|
end
|
44
28
|
|
45
29
|
# Convert the instance variables on the class, and other information, into the identifiers required for
|
@@ -61,6 +45,24 @@ module Contrast
|
|
61
45
|
}
|
62
46
|
end
|
63
47
|
|
48
|
+
# Convert this EventSource into the format expected for route observation
|
49
|
+
#
|
50
|
+
# @return [Hash]
|
51
|
+
# @raise [ArgumentError]
|
52
|
+
def to_controlled_observation_hash
|
53
|
+
begin
|
54
|
+
validate
|
55
|
+
rescue ArgumentError => e
|
56
|
+
logger.error('FindingEventSource observation validation failed with: ', e)
|
57
|
+
return
|
58
|
+
end
|
59
|
+
|
60
|
+
{
|
61
|
+
name: name, # rubocop:disable Security/Module/Name
|
62
|
+
type: type
|
63
|
+
}
|
64
|
+
end
|
65
|
+
|
64
66
|
# @raise [ArgumentError]
|
65
67
|
def validate
|
66
68
|
raise(ArgumentError, "#{ self } did not have a proper type. Unable to continue.") unless type && !type.empty?
|
@@ -28,25 +28,12 @@ module Contrast
|
|
28
28
|
|
29
29
|
AGENT_CLASS_MARKER = '/lib/contrast/'
|
30
30
|
|
31
|
-
|
32
|
-
|
33
|
-
# @return [Contrast::Agent::Reporting::FindingEventStack,nil]
|
34
|
-
def convert stack
|
35
|
-
return unless stack
|
36
|
-
return if stack.include?(AGENT_CLASS_MARKER)
|
37
|
-
|
38
|
-
report = new
|
39
|
-
report.attach_data(stack)
|
40
|
-
report
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
# Parse the data from a Contrast::Agent::Assess::Tag to attach what is required for reporting to TeamServer to
|
45
|
-
# this Contrast::Agent::Reporting::FindingEventTaintRange
|
31
|
+
# To play nice with the way that TeamServer is rendering these values, we only populate the file_name field with
|
32
|
+
# exactly what we want them to display.
|
46
33
|
#
|
47
|
-
# @param
|
48
|
-
def
|
49
|
-
@file =
|
34
|
+
# @param file_name [String] the caller location this stack frame represents.
|
35
|
+
def initialize file_name
|
36
|
+
@file = file_name
|
50
37
|
end
|
51
38
|
|
52
39
|
# Convert the instance variables on the class, and other information, into the identifiers required for
|
@@ -2,13 +2,13 @@
|
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
4
|
module Contrast
|
5
|
-
module
|
6
|
-
module
|
7
|
-
# A holder for the valid tags that can be sent to
|
8
|
-
#
|
9
|
-
|
10
|
-
module TraceTaintRangeTags
|
5
|
+
module Agent
|
6
|
+
module Reporting
|
7
|
+
# A holder for the valid tags that can be sent to TeamServer that we have to honor. Placed here so as not to
|
8
|
+
# clutter other code.
|
9
|
+
module FindingEventTaintRangeTags
|
11
10
|
# EventTagTypeDTM
|
11
|
+
# @return [Array<Symbol>]
|
12
12
|
VALID_TAGS = %w[
|
13
13
|
XML_ENCODED
|
14
14
|
XML_DECODED
|
@@ -97,6 +97,7 @@ module Contrast
|
|
97
97
|
DATABASE_WRITE
|
98
98
|
].cs__freeze
|
99
99
|
|
100
|
+
# @return [Array<Symbol>]
|
100
101
|
VALID_SOURCE_TAGS = %w[NO_NEWLINES UNTRUSTED CROSS_SITE LIMITED_CHARS].cs__freeze
|
101
102
|
end
|
102
103
|
end
|
@@ -13,10 +13,12 @@ module Contrast
|
|
13
13
|
class FindingRequest
|
14
14
|
include Contrast::Components::Logger::InstanceMethods
|
15
15
|
|
16
|
+
OMITTED_BODY = '{{body-omitted-by-contrast}}'
|
17
|
+
|
16
18
|
# @return [String] the body of this request
|
17
|
-
|
19
|
+
attr_accessor :body
|
18
20
|
# @return [Hash<String,Array<String>>] the headers of this request
|
19
|
-
|
21
|
+
attr_accessor :headers
|
20
22
|
# @return [String] the HTTP verb of this request
|
21
23
|
attr_reader :method
|
22
24
|
# @return [Hash<String,Array<String>>] the parameters of this request
|
@@ -26,16 +28,24 @@ module Contrast
|
|
26
28
|
# @return [String] the HTTP(S) protocol of this request
|
27
29
|
attr_reader :protocol
|
28
30
|
# @return [String] the query string of this request
|
29
|
-
|
31
|
+
attr_accessor :query_string
|
30
32
|
# @return [String] the url, including path and script, of this request
|
31
33
|
attr_reader :uri
|
32
34
|
# @return [String] the HTTP version of this request
|
33
35
|
attr_reader :version
|
36
|
+
# @return [Integer]
|
37
|
+
attr_reader :ip
|
38
|
+
# @return [String] Byte representation of the body
|
39
|
+
attr_accessor :body_binary
|
40
|
+
# @return [Hash]
|
41
|
+
attr_reader :cookies
|
34
42
|
|
35
43
|
class << self
|
36
44
|
# @param request [Contrast::Agent::Request]
|
37
45
|
# @return [Contrast::Agent::Reporting::FindingRequest]
|
38
46
|
def convert request
|
47
|
+
return unless request
|
48
|
+
|
39
49
|
report = new
|
40
50
|
report.attach_data(request)
|
41
51
|
report
|
@@ -49,13 +59,7 @@ module Contrast
|
|
49
59
|
def attach_data request
|
50
60
|
@body = request.body
|
51
61
|
@headers = {}
|
52
|
-
request
|
53
|
-
# We need to change from the uppercase _ format to capitalized - format.
|
54
|
-
header = key.split('_')
|
55
|
-
header.each(&:capitalize!)
|
56
|
-
header = header.join('-')
|
57
|
-
headers[header] = value.split
|
58
|
-
end
|
62
|
+
extract_headers(request)
|
59
63
|
@method = request.request_method
|
60
64
|
@parameters = {}
|
61
65
|
request.parameters.each_pair { |key, value| @parameters[key] = Array(value) }
|
@@ -64,6 +68,14 @@ module Contrast
|
|
64
68
|
@query_string = request.query_string
|
65
69
|
@uri = request.normalized_uri
|
66
70
|
@version = request.version
|
71
|
+
@ip = request.ip || ''
|
72
|
+
@body_binary = if omit_body?(request)
|
73
|
+
OMITTED_BODY
|
74
|
+
else
|
75
|
+
Contrast::Utils::StringUtils.force_utf8(request.body)
|
76
|
+
end
|
77
|
+
@cookies = {}
|
78
|
+
@cookies = request.cookies unless request.cookies.empty?
|
67
79
|
end
|
68
80
|
|
69
81
|
# Convert the instance variables on the class, and other information, into the identifiers required for
|
@@ -92,12 +104,30 @@ module Contrast
|
|
92
104
|
}
|
93
105
|
end
|
94
106
|
|
107
|
+
def omit_body? request
|
108
|
+
return true if ::Contrast::AGENT.omit_body?
|
109
|
+
return false if request.document_type != :NORMAL
|
110
|
+
|
111
|
+
request.media_type&.include?('multipart/form-data')
|
112
|
+
end
|
113
|
+
|
95
114
|
def validate
|
96
115
|
unless method && !method.empty? # rubocop:disable Security/Object/Method
|
97
116
|
raise(ArgumentError, "#{ self } did not have a proper method. Unable to continue.")
|
98
117
|
end
|
99
118
|
raise(ArgumentError, "#{ self } did not have a proper uri. Unable to continue.") unless uri && !uri.empty?
|
100
119
|
end
|
120
|
+
|
121
|
+
# @param request [Contrast::Agent::Request]
|
122
|
+
def extract_headers request
|
123
|
+
request.headers.each_pair do |key, value|
|
124
|
+
# We need to change from the uppercase _ format to capitalized - format.
|
125
|
+
header = key.split('_')
|
126
|
+
header.each(&:capitalize!)
|
127
|
+
header = header.join('-')
|
128
|
+
headers[header] = value.split
|
129
|
+
end
|
130
|
+
end
|
101
131
|
end
|
102
132
|
end
|
103
133
|
end
|
@@ -11,7 +11,7 @@ module Contrast
|
|
11
11
|
include Contrast::Components::Logger::InstanceMethods
|
12
12
|
|
13
13
|
# @param [String] Sha256Sum of library as identified by the agent
|
14
|
-
|
14
|
+
attr_reader :id
|
15
15
|
# @param [Array<String>] List of file paths that have been loaded out of or executed by the library
|
16
16
|
attr_reader :names
|
17
17
|
|
@@ -24,7 +24,7 @@ module Contrast
|
|
24
24
|
attr_accessor :url
|
25
25
|
# @param [String] the HTTP Verb used to access the method in the route.
|
26
26
|
attr_accessor :verb
|
27
|
-
# @param [Array<Contrast::Agent::Reporting::
|
27
|
+
# @param [Array<Contrast::Agent::Reporting::FindingEventSource>] the sources of user input accessed during this
|
28
28
|
# request. Used for remediation determinations in TeamServer.
|
29
29
|
attr_reader :sources
|
30
30
|
|
@@ -56,7 +56,7 @@ module Contrast
|
|
56
56
|
|
57
57
|
{
|
58
58
|
session_id: ::Contrast::ASSESS.session_id,
|
59
|
-
sources: @sources.map(&:
|
59
|
+
sources: @sources.map(&:to_controlled_observation_hash),
|
60
60
|
signature: @signature,
|
61
61
|
verb: @verb,
|
62
62
|
url: @url
|