contrast-agent 6.11.0 → 6.13.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.simplecov +1 -1
- data/Gemfile +1 -1
- data/Rakefile +1 -1
- data/ext/build_funchook.rb +1 -1
- data/ext/cs__assess_array/cs__assess_array.c +24 -18
- data/ext/cs__assess_array/extconf.rb +1 -1
- data/ext/cs__assess_basic_object/cs__assess_basic_object.c +1 -1
- data/ext/cs__assess_basic_object/extconf.rb +1 -1
- data/ext/cs__assess_fiber_track/cs__assess_fiber_track.c +1 -1
- data/ext/cs__assess_fiber_track/extconf.rb +1 -1
- data/ext/cs__assess_hash/cs__assess_hash.c +1 -1
- data/ext/cs__assess_hash/extconf.rb +1 -1
- data/ext/cs__assess_kernel/cs__assess_kernel.c +1 -1
- data/ext/cs__assess_kernel/extconf.rb +1 -1
- data/ext/cs__assess_marshal_module/cs__assess_marshal_module.c +7 -5
- data/ext/cs__assess_marshal_module/extconf.rb +1 -1
- data/ext/cs__assess_module/cs__assess_module.c +1 -1
- data/ext/cs__assess_module/extconf.rb +1 -1
- data/ext/cs__assess_regexp/cs__assess_regexp.c +1 -1
- data/ext/cs__assess_regexp/extconf.rb +1 -1
- data/ext/cs__assess_string/cs__assess_string.c +1 -1
- data/ext/cs__assess_string/extconf.rb +1 -1
- data/ext/cs__assess_string_interpolation/cs__assess_string_interpolation.c +1 -1
- data/ext/cs__assess_string_interpolation/extconf.rb +1 -1
- data/ext/cs__assess_test/extconf.rb +1 -1
- data/ext/cs__assess_yield_track/cs__assess_yield_track.c +1 -1
- data/ext/cs__assess_yield_track/extconf.rb +1 -1
- data/ext/cs__common/cs__common.c +1 -1
- data/ext/cs__common/extconf.rb +1 -1
- data/ext/cs__contrast_patch/cs__contrast_patch.c +12 -10
- data/ext/cs__contrast_patch/extconf.rb +1 -1
- data/ext/cs__os_information/cs__os_information.c +1 -1
- data/ext/cs__os_information/extconf.rb +1 -1
- data/ext/cs__scope/cs__scope.c +390 -207
- data/ext/cs__scope/cs__scope.h +3 -1
- data/ext/cs__scope/extconf.rb +1 -1
- data/ext/cs__tests/cs__tests.c +1 -1
- data/ext/cs__tests/extconf.rb +1 -1
- data/ext/extconf_common.rb +1 -1
- data/lib/contrast/agent/assess/contrast_object.rb +1 -1
- data/lib/contrast/agent/assess/events/event_data.rb +1 -1
- data/lib/contrast/agent/assess/finalizers/freeze.rb +1 -1
- data/lib/contrast/agent/assess/finalizers/hash.rb +1 -1
- data/lib/contrast/agent/assess/policy/dynamic_source_factory.rb +1 -1
- data/lib/contrast/agent/assess/policy/patcher.rb +1 -1
- data/lib/contrast/agent/assess/policy/policy.rb +1 -1
- data/lib/contrast/agent/assess/policy/policy_node.rb +1 -1
- data/lib/contrast/agent/assess/policy/policy_node_utils.rb +1 -1
- data/lib/contrast/agent/assess/policy/policy_scanner.rb +1 -1
- data/lib/contrast/agent/assess/policy/preshift.rb +1 -1
- data/lib/contrast/agent/assess/policy/propagation_method.rb +1 -1
- data/lib/contrast/agent/assess/policy/propagation_node.rb +1 -1
- data/lib/contrast/agent/assess/policy/propagator/append.rb +1 -1
- data/lib/contrast/agent/assess/policy/propagator/base.rb +1 -1
- data/lib/contrast/agent/assess/policy/propagator/buffer.rb +1 -1
- data/lib/contrast/agent/assess/policy/propagator/center.rb +1 -1
- data/lib/contrast/agent/assess/policy/propagator/custom.rb +1 -1
- data/lib/contrast/agent/assess/policy/propagator/database_write.rb +1 -1
- data/lib/contrast/agent/assess/policy/propagator/insert.rb +1 -1
- data/lib/contrast/agent/assess/policy/propagator/keep.rb +1 -1
- data/lib/contrast/agent/assess/policy/propagator/match_data.rb +1 -1
- data/lib/contrast/agent/assess/policy/propagator/next.rb +1 -1
- data/lib/contrast/agent/assess/policy/propagator/prepend.rb +1 -1
- data/lib/contrast/agent/assess/policy/propagator/rack_protection.rb +1 -1
- data/lib/contrast/agent/assess/policy/propagator/remove.rb +1 -1
- data/lib/contrast/agent/assess/policy/propagator/replace.rb +1 -1
- data/lib/contrast/agent/assess/policy/propagator/reverse.rb +1 -1
- data/lib/contrast/agent/assess/policy/propagator/select.rb +1 -1
- data/lib/contrast/agent/assess/policy/propagator/splat.rb +1 -1
- data/lib/contrast/agent/assess/policy/propagator/split.rb +1 -1
- data/lib/contrast/agent/assess/policy/propagator/substitution.rb +1 -1
- data/lib/contrast/agent/assess/policy/propagator/substitution_utils.rb +1 -1
- data/lib/contrast/agent/assess/policy/propagator/trim.rb +1 -1
- data/lib/contrast/agent/assess/policy/propagator.rb +1 -1
- data/lib/contrast/agent/assess/policy/source_method.rb +1 -3
- data/lib/contrast/agent/assess/policy/source_node.rb +1 -1
- data/lib/contrast/agent/assess/policy/source_validation/cross_site_validator.rb +1 -1
- data/lib/contrast/agent/assess/policy/source_validation/source_validation.rb +1 -1
- data/lib/contrast/agent/assess/policy/trigger/reflected_xss.rb +2 -1
- data/lib/contrast/agent/assess/policy/trigger/xpath.rb +1 -1
- data/lib/contrast/agent/assess/policy/trigger_method.rb +1 -1
- data/lib/contrast/agent/assess/policy/trigger_node.rb +1 -1
- data/lib/contrast/agent/assess/policy/trigger_validation/redos_validator.rb +39 -1
- data/lib/contrast/agent/assess/policy/trigger_validation/ssrf_validator.rb +1 -1
- data/lib/contrast/agent/assess/policy/trigger_validation/trigger_validation.rb +1 -1
- data/lib/contrast/agent/assess/policy/trigger_validation/xss_validator.rb +1 -1
- data/lib/contrast/agent/assess/properties.rb +1 -1
- data/lib/contrast/agent/assess/property/evented.rb +1 -1
- data/lib/contrast/agent/assess/property/tagged.rb +1 -1
- data/lib/contrast/agent/assess/property/updated.rb +1 -1
- data/lib/contrast/agent/assess/rule/provider/hardcoded_key.rb +1 -1
- data/lib/contrast/agent/assess/rule/provider/hardcoded_password.rb +1 -1
- data/lib/contrast/agent/assess/rule/provider/hardcoded_value_rule.rb +1 -1
- data/lib/contrast/agent/assess/rule/provider.rb +1 -1
- data/lib/contrast/agent/assess/rule/response/auto_complete_rule.rb +1 -1
- data/lib/contrast/agent/assess/rule/response/base_rule.rb +1 -1
- data/lib/contrast/agent/assess/rule/response/body_rule.rb +1 -1
- data/lib/contrast/agent/assess/rule/response/cache_control_header_rule.rb +1 -1
- data/lib/contrast/agent/assess/rule/response/click_jacking_header_rule.rb +1 -1
- data/lib/contrast/agent/assess/rule/response/csp_header_insecure_rule.rb +1 -1
- data/lib/contrast/agent/assess/rule/response/csp_header_missing_rule.rb +1 -1
- data/lib/contrast/agent/assess/rule/response/framework/rails_support.rb +1 -1
- data/lib/contrast/agent/assess/rule/response/header_rule.rb +1 -1
- data/lib/contrast/agent/assess/rule/response/hsts_header_rule.rb +1 -1
- data/lib/contrast/agent/assess/rule/response/parameters_pollution_rule.rb +1 -1
- data/lib/contrast/agent/assess/rule/response/x_content_type_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/tag.rb +1 -1
- data/lib/contrast/agent/assess/tracker.rb +1 -1
- data/lib/contrast/agent/assess.rb +1 -1
- data/lib/contrast/agent/at_exit_hook.rb +1 -1
- data/lib/contrast/agent/deadzone/policy/deadzone_node.rb +1 -1
- data/lib/contrast/agent/deadzone/policy/policy.rb +1 -1
- data/lib/contrast/agent/disable_reaction.rb +1 -1
- data/lib/contrast/agent/excluder.rb +125 -43
- data/lib/contrast/agent/exclusion_matcher.rb +11 -55
- data/lib/contrast/agent/inventory/database_config.rb +1 -1
- data/lib/contrast/agent/inventory/dependencies.rb +1 -1
- data/lib/contrast/agent/inventory/dependency_analysis.rb +1 -1
- data/lib/contrast/agent/inventory/dependency_usage_analysis.rb +1 -1
- data/lib/contrast/agent/inventory/policy/datastores.rb +1 -1
- data/lib/contrast/agent/inventory/policy/policy.rb +1 -1
- data/lib/contrast/agent/inventory/policy/trigger_node.rb +1 -1
- data/lib/contrast/agent/inventory.rb +1 -1
- data/lib/contrast/agent/middleware.rb +21 -8
- data/lib/contrast/agent/module_data.rb +1 -1
- data/lib/contrast/agent/patching/policy/after_load_patch.rb +1 -1
- data/lib/contrast/agent/patching/policy/after_load_patcher.rb +1 -1
- data/lib/contrast/agent/patching/policy/method_policy.rb +1 -1
- data/lib/contrast/agent/patching/policy/method_policy_extend.rb +1 -1
- data/lib/contrast/agent/patching/policy/module_policy.rb +1 -1
- data/lib/contrast/agent/patching/policy/patch.rb +1 -1
- data/lib/contrast/agent/patching/policy/patch_status.rb +1 -1
- data/lib/contrast/agent/patching/policy/patcher.rb +1 -1
- data/lib/contrast/agent/patching/policy/policy.rb +1 -1
- data/lib/contrast/agent/patching/policy/policy_node.rb +1 -1
- data/lib/contrast/agent/patching/policy/trigger_node.rb +1 -1
- data/lib/contrast/agent/protect/exploitable_collection.rb +1 -1
- data/lib/contrast/agent/protect/input_analyzer/input_analyzer.rb +4 -2
- data/lib/contrast/agent/protect/input_analyzer/worth_watching_analyzer.rb +12 -11
- data/lib/contrast/agent/protect/policy/applies_command_injection_rule.rb +1 -1
- data/lib/contrast/agent/protect/policy/applies_deserialization_rule.rb +1 -1
- data/lib/contrast/agent/protect/policy/applies_no_sqli_rule.rb +1 -1
- data/lib/contrast/agent/protect/policy/applies_path_traversal_rule.rb +1 -1
- data/lib/contrast/agent/protect/policy/applies_sqli_rule.rb +1 -1
- data/lib/contrast/agent/protect/policy/applies_xxe_rule.rb +1 -1
- data/lib/contrast/agent/protect/policy/policy.rb +1 -1
- data/lib/contrast/agent/protect/policy/rule_applicator.rb +6 -1
- data/lib/contrast/agent/protect/policy/trigger_node.rb +1 -1
- data/lib/contrast/agent/protect/rule/base.rb +9 -19
- data/lib/contrast/agent/protect/rule/base_service.rb +33 -10
- data/lib/contrast/agent/protect/rule/bot_blocker/bot_blocker_input_classification.rb +1 -1
- data/lib/contrast/agent/protect/rule/bot_blocker.rb +1 -1
- data/lib/contrast/agent/protect/rule/cmd_injection.rb +1 -1
- data/lib/contrast/agent/protect/rule/cmdi/cmdi_backdoors.rb +8 -50
- data/lib/contrast/agent/protect/rule/cmdi/cmdi_base_rule.rb +11 -18
- data/lib/contrast/agent/protect/rule/cmdi/cmdi_chained_command.rb +10 -11
- data/lib/contrast/agent/protect/rule/cmdi/cmdi_dangerous_path.rb +10 -11
- data/lib/contrast/agent/protect/rule/cmdi/cmdi_input_classification.rb +1 -1
- data/lib/contrast/agent/protect/rule/default_scanner.rb +1 -1
- data/lib/contrast/agent/protect/rule/deserialization.rb +2 -3
- data/lib/contrast/agent/protect/rule/no_sqli/mongo_no_sql_scanner.rb +1 -1
- data/lib/contrast/agent/protect/rule/no_sqli/no_sqli_input_classification.rb +1 -1
- data/lib/contrast/agent/protect/rule/no_sqli.rb +1 -13
- data/lib/contrast/agent/protect/rule/path_traversal/path_traversal_input_classification.rb +1 -1
- data/lib/contrast/agent/protect/rule/path_traversal/path_traversal_semantic_security_bypass.rb +34 -9
- data/lib/contrast/agent/protect/rule/path_traversal.rb +1 -47
- data/lib/contrast/agent/protect/rule/sql_sample_builder.rb +1 -1
- data/lib/contrast/agent/protect/rule/sqli/default_sql_scanner.rb +1 -1
- data/lib/contrast/agent/protect/rule/sqli/mysql_sql_scanner.rb +1 -1
- data/lib/contrast/agent/protect/rule/sqli/postgres_sql_scanner.rb +2 -2
- data/lib/contrast/agent/protect/rule/sqli/sqli_base_rule.rb +1 -1
- data/lib/contrast/agent/protect/rule/sqli/sqli_input_classification.rb +1 -1
- data/lib/contrast/agent/protect/rule/sqli/sqli_semantic/sqli_dangerous_functions.rb +5 -5
- data/lib/contrast/agent/protect/rule/sqli/sqlite_sql_scanner.rb +1 -1
- data/lib/contrast/agent/protect/rule/sqli.rb +1 -13
- data/lib/contrast/agent/protect/rule/unsafe_file_upload/unsafe_file_upload_input_classification.rb +1 -1
- data/lib/contrast/agent/protect/rule/unsafe_file_upload.rb +1 -2
- data/lib/contrast/agent/protect/rule/xss/reflected_xss_input_classification.rb +1 -1
- data/lib/contrast/agent/protect/rule/xss.rb +1 -1
- data/lib/contrast/agent/protect/rule/xxe/entity_wrapper.rb +1 -1
- data/lib/contrast/agent/protect/rule/xxe.rb +2 -3
- data/lib/contrast/agent/protect/rule.rb +1 -1
- data/lib/contrast/agent/reporting/attack_result/attack_result.rb +1 -1
- data/lib/contrast/agent/reporting/attack_result/rasp_rule_sample.rb +1 -1
- data/lib/contrast/agent/reporting/attack_result/response_type.rb +1 -1
- data/lib/contrast/agent/reporting/attack_result/user_input.rb +1 -1
- data/lib/contrast/{api/communication → agent/reporting}/connection_status.rb +3 -17
- data/lib/contrast/agent/reporting/details/bot_blocker_details.rb +1 -1
- data/lib/contrast/agent/reporting/details/cmd_injection_details.rb +1 -1
- data/lib/contrast/agent/reporting/details/details.rb +1 -1
- data/lib/contrast/agent/reporting/details/ip_denylist_details.rb +1 -1
- data/lib/contrast/agent/reporting/details/no_sqli_details.rb +1 -1
- data/lib/contrast/agent/reporting/details/path_traversal_details.rb +1 -1
- data/lib/contrast/agent/reporting/details/path_traversal_semantic_analysis_details.rb +1 -1
- data/lib/contrast/agent/reporting/details/protect_rule_details.rb +1 -1
- data/lib/contrast/agent/reporting/details/sqli_dangerous_functions.rb +1 -1
- data/lib/contrast/agent/reporting/details/sqli_details.rb +1 -1
- data/lib/contrast/agent/reporting/details/untrusted_deserialization_details.rb +1 -1
- data/lib/contrast/agent/reporting/details/virtual_patch_details.rb +1 -1
- data/lib/contrast/agent/reporting/details/xss_details.rb +1 -1
- data/lib/contrast/agent/reporting/details/xss_match.rb +1 -1
- data/lib/contrast/agent/reporting/details/xxe_details.rb +1 -1
- data/lib/contrast/agent/reporting/details/xxe_match.rb +1 -1
- data/lib/contrast/agent/reporting/details/xxe_wrapper.rb +1 -1
- data/lib/contrast/agent/reporting/input_analysis/details/bot_blocker_details.rb +1 -1
- data/lib/contrast/agent/reporting/input_analysis/details/protect_rule_details.rb +1 -1
- data/lib/contrast/agent/reporting/input_analysis/input_analysis.rb +1 -1
- data/lib/contrast/agent/reporting/input_analysis/input_analysis_result.rb +1 -1
- data/lib/contrast/agent/reporting/input_analysis/input_type.rb +1 -1
- data/lib/contrast/agent/reporting/input_analysis/score_level.rb +1 -1
- data/lib/contrast/agent/reporting/masker/masker.rb +1 -1
- data/lib/contrast/agent/reporting/masker/masker_utils.rb +1 -1
- data/lib/contrast/agent/reporting/report.rb +1 -1
- data/lib/contrast/agent/reporting/reporter.rb +10 -9
- data/lib/contrast/agent/reporting/reporting_events/agent_startup.rb +2 -2
- data/lib/contrast/agent/reporting/reporting_events/application_activity.rb +5 -4
- data/lib/contrast/agent/reporting/reporting_events/application_defend_activity.rb +13 -9
- data/lib/contrast/agent/reporting/reporting_events/application_defend_attack_activity.rb +5 -6
- data/lib/contrast/agent/reporting/reporting_events/application_defend_attack_sample.rb +1 -1
- data/lib/contrast/agent/reporting/reporting_events/application_defend_attack_sample_activity.rb +4 -3
- data/lib/contrast/agent/reporting/reporting_events/application_defend_attack_sample_stack.rb +1 -1
- data/lib/contrast/agent/reporting/reporting_events/application_defend_attacker_activity.rb +19 -12
- data/lib/contrast/agent/reporting/reporting_events/application_inventory.rb +2 -2
- data/lib/contrast/agent/reporting/reporting_events/application_inventory_activity.rb +2 -2
- data/lib/contrast/agent/reporting/reporting_events/application_reporting_event.rb +1 -1
- data/lib/contrast/agent/reporting/reporting_events/application_settings.rb +2 -2
- data/lib/contrast/agent/reporting/reporting_events/application_startup.rb +2 -2
- data/lib/contrast/agent/reporting/reporting_events/application_startup_instrumentation.rb +1 -1
- data/lib/contrast/agent/reporting/reporting_events/application_update.rb +2 -3
- data/lib/contrast/agent/reporting/reporting_events/architecture_component.rb +4 -10
- data/lib/contrast/agent/reporting/reporting_events/discovered_route.rb +3 -11
- data/lib/contrast/agent/reporting/reporting_events/finding.rb +2 -11
- data/lib/contrast/agent/reporting/reporting_events/finding_event.rb +5 -12
- data/lib/contrast/agent/reporting/reporting_events/finding_event_object.rb +4 -12
- data/lib/contrast/agent/reporting/reporting_events/finding_event_parent_object.rb +9 -13
- data/lib/contrast/agent/reporting/reporting_events/finding_event_property.rb +9 -13
- data/lib/contrast/agent/reporting/reporting_events/finding_event_signature.rb +5 -12
- data/lib/contrast/agent/reporting/reporting_events/finding_event_source.rb +10 -21
- data/lib/contrast/agent/reporting/reporting_events/finding_event_stack.rb +9 -12
- data/lib/contrast/agent/reporting/reporting_events/finding_event_taint_range.rb +10 -14
- data/lib/contrast/agent/reporting/reporting_events/finding_event_taint_range_tags.rb +1 -1
- data/lib/contrast/agent/reporting/reporting_events/finding_request.rb +4 -12
- data/lib/contrast/agent/reporting/reporting_events/library_discovery.rb +14 -14
- data/lib/contrast/agent/reporting/reporting_events/library_usage_observation.rb +14 -14
- data/lib/contrast/agent/reporting/reporting_events/observed_library_usage.rb +3 -11
- data/lib/contrast/agent/reporting/reporting_events/observed_route.rb +2 -11
- data/lib/contrast/agent/reporting/reporting_events/poll.rb +2 -2
- data/lib/contrast/agent/reporting/reporting_events/preflight.rb +13 -2
- data/lib/contrast/agent/reporting/reporting_events/preflight_message.rb +5 -13
- data/lib/contrast/agent/reporting/reporting_events/reportable_hash.rb +47 -0
- data/lib/contrast/agent/reporting/reporting_events/reporting_event.rb +4 -35
- data/lib/contrast/agent/reporting/reporting_events/route_coverage.rb +1 -3
- data/lib/contrast/agent/reporting/reporting_events/route_discovery.rb +9 -13
- data/lib/contrast/agent/reporting/reporting_events/route_discovery_observation.rb +9 -13
- data/lib/contrast/agent/reporting/reporting_events/server_reporting_event.rb +1 -1
- data/lib/contrast/agent/reporting/reporting_events/server_settings.rb +2 -2
- data/lib/contrast/agent/reporting/reporting_utilities/audit.rb +5 -2
- data/lib/contrast/agent/reporting/reporting_utilities/build_preflight.rb +5 -2
- data/lib/contrast/agent/reporting/reporting_utilities/endpoints.rb +1 -1
- data/lib/contrast/agent/reporting/reporting_utilities/headers.rb +6 -3
- data/lib/contrast/agent/reporting/reporting_utilities/ng_response_extractor.rb +4 -4
- data/lib/contrast/agent/reporting/reporting_utilities/reporter_client.rb +6 -19
- data/lib/contrast/agent/reporting/reporting_utilities/reporter_client_utils.rb +20 -3
- data/lib/contrast/agent/reporting/reporting_utilities/reporting_storage.rb +1 -1
- data/lib/contrast/agent/reporting/reporting_utilities/response.rb +1 -1
- data/lib/contrast/agent/reporting/reporting_utilities/response_extractor.rb +2 -22
- data/lib/contrast/agent/reporting/reporting_utilities/response_handler.rb +1 -1
- data/lib/contrast/agent/reporting/reporting_utilities/response_handler_mode.rb +1 -1
- data/lib/contrast/agent/reporting/reporting_utilities/response_handler_utils.rb +22 -5
- data/lib/contrast/agent/reporting/reporting_workers/application_server_worker.rb +1 -1
- data/lib/contrast/agent/reporting/reporting_workers/reporter_heartbeat.rb +1 -1
- data/lib/contrast/agent/reporting/reporting_workers/reporting_workers.rb +1 -1
- data/lib/contrast/agent/reporting/reporting_workers/server_settings_worker.rb +1 -1
- data/lib/contrast/agent/reporting/settings/application_settings.rb +1 -1
- data/lib/contrast/agent/reporting/settings/assess.rb +1 -1
- data/lib/contrast/agent/reporting/settings/assess_rule.rb +1 -1
- data/lib/contrast/agent/reporting/settings/assess_server_feature.rb +1 -1
- data/lib/contrast/agent/reporting/settings/bot_blocker.rb +1 -1
- data/lib/contrast/agent/reporting/settings/exclusion_base.rb +90 -12
- data/lib/contrast/agent/reporting/settings/exclusions.rb +11 -31
- data/lib/contrast/agent/reporting/settings/helpers.rb +41 -5
- data/lib/contrast/agent/reporting/settings/input_exclusion.rb +54 -10
- data/lib/contrast/agent/reporting/settings/ip_filter.rb +1 -1
- data/lib/contrast/agent/reporting/settings/keyword.rb +1 -1
- data/lib/contrast/agent/reporting/settings/log_enhancer.rb +1 -1
- data/lib/contrast/agent/reporting/settings/protect.rb +1 -1
- data/lib/contrast/agent/reporting/settings/protect_rule.rb +1 -1
- data/lib/contrast/agent/reporting/settings/protect_server_feature.rb +1 -1
- data/lib/contrast/agent/reporting/settings/reaction.rb +1 -1
- data/lib/contrast/agent/reporting/settings/rule_definition.rb +1 -1
- data/lib/contrast/agent/reporting/settings/sampling.rb +1 -1
- data/lib/contrast/agent/reporting/settings/sanitizer.rb +1 -1
- data/lib/contrast/agent/reporting/settings/security_logger.rb +1 -1
- data/lib/contrast/agent/reporting/settings/sensitive_data_masking.rb +1 -1
- data/lib/contrast/agent/reporting/settings/sensitive_data_masking_rule.rb +1 -1
- data/lib/contrast/agent/reporting/settings/server_features.rb +1 -1
- data/lib/contrast/agent/reporting/settings/syslog.rb +1 -1
- data/lib/contrast/agent/reporting/settings/url_exclusion.rb +2 -26
- data/lib/contrast/agent/reporting/settings/validator.rb +1 -1
- data/lib/contrast/agent/reporting/settings/virtual_patch.rb +1 -1
- data/lib/contrast/agent/reporting/settings/virtual_patch_condition.rb +1 -1
- data/lib/contrast/agent/request.rb +1 -1
- data/lib/contrast/agent/request_context.rb +1 -1
- data/lib/contrast/agent/request_context_extend.rb +1 -1
- data/lib/contrast/agent/request_handler.rb +1 -1
- data/lib/contrast/agent/response.rb +1 -1
- data/lib/contrast/agent/rule_set.rb +1 -1
- data/lib/contrast/agent/scope.rb +9 -1
- data/lib/contrast/agent/static_analysis.rb +1 -1
- data/lib/contrast/agent/telemetry/base.rb +21 -12
- data/lib/contrast/agent/telemetry/client.rb +109 -0
- data/lib/contrast/agent/telemetry/{events/event.rb → event.rb} +1 -1
- data/lib/contrast/agent/telemetry/{events/exceptions/telemetry_exception_base.rb → exception/base.rb} +2 -2
- data/lib/contrast/agent/telemetry/{events/exceptions/telemetry_exception_event.rb → exception/event.rb} +10 -10
- data/lib/contrast/agent/telemetry/{events/exceptions/telemetry_exception_message.rb → exception/message.rb} +9 -9
- data/lib/contrast/agent/telemetry/{events/exceptions/telemetry_exception_message_exception.rb → exception/message_exception.rb} +9 -9
- data/lib/contrast/agent/telemetry/{events/exceptions/telemetry_exception_stack_frame.rb → exception/stack_frame.rb} +4 -4
- data/lib/contrast/agent/telemetry/exception.rb +19 -0
- data/lib/contrast/agent/telemetry/hash.rb +71 -0
- data/lib/contrast/{utils/telemetry_identifier.rb → agent/telemetry/identifier.rb} +5 -5
- data/lib/contrast/agent/telemetry/{events/metric_event.rb → metric_event.rb} +2 -2
- data/lib/contrast/agent/telemetry/{events/startup_metrics_event.rb → startup_metrics_event.rb} +2 -2
- data/lib/contrast/{utils → agent}/telemetry.rb +3 -3
- data/lib/contrast/agent/thread.rb +1 -1
- data/lib/contrast/agent/thread_watcher.rb +28 -31
- data/lib/contrast/agent/tracepoint_hook.rb +1 -1
- data/lib/contrast/agent/version.rb +2 -2
- data/lib/contrast/agent/worker_thread.rb +1 -1
- data/lib/contrast/agent.rb +6 -2
- data/lib/contrast/agent_lib/api/command_injection.rb +1 -1
- data/lib/contrast/agent_lib/api/init.rb +1 -1
- data/lib/contrast/agent_lib/api/input_tracing.rb +1 -1
- data/lib/contrast/agent_lib/api/panic.rb +1 -1
- data/lib/contrast/agent_lib/api/path_semantic_file_security_bypass.rb +1 -1
- data/lib/contrast/agent_lib/interface.rb +1 -1
- data/lib/contrast/agent_lib/interface_base.rb +2 -2
- data/lib/contrast/agent_lib/return_types/eval_result.rb +1 -1
- data/lib/contrast/agent_lib/test.rb +1 -1
- data/lib/contrast/components/agent.rb +1 -1
- data/lib/contrast/components/api.rb +1 -1
- data/lib/contrast/components/app_context.rb +1 -1
- data/lib/contrast/components/app_context_extend.rb +1 -1
- data/lib/contrast/components/assess.rb +1 -1
- data/lib/contrast/components/assess_rules.rb +1 -1
- data/lib/contrast/components/base.rb +1 -1
- data/lib/contrast/components/config/sources.rb +1 -1
- data/lib/contrast/components/config.rb +1 -1
- data/lib/contrast/components/heap_dump.rb +1 -1
- data/lib/contrast/components/inventory.rb +1 -1
- data/lib/contrast/components/logger.rb +1 -1
- data/lib/contrast/components/polling.rb +4 -4
- data/lib/contrast/components/protect.rb +1 -1
- data/lib/contrast/components/ruby_component.rb +45 -6
- data/lib/contrast/components/sampling.rb +6 -6
- data/lib/contrast/components/scope.rb +9 -1
- data/lib/contrast/components/security_logger.rb +1 -1
- data/lib/contrast/components/settings.rb +13 -12
- data/lib/contrast/config/api_proxy_configuration.rb +1 -1
- data/lib/contrast/config/base_configuration.rb +1 -1
- data/lib/contrast/config/certification_configuration.rb +1 -1
- data/lib/contrast/config/config.rb +14 -12
- data/lib/contrast/config/diagnostics.rb +12 -3
- data/lib/contrast/config/diagnostics_tools.rb +2 -1
- data/lib/contrast/config/effective_config.rb +81 -15
- data/lib/contrast/config/effective_config_value.rb +4 -4
- data/lib/contrast/config/env_variables.rb +1 -1
- data/lib/contrast/config/exception_configuration.rb +1 -1
- data/lib/contrast/config/protect_rule_configuration.rb +1 -1
- data/lib/contrast/config/protect_rules_configuration.rb +1 -1
- data/lib/contrast/config/request_audit_configuration.rb +1 -1
- data/lib/contrast/config/server_configuration.rb +2 -2
- data/lib/contrast/config.rb +1 -1
- data/lib/contrast/configuration.rb +1 -1
- data/lib/contrast/extension/assess/array.rb +1 -1
- data/lib/contrast/extension/assess/erb.rb +1 -1
- data/lib/contrast/extension/assess/eval_trigger.rb +1 -1
- data/lib/contrast/extension/assess/exec_trigger.rb +1 -1
- data/lib/contrast/extension/assess/fiber.rb +1 -1
- data/lib/contrast/extension/assess/hash.rb +1 -1
- data/lib/contrast/extension/assess/kernel.rb +1 -1
- data/lib/contrast/extension/assess/marshal.rb +1 -1
- data/lib/contrast/extension/assess/regexp.rb +1 -1
- data/lib/contrast/extension/assess/string.rb +1 -1
- data/lib/contrast/extension/assess.rb +1 -1
- data/lib/contrast/extension/delegator.rb +1 -1
- data/lib/contrast/extension/extension.rb +1 -1
- data/lib/contrast/extension/inventory.rb +1 -1
- data/lib/contrast/extension/module.rb +1 -1
- data/lib/contrast/extension/object.rb +1 -1
- data/lib/contrast/extension/protect/psych.rb +1 -1
- data/lib/contrast/extension/protect.rb +1 -1
- data/lib/contrast/extension/thread.rb +1 -1
- data/lib/contrast/framework/base_support.rb +1 -1
- data/lib/contrast/framework/grape/support.rb +1 -1
- data/lib/contrast/framework/manager.rb +1 -1
- data/lib/contrast/framework/manager_extend.rb +1 -1
- data/lib/contrast/framework/rack/patch/session_cookie.rb +1 -1
- data/lib/contrast/framework/rack/patch/support.rb +1 -1
- data/lib/contrast/framework/rack/support.rb +1 -1
- data/lib/contrast/framework/rails/patch/action_controller_live_buffer.rb +1 -1
- data/lib/contrast/framework/rails/patch/assess_configuration.rb +1 -1
- data/lib/contrast/framework/rails/patch/rails_application_configuration.rb +1 -1
- data/lib/contrast/framework/rails/patch/support.rb +1 -1
- data/lib/contrast/framework/rails/railtie.rb +1 -1
- data/lib/contrast/framework/rails/support.rb +1 -1
- data/lib/contrast/framework/sinatra/patch/encrypted_session_cookie.rb +39 -0
- data/lib/contrast/framework/sinatra/support.rb +14 -1
- data/lib/contrast/funchook/funchook.rb +1 -1
- data/lib/contrast/logger/aliased_logging.rb +12 -14
- data/lib/contrast/logger/application.rb +1 -1
- data/lib/contrast/logger/cef_log.rb +1 -1
- data/lib/contrast/logger/format.rb +1 -1
- data/lib/contrast/logger/log.rb +1 -1
- data/lib/contrast/logger/request.rb +1 -1
- data/lib/contrast/logger/time.rb +1 -1
- data/lib/contrast/security_exception.rb +1 -1
- data/lib/contrast/tasks/config.rb +1 -1
- data/lib/contrast/utils/assess/event_limit_utils.rb +1 -1
- data/lib/contrast/utils/assess/object_store.rb +1 -1
- data/lib/contrast/utils/assess/propagation_method_utils.rb +1 -1
- data/lib/contrast/utils/assess/property/tagged_utils.rb +1 -1
- data/lib/contrast/utils/assess/sampling_util.rb +1 -1
- data/lib/contrast/utils/assess/source_method_utils.rb +1 -1
- data/lib/contrast/utils/assess/split_utils.rb +1 -1
- data/lib/contrast/utils/assess/tracking_util.rb +1 -1
- data/lib/contrast/utils/assess/trigger_method_utils.rb +1 -1
- data/lib/contrast/utils/class_util.rb +1 -1
- data/lib/contrast/utils/duck_utils.rb +1 -1
- data/lib/contrast/utils/env_configuration_item.rb +1 -1
- data/lib/contrast/utils/findings.rb +1 -1
- data/lib/contrast/utils/hash_digest.rb +1 -1
- data/lib/contrast/utils/hash_digest_extend.rb +1 -1
- data/lib/contrast/utils/head_dump_utils_extend.rb +1 -1
- data/lib/contrast/utils/heap_dump_util.rb +1 -1
- data/lib/contrast/utils/input_classification_base.rb +2 -5
- data/lib/contrast/utils/invalid_configuration_util.rb +1 -1
- data/lib/contrast/utils/io_util.rb +1 -1
- data/lib/contrast/utils/job_servers_running.rb +1 -1
- data/lib/contrast/utils/log_utils.rb +2 -2
- data/lib/contrast/utils/lru_cache.rb +1 -1
- data/lib/contrast/utils/metrics_hash.rb +1 -1
- data/lib/contrast/utils/middleware_utils.rb +4 -4
- data/lib/contrast/utils/net_http_base.rb +3 -3
- data/lib/contrast/utils/object_share.rb +2 -1
- data/lib/contrast/utils/os.rb +1 -1
- data/lib/contrast/utils/patching/policy/patch_utils.rb +1 -1
- data/lib/contrast/utils/patching/policy/patcher_utils.rb +1 -1
- data/lib/contrast/utils/reporting/application_activity_batch_utils.rb +12 -4
- data/lib/contrast/utils/request_utils.rb +1 -1
- data/lib/contrast/utils/resource_loader.rb +1 -1
- data/lib/contrast/utils/response_utils.rb +1 -1
- data/lib/contrast/utils/routes_sent.rb +1 -2
- data/lib/contrast/utils/sha256_builder.rb +1 -1
- data/lib/contrast/utils/silence_maker.rb +16 -0
- data/lib/contrast/utils/stack_trace_utils.rb +1 -1
- data/lib/contrast/utils/string_utils.rb +1 -1
- data/lib/contrast/utils/tag_util.rb +1 -1
- data/lib/contrast/utils/thread_tracker.rb +1 -1
- data/lib/contrast/utils/timer.rb +1 -1
- data/lib/contrast-agent.rb +1 -1
- data/lib/contrast.rb +7 -6
- data/resources/assess/policy.json +26 -0
- data/ruby-agent.gemspec +2 -2
- metadata +31 -30
- data/lib/contrast/agent/reporting/settings/code_exclusion.rb +0 -32
- data/lib/contrast/agent/telemetry/events/exceptions/obfuscate.rb +0 -124
- data/lib/contrast/agent/telemetry/events/exceptions/telemetry_exceptions.rb +0 -19
- data/lib/contrast/utils/telemetry_client.rb +0 -107
- data/lib/contrast/utils/telemetry_hash.rb +0 -65
data/ext/cs__scope/cs__scope.c
CHANGED
@@ -1,22 +1,35 @@
|
|
1
|
-
/* Copyright (c)
|
1
|
+
/* Copyright (c) 2023 Contrast Security, Inc. See
|
2
2
|
* https://www.contrastsecurity.com/enduser-terms-0317a for more details. */
|
3
3
|
|
4
4
|
#include "cs__scope.h"
|
5
5
|
#include "../cs__common/cs__common.h"
|
6
6
|
#include <ruby.h>
|
7
|
+
#include <stdlib.h>
|
8
|
+
|
9
|
+
/*-----------------------------------------
|
10
|
+
| Calls to Contrast modules and classes
|
11
|
+
------------------------------------------*/
|
7
12
|
|
8
|
-
/* Calls to Contrast modules and classes */
|
9
13
|
VALUE contrast, agent, components;
|
10
14
|
VALUE scope_interface, scope_inst_methods;
|
11
15
|
VALUE scope_mod, scope_klass;
|
12
16
|
|
13
|
-
|
17
|
+
/*---------
|
18
|
+
| Arrays
|
19
|
+
----------*/
|
20
|
+
static char truthy_arr[3][5] = {"true", "True", "TRUE"};
|
21
|
+
|
22
|
+
/*----------
|
23
|
+
| Helpers
|
24
|
+
-----------*/
|
14
25
|
|
15
|
-
|
26
|
+
/**
|
27
|
+
* @brief get scope for ec or create new
|
16
28
|
*
|
17
|
-
* [Ruby definition]
|
29
|
+
* @note [Ruby definition] EXECUTION_CONTEXT[Fiber.current] ||=
|
30
|
+
* Contrast::Agent::Scope.new
|
18
31
|
*
|
19
|
-
*
|
32
|
+
* @return VALUE [Contrast::Agent::Scope]
|
20
33
|
*/
|
21
34
|
VALUE get_ec() {
|
22
35
|
VALUE ec, scope_inst, new_inst, keys, fiber;
|
@@ -36,11 +49,21 @@ VALUE get_ec() {
|
|
36
49
|
}
|
37
50
|
}
|
38
51
|
|
39
|
-
|
52
|
+
/**
|
53
|
+
* @brief create new Scope class instance
|
54
|
+
*
|
55
|
+
* @return VALUE [Contrast::Agent::Scope]
|
56
|
+
*/
|
40
57
|
VALUE rb_new_c_scope() {
|
41
58
|
return rb_class_new_instance(0, 0, scope_klass);
|
42
59
|
}
|
43
60
|
|
61
|
+
/**
|
62
|
+
* @brief Increases scope value by 1.
|
63
|
+
*
|
64
|
+
* @param scope int
|
65
|
+
* @return int
|
66
|
+
*/
|
44
67
|
int scope_increase(int scope) {
|
45
68
|
int inc = scope;
|
46
69
|
inc = inc + 1;
|
@@ -48,6 +71,12 @@ int scope_increase(int scope) {
|
|
48
71
|
return INT2FIX(inc);
|
49
72
|
}
|
50
73
|
|
74
|
+
/**
|
75
|
+
* @brief Decreases scope value by 1.
|
76
|
+
*
|
77
|
+
* @param scope int
|
78
|
+
* @return int
|
79
|
+
*/
|
51
80
|
int scope_decrease(int scope) {
|
52
81
|
int inc = scope;
|
53
82
|
inc = inc - 1;
|
@@ -55,6 +84,12 @@ int scope_decrease(int scope) {
|
|
55
84
|
return INT2FIX(inc);
|
56
85
|
}
|
57
86
|
|
87
|
+
/**
|
88
|
+
* @brief returns Qfalse or Qtrue if is in defined scope
|
89
|
+
*
|
90
|
+
* @param scope int
|
91
|
+
* @return VALUE
|
92
|
+
*/
|
58
93
|
VALUE is_in_scope(int scope) {
|
59
94
|
if (scope > 0) {
|
60
95
|
return Qtrue;
|
@@ -63,60 +98,105 @@ VALUE is_in_scope(int scope) {
|
|
63
98
|
}
|
64
99
|
}
|
65
100
|
|
66
|
-
|
67
|
-
*
|
101
|
+
/**
|
102
|
+
* @error: raise NoMethodError, "Scope '#{ name.inspect }' is not registered as
|
103
|
+
* a scope."
|
104
|
+
*/
|
68
105
|
void rb_raise_scope_no_method_err(const VALUE method_scope_sym) {
|
69
106
|
rb_raise(rb_eNoMethodError,
|
70
107
|
"Scope ':%" PRIsVALUE "' is not registered as a scope.",
|
71
108
|
rb_sym_to_s(method_scope_sym));
|
72
109
|
}
|
73
110
|
|
74
|
-
|
75
|
-
|
76
|
-
|
111
|
+
/*---------------------------------
|
112
|
+
| @class Contrast::Agent::Scope
|
113
|
+
----------------------------------*/
|
77
114
|
|
78
|
-
|
79
|
-
* @
|
115
|
+
/**
|
116
|
+
* @brief sets scope instance variables.
|
117
|
+
*
|
118
|
+
* @param self VALUE
|
119
|
+
* @param args VALUE
|
120
|
+
* @return VALUE self
|
80
121
|
*
|
81
|
-
*
|
82
|
-
*
|
83
|
-
*
|
84
|
-
*
|
85
|
-
*
|
86
|
-
* end
|
122
|
+
* @note def initialize
|
123
|
+
* @contrast_scope = 0
|
124
|
+
* @deserialization_scope = 0
|
125
|
+
* @split_scope = 0
|
126
|
+
* end
|
87
127
|
*/
|
88
128
|
VALUE contrast_scope_klass_init(VALUE self, VALUE args) {
|
89
|
-
rb_iv_set(self, rb_iv_cntr_scope,
|
129
|
+
rb_iv_set(self, rb_iv_cntr_scope, contrast_scope_application_update());
|
90
130
|
rb_iv_set(self, rb_iv_dslr_scope, INT2FIX(0));
|
91
131
|
rb_iv_set(self, rb_iv_split_scope, INT2FIX(0));
|
92
132
|
|
93
133
|
return self;
|
94
134
|
}
|
95
135
|
|
96
|
-
|
97
|
-
* @
|
98
|
-
*
|
99
|
-
*
|
136
|
+
/**
|
137
|
+
* @brief This function will determine if the Application Scope flag is set.
|
138
|
+
* If the value set is not valid the Contrast Scope with start with 0.
|
139
|
+
* If the value is validated, then the Contrast Scope will be set to 1.
|
140
|
+
* If the value is nil the Contrast Scope will be set as default => 0.
|
100
141
|
*
|
101
|
-
*
|
142
|
+
* To be valid app scope must be one of the truthy_arr: ["true", "True", "TRUE",
|
143
|
+
* "1"]
|
144
|
+
*/
|
145
|
+
VALUE contrast_scope_application_update() {
|
146
|
+
/**
|
147
|
+
* ENV variables are null-terminated strings.
|
148
|
+
*
|
149
|
+
* getenv() returns a pointer to a string within the environment list.
|
150
|
+
* The caller must take care not to modify this string,
|
151
|
+
* since that would change the environment of the process.
|
152
|
+
*
|
153
|
+
* [ Do not touch, do not free. We don't control it! ]
|
154
|
+
*/
|
155
|
+
char *eVar = getenv(c_const_ctr_agent_app_scope);
|
156
|
+
VALUE app_scope = eVar;
|
157
|
+
|
158
|
+
/* check to see if the ENV variable is set */
|
159
|
+
if (RTEST(app_scope)) {
|
160
|
+
/* Application Scope is set*/
|
161
|
+
for (int i = 0; i < sizeof(truthy_arr) / sizeof(truthy_arr[0]); i++) {
|
162
|
+
if (strcmp(eVar, truthy_arr[i]) == 0) {
|
163
|
+
return INT2FIX(1);
|
164
|
+
}
|
165
|
+
}
|
166
|
+
/* this covers all of the false values */
|
167
|
+
return INT2FIX(0);
|
168
|
+
} else {
|
169
|
+
/* Application Scope is not set ( NULL )*/
|
170
|
+
return INT2FIX(0);
|
171
|
+
}
|
172
|
+
}
|
173
|
+
|
174
|
+
/**
|
175
|
+
* @brief Check if we are in contrast scope.
|
176
|
+
* @note @method in_contrast_scope?
|
177
|
+
* @param self VALUE
|
178
|
+
* @param args VALUE
|
179
|
+
* @return VALUE [Boolean] check if we are in contrast scope
|
102
180
|
* if the scope is above 0 return true.
|
103
|
-
*
|
104
|
-
*
|
105
|
-
*
|
181
|
+
*
|
182
|
+
* @note def in_contrast_scope?
|
183
|
+
* @contrast_scope.positive?
|
184
|
+
* end
|
106
185
|
*/
|
107
186
|
VALUE in_cntr_scope(VALUE self, VALUE args) {
|
108
187
|
return is_in_scope(FIX2INT(rb_iv_get(self, rb_iv_cntr_scope)));
|
109
188
|
}
|
110
189
|
|
111
|
-
|
112
|
-
* @
|
190
|
+
/**
|
191
|
+
* @brief Enters contrast scope.
|
113
192
|
*
|
114
|
-
*
|
193
|
+
* @param self VALUE
|
194
|
+
* @param args VALUE
|
195
|
+
* @return VALUE [Integer] contrast scope increased.
|
115
196
|
*
|
116
|
-
* @
|
117
|
-
*
|
118
|
-
*
|
119
|
-
* end
|
197
|
+
* @note def enter_contrast_scope!
|
198
|
+
* @contrast_scope += 1
|
199
|
+
* end
|
120
200
|
*/
|
121
201
|
VALUE enter_cntr_scope(VALUE self, VALUE args) {
|
122
202
|
int scope = FIX2INT(rb_iv_get(self, rb_iv_cntr_scope));
|
@@ -125,15 +205,16 @@ VALUE enter_cntr_scope(VALUE self, VALUE args) {
|
|
125
205
|
return rb_iv_get(self, rb_iv_cntr_scope);
|
126
206
|
}
|
127
207
|
|
128
|
-
|
129
|
-
* @
|
208
|
+
/**
|
209
|
+
* @brief Exits contrast scope.
|
130
210
|
*
|
131
|
-
*
|
211
|
+
* @param self VALUE
|
212
|
+
* @param args VALUE
|
213
|
+
* @return VALUE [Integer] contrast scope decreased.
|
132
214
|
*
|
133
|
-
* @
|
134
|
-
*
|
135
|
-
*
|
136
|
-
* end
|
215
|
+
* @note def exit_contrast_scope!
|
216
|
+
* @contrast_scope -= 1
|
217
|
+
* end
|
137
218
|
*/
|
138
219
|
VALUE exit_cntr_scope(VALUE self, VALUE args) {
|
139
220
|
int scope = FIX2INT(rb_iv_get(self, rb_iv_cntr_scope));
|
@@ -142,30 +223,32 @@ VALUE exit_cntr_scope(VALUE self, VALUE args) {
|
|
142
223
|
return rb_iv_get(self, rb_iv_cntr_scope);
|
143
224
|
}
|
144
225
|
|
145
|
-
|
146
|
-
* @
|
147
|
-
*
|
148
|
-
* Check if we are in deserialization scope.
|
226
|
+
/**
|
227
|
+
* @brief Check if we are in deserialization scope.
|
149
228
|
*
|
150
|
-
* @
|
229
|
+
* @param self VALUE
|
230
|
+
* @param args VALUE
|
231
|
+
* @return VALUE [Boolean] check if we are in deserialization scope
|
151
232
|
* if the scope is above 0 return true.
|
152
|
-
*
|
153
|
-
*
|
154
|
-
*
|
233
|
+
*
|
234
|
+
* @note def in_deserialization_scope?
|
235
|
+
* @deserialization_scope.positive?
|
236
|
+
* end
|
155
237
|
*/
|
156
238
|
VALUE in_dslr_scope(VALUE self, VALUE args) {
|
157
239
|
return is_in_scope(FIX2INT(rb_iv_get(self, rb_iv_dslr_scope)));
|
158
240
|
}
|
159
241
|
|
160
|
-
|
161
|
-
* @
|
242
|
+
/**
|
243
|
+
* @brief Enters deserialization scope.
|
162
244
|
*
|
163
|
-
*
|
245
|
+
* @param self VALUE
|
246
|
+
* @param args VALUE
|
247
|
+
* @return VALUE [Integer] deserialization scope increased.
|
164
248
|
*
|
165
|
-
* @
|
166
|
-
*
|
167
|
-
*
|
168
|
-
* end
|
249
|
+
* @note def enter_deserialization_scope!
|
250
|
+
* @deserialization_scope += 1
|
251
|
+
* end
|
169
252
|
*/
|
170
253
|
VALUE enter_dsrl_scope(VALUE self, VALUE args) {
|
171
254
|
int scope = FIX2INT(rb_iv_get(self, rb_iv_dslr_scope));
|
@@ -174,15 +257,17 @@ VALUE enter_dsrl_scope(VALUE self, VALUE args) {
|
|
174
257
|
return rb_iv_get(self, rb_iv_dslr_scope);
|
175
258
|
}
|
176
259
|
|
177
|
-
|
178
|
-
* @
|
260
|
+
/**
|
261
|
+
* @brief Exits deserialization scope.
|
179
262
|
*
|
180
|
-
*
|
263
|
+
* @param self VALUE
|
264
|
+
* @param args VALUE
|
265
|
+
* @return VALUE [Integer] deserialization scope decreased.
|
181
266
|
*
|
182
|
-
* @
|
183
|
-
*
|
184
|
-
*
|
185
|
-
|
267
|
+
* @note def enter_deserialization_scope!
|
268
|
+
* @deserialization_scope += 1
|
269
|
+
* end
|
270
|
+
|
186
271
|
*/
|
187
272
|
VALUE exit_dsrl_scope(VALUE self, VALUE args) {
|
188
273
|
int scope = FIX2INT(rb_iv_get(self, rb_iv_dslr_scope));
|
@@ -191,30 +276,32 @@ VALUE exit_dsrl_scope(VALUE self, VALUE args) {
|
|
191
276
|
return rb_iv_get(self, rb_iv_dslr_scope);
|
192
277
|
}
|
193
278
|
|
194
|
-
|
195
|
-
* @
|
196
|
-
*
|
197
|
-
* Check if we are in split scope.
|
279
|
+
/**
|
280
|
+
* @brief Check if we are in split scope.
|
198
281
|
*
|
199
|
-
* @
|
282
|
+
* @param self VALUE
|
283
|
+
* @param args VALUE
|
284
|
+
* @return VALUE [Boolean] check if we are in split scope
|
200
285
|
* if the scope is above 0 return true.
|
201
|
-
*
|
202
|
-
*
|
203
|
-
*
|
286
|
+
*
|
287
|
+
* @note def in_split_scope?
|
288
|
+
* @split_scope.positive?
|
289
|
+
* end
|
204
290
|
*/
|
205
291
|
VALUE in_split_scope(VALUE self, VALUE args) {
|
206
292
|
return is_in_scope(FIX2INT(rb_iv_get(self, rb_iv_split_scope)));
|
207
293
|
}
|
208
294
|
|
209
|
-
|
210
|
-
* @
|
295
|
+
/**
|
296
|
+
* @brief Enters split scope.
|
211
297
|
*
|
212
|
-
*
|
298
|
+
* @param self VALUE
|
299
|
+
* @param args VALUE
|
300
|
+
* @return VALUE [Integer] split scope increased.
|
213
301
|
*
|
214
|
-
* @
|
215
|
-
*
|
216
|
-
*
|
217
|
-
* end
|
302
|
+
* @note def enter_split_scope!
|
303
|
+
* @split_scope += 1
|
304
|
+
* end
|
218
305
|
*/
|
219
306
|
VALUE enter_split_scope(VALUE self, VALUE args) {
|
220
307
|
int scope = FIX2INT(rb_iv_get(self, rb_iv_split_scope));
|
@@ -223,15 +310,16 @@ VALUE enter_split_scope(VALUE self, VALUE args) {
|
|
223
310
|
return rb_iv_get(self, rb_iv_split_scope);
|
224
311
|
}
|
225
312
|
|
226
|
-
|
227
|
-
* @
|
313
|
+
/**
|
314
|
+
* @brief Exits split scope.
|
228
315
|
*
|
229
|
-
*
|
316
|
+
* @param self VALUE
|
317
|
+
* @param args VALUE
|
318
|
+
* @return VALUE [Integer] split scope decreased.
|
230
319
|
*
|
231
|
-
* @
|
232
|
-
*
|
233
|
-
*
|
234
|
-
* end
|
320
|
+
* @note def enter_split_scope!
|
321
|
+
* @split_scope -= 1
|
322
|
+
* end
|
235
323
|
*/
|
236
324
|
VALUE exit_split_scope(VALUE self, VALUE args) {
|
237
325
|
int scope = FIX2INT(rb_iv_get(self, rb_iv_split_scope));
|
@@ -240,44 +328,47 @@ VALUE exit_split_scope(VALUE self, VALUE args) {
|
|
240
328
|
return rb_iv_get(self, rb_iv_split_scope);
|
241
329
|
}
|
242
330
|
|
243
|
-
|
244
|
-
* @
|
331
|
+
/**
|
332
|
+
* @brief Returns split scope current depth.
|
245
333
|
*
|
246
|
-
*
|
334
|
+
* @param self VALUE
|
335
|
+
* @param args VALUE
|
336
|
+
* @return VALUE [Integer]
|
247
337
|
*
|
248
|
-
* @
|
249
|
-
*
|
250
|
-
*
|
251
|
-
* end
|
338
|
+
* @note def split_scope_depth
|
339
|
+
* @split_scope
|
340
|
+
* end
|
252
341
|
*/
|
253
342
|
VALUE split_scope_depth(VALUE self, VALUE args) {
|
254
343
|
return rb_iv_get(self, rb_iv_split_scope);
|
255
344
|
}
|
256
345
|
|
257
|
-
|
346
|
+
/**
|
258
347
|
* Static methods to be used, the cases are defined by the usage from the above
|
259
348
|
* methods if more methods are added - please extend the case statements as they
|
260
|
-
* are no longed dynamic
|
349
|
+
* are no longed dynamic.
|
261
350
|
*/
|
262
351
|
|
263
|
-
|
264
|
-
* @
|
265
|
-
*
|
266
|
-
*
|
267
|
-
*
|
268
|
-
*
|
269
|
-
* @return [Boolean] check if we are in passed scope.
|
270
|
-
*
|
271
|
-
*
|
272
|
-
*
|
273
|
-
*
|
274
|
-
*
|
275
|
-
*
|
276
|
-
*
|
277
|
-
*
|
278
|
-
*
|
279
|
-
*
|
280
|
-
*
|
352
|
+
/**
|
353
|
+
* @brief Check if we are in specific scope.
|
354
|
+
*
|
355
|
+
* @param self VALUE
|
356
|
+
* @param method_scope_sym VALUE [Symbol] scope symbol representing scope to
|
357
|
+
* check.
|
358
|
+
* @return VALUE [Boolean] check if we are in passed scope.
|
359
|
+
* @error: NoMethodError
|
360
|
+
*
|
361
|
+
* @note def in_scope? name
|
362
|
+
* case name
|
363
|
+
* when :contrast
|
364
|
+
* in_contrast_scope?
|
365
|
+
* when :deserialization
|
366
|
+
* in_deserialization_scope?
|
367
|
+
* when :split
|
368
|
+
* in_split_scope?
|
369
|
+
* else
|
370
|
+
* raise NoMethodError, "Scope '#{ name.inspect }' is not registered
|
371
|
+
* as a scope." end end
|
281
372
|
*/
|
282
373
|
VALUE scope_klass_in_scope(VALUE self, VALUE method_scope_sym) {
|
283
374
|
VALUE in_scope = Qnil;
|
@@ -298,24 +389,25 @@ VALUE scope_klass_in_scope(VALUE self, VALUE method_scope_sym) {
|
|
298
389
|
return in_scope;
|
299
390
|
}
|
300
391
|
|
301
|
-
|
302
|
-
* @
|
303
|
-
*
|
304
|
-
*
|
305
|
-
*
|
306
|
-
*
|
307
|
-
* @return [Boolean] entered scope value increased.
|
308
|
-
*
|
309
|
-
*
|
310
|
-
*
|
311
|
-
*
|
312
|
-
*
|
313
|
-
*
|
314
|
-
*
|
315
|
-
*
|
316
|
-
*
|
317
|
-
*
|
318
|
-
*
|
392
|
+
/**
|
393
|
+
* @brief Enters specific scope.
|
394
|
+
*
|
395
|
+
* @param self VALUE
|
396
|
+
* @param method_scope_sym VALUE [Symbol] scope symbol representing scope to
|
397
|
+
* enter.
|
398
|
+
* @return VALUE [Boolean] entered scope value increased.
|
399
|
+
*
|
400
|
+
* @note def enter_scope! name
|
401
|
+
* case name
|
402
|
+
* when :contrast
|
403
|
+
* enter_contrast_scope!
|
404
|
+
* when :deserialization
|
405
|
+
* enter_deserialization_scope!
|
406
|
+
* when :split
|
407
|
+
* enter_split_scope!
|
408
|
+
* else
|
409
|
+
* raise NoMethodError, "Scope '#{ name.inspect }' is not registered as
|
410
|
+
* a scope." end end
|
319
411
|
*/
|
320
412
|
VALUE scope_klass_enter_scope(VALUE self, VALUE method_scope_sym) {
|
321
413
|
VALUE enter_scope = Qnil;
|
@@ -333,13 +425,15 @@ VALUE scope_klass_enter_scope(VALUE self, VALUE method_scope_sym) {
|
|
333
425
|
return enter_scope;
|
334
426
|
}
|
335
427
|
|
336
|
-
|
337
|
-
* @
|
428
|
+
/**
|
429
|
+
* @brief Exits specific scope.
|
338
430
|
*
|
339
|
-
*
|
431
|
+
* @param self VALUE
|
432
|
+
* @param method_scope_sym VALUE [Symbol] scope symbol representing scope to
|
433
|
+
* exit.
|
434
|
+
* @return VALUE [Boolean] entered scope value decreased.
|
340
435
|
*
|
341
|
-
* @
|
342
|
-
* @return [Boolean] entered scope value decreased.
|
436
|
+
* @note
|
343
437
|
* def exit_scope! name
|
344
438
|
* case name
|
345
439
|
* when :contrast
|
@@ -368,18 +462,18 @@ VALUE scope_klass_exit_scope(VALUE self, VALUE method_scope_sym) {
|
|
368
462
|
return exit_scope;
|
369
463
|
}
|
370
464
|
|
371
|
-
|
372
|
-
|
373
|
-
|
465
|
+
/*-----------------------------------------
|
466
|
+
| @class Contrast::Components::Interface
|
467
|
+
------------------------------------------*/
|
374
468
|
|
375
|
-
|
376
|
-
*
|
377
|
-
* init set new scope for current fiber
|
378
|
-
* @return ec [Hash<Fiber => Scope>]
|
469
|
+
/**
|
470
|
+
* @brief init set new scope for current fiber
|
379
471
|
*
|
380
|
-
*
|
472
|
+
* @param self VALUE
|
473
|
+
* @param args VALUE
|
474
|
+
* @return VALUE [Hash<Fiber => Scope>] ec
|
381
475
|
*
|
382
|
-
* EXECUTION_CONTEXT[Fiber.current] = Contrast::Agent::Scope.new
|
476
|
+
* @note EXECUTION_CONTEXT[Fiber.current] = Contrast::Agent::Scope.new
|
383
477
|
*/
|
384
478
|
VALUE contrast_scope_interface_init(VALUE self, VALUE args) {
|
385
479
|
VALUE ec = rb_const_get(scope_mod, rb_intern(rb_const_ec));
|
@@ -388,26 +482,24 @@ VALUE contrast_scope_interface_init(VALUE self, VALUE args) {
|
|
388
482
|
return ec;
|
389
483
|
}
|
390
484
|
|
391
|
-
|
392
|
-
* @
|
393
|
-
*
|
394
|
-
*
|
395
|
-
* sparingly, preferring the instance & class methods to access and query scope,
|
396
|
-
* rather than interacting with the scope object directly.
|
485
|
+
/**
|
486
|
+
* @brief This returns the scope governing the current execution context. Use
|
487
|
+
* this sparingly, preferring the instance & class methods to access and query
|
488
|
+
* scope, rather than interacting with the scope object directly.
|
397
489
|
*
|
398
490
|
* Alternative to Monitor => mutex.synchronize
|
399
491
|
* rb_mutex_new(void)
|
400
492
|
* rb_mutex_synchronize (VALUE mutex, VALUE(*func)(VALUE arg), VALUE arg)
|
401
493
|
* Mutex.synchronize do ... end goes here:
|
402
494
|
*
|
495
|
+
* @param self VALUE
|
496
|
+
* @param args VALUE
|
497
|
+
* @return VALUE
|
403
498
|
*
|
404
|
-
*
|
405
|
-
*
|
406
|
-
*
|
407
|
-
*
|
408
|
-
* return EXECUTION_CONTEXT[Fiber.current] ||= Contrast::Agent::Scope.new
|
409
|
-
* end
|
410
|
-
* end
|
499
|
+
* @note def scope_for_current_ec
|
500
|
+
* MONITOR.synchronize do
|
501
|
+
* return EXECUTION_CONTEXT[Fiber.current] ||=
|
502
|
+
* Contrast::Agent::Scope.new end end
|
411
503
|
*/
|
412
504
|
VALUE contrast_scope_for_current_ec(VALUE self, VALUE args) {
|
413
505
|
/* synchronize */
|
@@ -416,26 +508,23 @@ VALUE contrast_scope_for_current_ec(VALUE self, VALUE args) {
|
|
416
508
|
return rb_mutex_synchronize(mutex, get_ec, 0);
|
417
509
|
}
|
418
510
|
|
419
|
-
|
420
|
-
|
421
|
-
|
511
|
+
/*--------------------------------------------------------
|
512
|
+
| @module Contrast::Components::Scope::InstanceMethods
|
513
|
+
---------------------------------------------------------*/
|
422
514
|
|
423
|
-
|
424
|
-
* @method
|
425
|
-
*
|
426
|
-
* Iterates over the method policy's scopes and enters in each one.
|
515
|
+
/**
|
516
|
+
* @brief Iterates over the method policy's scopes and enters in each one.
|
427
517
|
*
|
428
|
-
*
|
518
|
+
* @param self VALUE
|
519
|
+
* @param scopes_to_enter VALUE [Array<Symbol>] Scopes form
|
429
520
|
* method_policy#scopes_to_enter for the scope current method policy
|
430
|
-
*
|
431
|
-
*
|
432
|
-
* [Ruby definition]
|
521
|
+
* @return VALUE [Array<Symbol>] scopes_to_enter
|
433
522
|
*
|
434
|
-
*
|
435
|
-
*
|
436
|
-
*
|
523
|
+
* @note def enter_method_scope! scopes_to_enter
|
524
|
+
* scopes_to_enter.each do |scope|
|
525
|
+
* enter_scope!(scope)
|
526
|
+
* end
|
437
527
|
* end
|
438
|
-
* end
|
439
528
|
*/
|
440
529
|
VALUE inst_methods_enter_method_scope(VALUE self, VALUE scopes_to_enter) {
|
441
530
|
VALUE scopes_ary, scope;
|
@@ -451,22 +540,19 @@ VALUE inst_methods_enter_method_scope(VALUE self, VALUE scopes_to_enter) {
|
|
451
540
|
return scopes_to_enter;
|
452
541
|
}
|
453
542
|
|
454
|
-
|
455
|
-
* @method
|
456
|
-
*
|
457
|
-
* Iterates over the method policy's scopes and exits each one.
|
543
|
+
/**
|
544
|
+
* @brief Iterates over the method policy's scopes and exits each one.
|
458
545
|
*
|
459
|
-
*
|
546
|
+
* @param self VALUE
|
547
|
+
* @param scopes_to_exit VALUE [Array<Symbol>] Scopes form
|
460
548
|
* method_policy#scopes_to_exit for the scope current method policy
|
461
|
-
*
|
549
|
+
* @return VALUE [Array<Symbol>] scopes_to_exit
|
462
550
|
*
|
463
|
-
*
|
464
|
-
*
|
465
|
-
*
|
466
|
-
*
|
467
|
-
* enter_scope!(scope)
|
551
|
+
* @note def enter_method_scope! scopes_to_exit
|
552
|
+
* scopes_to_exit.each do |scope|
|
553
|
+
* enter_scope!(scope)
|
554
|
+
* end
|
468
555
|
* end
|
469
|
-
* end
|
470
556
|
*/
|
471
557
|
VALUE inst_methods_exit_method_scope(VALUE self, VALUE scopes_to_exit) {
|
472
558
|
VALUE scopes_ary, scope;
|
@@ -482,19 +568,34 @@ VALUE inst_methods_exit_method_scope(VALUE self, VALUE scopes_to_exit) {
|
|
482
568
|
return scopes_to_exit;
|
483
569
|
}
|
484
570
|
|
485
|
-
|
571
|
+
/**
|
572
|
+
* For the InstanceMethods we need to call all the scope methods from the
|
486
573
|
* current ec context All methods bellow are with same names as
|
487
574
|
* Contrast::Agent::Scope class with the difference that they act as forwarders:
|
488
|
-
* exp:
|
489
575
|
* def in_contrast_scope?
|
490
576
|
* scope_for_current_ec.in_contrast_scope?
|
491
577
|
* end
|
492
578
|
*/
|
579
|
+
|
580
|
+
/**
|
581
|
+
* @brief scope_for_current_ec.in_contrast_scope?
|
582
|
+
*
|
583
|
+
* @param self VALUE
|
584
|
+
* @param args VALUE
|
585
|
+
* @return VALUE
|
586
|
+
*/
|
493
587
|
VALUE inst_methods_in_cntr_scope(VALUE self, VALUE args) {
|
494
588
|
return is_in_scope(FIX2INT(
|
495
589
|
rb_iv_get(contrast_scope_for_current_ec(self, 0), rb_iv_cntr_scope)));
|
496
590
|
}
|
497
591
|
|
592
|
+
/**
|
593
|
+
* @brief scope_for_current_ec.enter_contrast_scope!
|
594
|
+
*
|
595
|
+
* @param self VALUE
|
596
|
+
* @param args VALUE
|
597
|
+
* @return VALUE
|
598
|
+
*/
|
498
599
|
VALUE inst_methods_enter_cntr_scope(VALUE self, VALUE args) {
|
499
600
|
int scope = FIX2INT(
|
500
601
|
rb_iv_get(contrast_scope_for_current_ec(self, 0), rb_iv_cntr_scope));
|
@@ -504,6 +605,13 @@ VALUE inst_methods_enter_cntr_scope(VALUE self, VALUE args) {
|
|
504
605
|
return rb_iv_get(contrast_scope_for_current_ec(self, 0), rb_iv_cntr_scope);
|
505
606
|
}
|
506
607
|
|
608
|
+
/**
|
609
|
+
* @brief scope_for_current_ec.exit_contrast_scope!
|
610
|
+
*
|
611
|
+
* @param self VALUE
|
612
|
+
* @param args VALUE
|
613
|
+
* @return VALUE
|
614
|
+
*/
|
507
615
|
VALUE inst_methods_exit_cntr_scope(VALUE self, VALUE args) {
|
508
616
|
int scope = FIX2INT(
|
509
617
|
rb_iv_get(contrast_scope_for_current_ec(self, 0), rb_iv_cntr_scope));
|
@@ -513,11 +621,25 @@ VALUE inst_methods_exit_cntr_scope(VALUE self, VALUE args) {
|
|
513
621
|
return rb_iv_get(contrast_scope_for_current_ec(self, 0), rb_iv_cntr_scope);
|
514
622
|
}
|
515
623
|
|
624
|
+
/**
|
625
|
+
* @brief scope_for_current_ec.in_split_scope?
|
626
|
+
*
|
627
|
+
* @param self VALUE
|
628
|
+
* @param args VALUE
|
629
|
+
* @return VALUE
|
630
|
+
*/
|
516
631
|
VALUE inst_methods_in_split_scope(VALUE self, VALUE args) {
|
517
632
|
return is_in_scope(FIX2INT(
|
518
633
|
rb_iv_get(contrast_scope_for_current_ec(self, 0), rb_iv_split_scope)));
|
519
634
|
}
|
520
635
|
|
636
|
+
/**
|
637
|
+
* @brief scope_for_current_ec.enter_split_scope!
|
638
|
+
*
|
639
|
+
* @param self VALUE
|
640
|
+
* @param args VALUE
|
641
|
+
* @return VALUE
|
642
|
+
*/
|
521
643
|
VALUE inst_methods_enter_split_scope(VALUE self, VALUE args) {
|
522
644
|
int scope = FIX2INT(
|
523
645
|
rb_iv_get(contrast_scope_for_current_ec(self, 0), rb_iv_split_scope));
|
@@ -526,6 +648,13 @@ VALUE inst_methods_enter_split_scope(VALUE self, VALUE args) {
|
|
526
648
|
scope_increase(scope));
|
527
649
|
}
|
528
650
|
|
651
|
+
/**
|
652
|
+
* @brief scope_for_current_ec.exit_split_scope!
|
653
|
+
*
|
654
|
+
* @param self VALUE
|
655
|
+
* @param args VALUE
|
656
|
+
* @return VALUE
|
657
|
+
*/
|
529
658
|
VALUE inst_methods_exit_split_scope(VALUE self, VALUE args) {
|
530
659
|
int scope = FIX2INT(
|
531
660
|
rb_iv_get(contrast_scope_for_current_ec(self, 0), rb_iv_split_scope));
|
@@ -535,15 +664,36 @@ VALUE inst_methods_exit_split_scope(VALUE self, VALUE args) {
|
|
535
664
|
return rb_iv_get(contrast_scope_for_current_ec(self, 0), rb_iv_split_scope);
|
536
665
|
}
|
537
666
|
|
667
|
+
/**
|
668
|
+
* @brief Get Deserialization scope iv.
|
669
|
+
*
|
670
|
+
* @param self
|
671
|
+
* @param args
|
672
|
+
* @return VALUE
|
673
|
+
*/
|
538
674
|
VALUE inst_methods_split_scope_depth(VALUE self, VALUE args) {
|
539
675
|
return rb_iv_get(contrast_scope_for_current_ec(self, 0), rb_iv_split_scope);
|
540
676
|
}
|
541
677
|
|
678
|
+
/**
|
679
|
+
* @brief scope_for_current_ec.in_deserialization_scope?
|
680
|
+
*
|
681
|
+
* @param self VALUE
|
682
|
+
* @param args VALUE
|
683
|
+
* @return VALUE
|
684
|
+
*/
|
542
685
|
VALUE inst_methods_in_dsrl_scope(VALUE self, VALUE args) {
|
543
686
|
return is_in_scope(FIX2INT(
|
544
687
|
rb_iv_get(contrast_scope_for_current_ec(self, 0), rb_iv_dslr_scope)));
|
545
688
|
}
|
546
689
|
|
690
|
+
/**
|
691
|
+
* @brief scope_for_current_ec.enter_deserialization_scope!
|
692
|
+
*
|
693
|
+
* @param self VALUE
|
694
|
+
* @param args VALUE
|
695
|
+
* @return VALUE
|
696
|
+
*/
|
547
697
|
VALUE inst_methods_enter_dsrl_scope(VALUE self, VALUE args) {
|
548
698
|
int scope = FIX2INT(
|
549
699
|
rb_iv_get(contrast_scope_for_current_ec(self, 0), rb_iv_dslr_scope));
|
@@ -553,6 +703,13 @@ VALUE inst_methods_enter_dsrl_scope(VALUE self, VALUE args) {
|
|
553
703
|
return rb_iv_get(contrast_scope_for_current_ec(self, 0), rb_iv_dslr_scope);
|
554
704
|
}
|
555
705
|
|
706
|
+
/**
|
707
|
+
* @brief scope_for_current_ec.exit_deserialization_scope!
|
708
|
+
*
|
709
|
+
* @param self VALUE
|
710
|
+
* @param args VALUE
|
711
|
+
* @return VALUE
|
712
|
+
*/
|
556
713
|
VALUE inst_methods_exit_dsrl_scope(VALUE self, VALUE args) {
|
557
714
|
int scope = FIX2INT(
|
558
715
|
rb_iv_get(contrast_scope_for_current_ec(self, 0), rb_iv_dslr_scope));
|
@@ -562,6 +719,15 @@ VALUE inst_methods_exit_dsrl_scope(VALUE self, VALUE args) {
|
|
562
719
|
return rb_iv_get(contrast_scope_for_current_ec(self, 0), rb_iv_dslr_scope);
|
563
720
|
}
|
564
721
|
|
722
|
+
/**
|
723
|
+
* @brief Check to see if we are in scope by parameter symbol passed. Raises
|
724
|
+
* error if symbol is not valid.
|
725
|
+
*
|
726
|
+
* @param self VALUE
|
727
|
+
* @param method_scope_sym VALUE [Symbol]
|
728
|
+
* @error: rb_raise_scope_no_method_err [NoMethodError]
|
729
|
+
* @return VALUE
|
730
|
+
*/
|
565
731
|
VALUE inst_methods_in_scope(VALUE self, VALUE method_scope_sym) {
|
566
732
|
if (method_scope_sym == rb_sym_contrast) {
|
567
733
|
inst_methods_in_cntr_scope(self, 0);
|
@@ -574,6 +740,15 @@ VALUE inst_methods_in_scope(VALUE self, VALUE method_scope_sym) {
|
|
574
740
|
}
|
575
741
|
}
|
576
742
|
|
743
|
+
/**
|
744
|
+
* @brief Enters scope by parameter symbol passed. Raises error if symbol is not
|
745
|
+
* valid.
|
746
|
+
*
|
747
|
+
* @param self VALUE
|
748
|
+
* @param method_scope_sym VALUE [Symbol]
|
749
|
+
* @error: rb_raise_scope_no_method_err [NoMethodError]
|
750
|
+
* @return VALUE
|
751
|
+
*/
|
577
752
|
VALUE inst_methods_enter_scope(VALUE self, VALUE method_scope_sym) {
|
578
753
|
if (method_scope_sym == rb_sym_contrast) {
|
579
754
|
inst_methods_enter_cntr_scope(self, 0);
|
@@ -586,6 +761,15 @@ VALUE inst_methods_enter_scope(VALUE self, VALUE method_scope_sym) {
|
|
586
761
|
}
|
587
762
|
}
|
588
763
|
|
764
|
+
/**
|
765
|
+
* @brief Exits scope by parameter symbol passed. Raises error if symbol is not
|
766
|
+
* valid.
|
767
|
+
*
|
768
|
+
* @param self VALUE
|
769
|
+
* @param method_scope_sym VALUE [Symbol]
|
770
|
+
* @error: rb_raise_scope_no_method_err [NoMethodError]
|
771
|
+
* @return VALUE
|
772
|
+
*/
|
589
773
|
VALUE inst_methods_exit_scope(VALUE self, VALUE method_scope_sym) {
|
590
774
|
if (method_scope_sym == rb_sym_contrast) {
|
591
775
|
inst_methods_exit_cntr_scope(self, 0);
|
@@ -598,22 +782,16 @@ VALUE inst_methods_exit_scope(VALUE self, VALUE method_scope_sym) {
|
|
598
782
|
}
|
599
783
|
}
|
600
784
|
|
601
|
-
|
602
|
-
*
|
603
|
-
*
|
604
|
-
* TODO: RUBY-534, #sweep_dead_ecs compensates for a lack of weak tables. when
|
785
|
+
/**
|
786
|
+
* @brief Sweeps and cleans any unused Execution Contexts.
|
787
|
+
* TODO: RUBY-534, #sweep_dead_ecs compensates for a lack of weak tables. when
|
605
788
|
* we can use WeakRef, we should investigate removing this call and instead use
|
606
789
|
* the WeakRef for the Execution Context's Keys or using our Finalizers Hash for
|
607
790
|
* Fibers
|
608
791
|
*
|
609
|
-
*
|
610
|
-
*
|
611
|
-
*
|
612
|
-
* EXECUTION_CONTEXT.delete_if do |ec, _scope|
|
613
|
-
* !ec.alive?
|
614
|
-
* end
|
615
|
-
* end
|
616
|
-
* end
|
792
|
+
* @param self VALUE
|
793
|
+
* @param args VALUE
|
794
|
+
* @return VALUE
|
617
795
|
*/
|
618
796
|
VALUE scope_mod_sweep_dead_ecs(VALUE self, VALUE args) {
|
619
797
|
VALUE mutex, ec, ec_keys, key, test;
|
@@ -649,6 +827,7 @@ void Init_cs__scope() {
|
|
649
827
|
rb_const_mon = "MONITOR";
|
650
828
|
rb_const_ec = "EXECUTION_CONTEXT";
|
651
829
|
rb_const_ec_keys = "EC_KEYS";
|
830
|
+
c_const_ctr_agent_app_scope = "CONTRAST__AGENT__RUBY__APPLICATION_SCOPE";
|
652
831
|
|
653
832
|
/* Symbols */
|
654
833
|
rb_sym_scope_mod = rb_intern("Scope");
|
@@ -675,6 +854,7 @@ void Init_cs__scope() {
|
|
675
854
|
|
676
855
|
/* Define the new scope modules and objects */
|
677
856
|
contrast = rb_define_module("Contrast");
|
857
|
+
/* contrast::Agent */
|
678
858
|
agent = rb_define_module_under(contrast, "Agent");
|
679
859
|
/* components => Contrast::Components */
|
680
860
|
components = rb_define_module_under(contrast, "Components");
|
@@ -687,7 +867,7 @@ void Init_cs__scope() {
|
|
687
867
|
/* scope_klass => Contrast::Agent::Scope */
|
688
868
|
scope_klass = rb_define_class_under(agent, "Scope", rb_cObject);
|
689
869
|
|
690
|
-
|
870
|
+
/**
|
691
871
|
* @class Contrast::Agent::Scope
|
692
872
|
*/
|
693
873
|
|
@@ -721,7 +901,7 @@ void Init_cs__scope() {
|
|
721
901
|
rb_define_method(scope_klass, rb_method_name_exit_scope,
|
722
902
|
scope_klass_exit_scope, 1);
|
723
903
|
|
724
|
-
|
904
|
+
/**
|
725
905
|
* @class Contrast::Components::Interface
|
726
906
|
*/
|
727
907
|
|
@@ -732,7 +912,7 @@ void Init_cs__scope() {
|
|
732
912
|
rb_define_method(scope_interface, rb_method_name_scope_for_current_ec,
|
733
913
|
contrast_scope_for_current_ec, 0);
|
734
914
|
|
735
|
-
|
915
|
+
/**
|
736
916
|
* @module Contrast::Components::Scope
|
737
917
|
*/
|
738
918
|
|
@@ -742,10 +922,10 @@ void Init_cs__scope() {
|
|
742
922
|
rb_const_set(scope_mod, rb_intern(rb_const_ec_keys), rb_ary_new());
|
743
923
|
/* Contrast::Components::Scope::EXECUTION_CONTEXT => {} */
|
744
924
|
rb_define_const(scope_mod, rb_const_ec, rb_hash_new());
|
745
|
-
/* Contrast::Components::Scope::MONITOR => Mutex.new */
|
925
|
+
/* Contrast::Components::Scope::MONITOR => Mutex.new.freeze */
|
746
926
|
rb_define_const(scope_mod, rb_const_mon, rb_mutex_new());
|
747
927
|
|
748
|
-
|
928
|
+
/**
|
749
929
|
* @module Contrast::Components::Scope::InstanceMethods
|
750
930
|
*/
|
751
931
|
|
@@ -780,13 +960,16 @@ void Init_cs__scope() {
|
|
780
960
|
rb_define_method(scope_inst_methods, rb_method_name_exit_scope,
|
781
961
|
inst_methods_exit_scope, 1);
|
782
962
|
|
783
|
-
|
963
|
+
/**
|
784
964
|
* @module Contrast::Components::Scope
|
785
965
|
*/
|
786
966
|
rb_define_singleton_method(scope_mod, "sweep_dead_ecs",
|
787
967
|
scope_mod_sweep_dead_ecs, 0);
|
968
|
+
/* Contrast::Components::Scope#cs__with_app_scope? */
|
969
|
+
rb_define_singleton_method(scope_mod, "cs__with_app_scope?",
|
970
|
+
contrast_scope_application_update, 0);
|
788
971
|
|
789
|
-
|
972
|
+
/**
|
790
973
|
* @module Contrast::Components::Scope::InstanceMethods
|
791
974
|
*/
|
792
975
|
rb_define_method(scope_inst_methods, "contrast_enter_method_scopes!",
|