Module: Contrast::Components::Scope::InstanceMethods
- Included in:
- Agent::Assess::Policy::Patcher, Agent::Assess::Policy::Propagator::Split, Agent::Middleware, Agent::Patching::Policy::AfterLoadPatch, Agent::Patching::Policy::Patch, Agent::Patching::Policy::Patcher, Agent::Patching::Policy::PolicyNode, Agent::Protect::Rule::Base, Agent::Reporting::ReporterClientUtils, Agent::Request, Agent::RequestContext, Agent::StaticAnalysis, Agent::Thread, Agent::TracePointHook, Contrast::Configuration, Contrast::Configuration, Extension::Assess::ArrayPropagator, Extension::Assess::FiberPropagator, Extension::Assess::MarshalPropagator, Extension::Assess::RegexpPropagator, Extension::Assess::StringPropagator, Framework::Rack::Patch::SessionCookie, Framework::Sinatra::Patch::EncryptedSessionCookie, Utils::InvalidConfigurationUtil, Utils::OS
- Defined in:
- lib/contrast/components/scope.rb,
ext/cs__scope/cs__scope.c
Overview
Methods defined in C:
For each instance method on a scope, define a forwarder to the scope on the current execution context’s scope. def scope_for_current_ec end;
all the methods bellow are used as forwarders to be executed in the current ec. exp: in_contrast_scope? => scope_for_current_ec.enter_contrast_scope!
Check if we are in contrast scope. def in_contrast_scope? end; check if we are in deserialization scope. def in_deserialization_scope? end; check if we are in split scope. def in_split_scope? end; enter contrast scope. def enter_contrast_scope! end; enter deserialization scope. def enter_deserialization_scope! end; enter split scope. def enter_split_scope! end; check split scope depth. def split_scope_depth end; exit contrast scope. def exit_contrast_scope! end; exit deserialization scope. def exit_deserialization_scope! end; exit split scope. def exit_split_scope! end; Static methods to be used, the cases are defined by the usage from the above methods
check if are in specific scope. def in_scope? name end; enter specific scope. def enter_scope! name end; exit specific scope. def exit_cope! name end;
Instance Method Summary collapse
-
#contrast_enter_method_scopes!(scopes_to_enter) ⇒ Object
method_policy#scopes_to_enter for the scope current method policy end end.
-
#contrast_exit_method_scopes!(scopes_to_exit) ⇒ Object
method_policy#scopes_to_exit for the scope current method policy end end.
-
#with_app_scope ⇒ Object
Enter app scope.
-
#with_contrast_scope ⇒ Object
Forwarder to execute block in contrast scope under current method execution context.
-
#with_deserialization_scope ⇒ Object
Forwarder to execute block in deserialization scope under current method execution context.
-
#with_split_scope ⇒ Object
Forwarder to execute block in split scope under current method execution context.
Instance Method Details
#contrast_enter_method_scopes!(scopes_to_enter) ⇒ Object
def enter_method_scope! scopes_to_enter scopes_to_enter.each do |scope|
enter_scope!(scope)
method_policy#scopes_to_enter for the scope current method policy
end
end
592 593 594 595 596 597 598 599 600 601 602 603 604 |
# File 'ext/cs__scope/cs__scope.c', line 592
VALUE inst_methods_enter_method_scope(VALUE self, VALUE scopes_to_enter) {
VALUE scopes_ary, scope;
scopes_ary = rb_ary_dup(scopes_to_enter);
scope = rb_ary_pop(scopes_ary);
while (!RB_TYPE_P(scope, T_NIL)) {
inst_methods_enter_scope(self, scope);
scope = rb_ary_pop(scopes_ary);
}
return scopes_to_enter;
}
|
#contrast_exit_method_scopes!(scopes_to_exit) ⇒ Object
def enter_method_scope! scopes_to_exit scopes_to_exit.each do |scope|
enter_scope!(scope)
method_policy#scopes_to_exit for the scope current method policy
end
end
620 621 622 623 624 625 626 627 628 629 630 631 632 |
# File 'ext/cs__scope/cs__scope.c', line 620
VALUE inst_methods_exit_method_scope(VALUE self, VALUE scopes_to_exit) {
VALUE scopes_ary, scope;
scopes_ary = rb_ary_dup(scopes_to_exit);
scope = rb_ary_pop(scopes_ary);
while (!RB_TYPE_P(scope, T_NIL)) {
inst_methods_exit_scope(self, scope);
scope = rb_ary_pop(scopes_ary);
}
return scopes_to_exit;
}
|
#with_app_scope ⇒ Object
Enter app scope
134 135 136 137 138 139 |
# File 'lib/contrast/components/scope.rb', line 134 def with_app_scope scope_for_current_ec.exit_contrast_scope! yield ensure scope_for_current_ec.enter_contrast_scope! end |
#with_contrast_scope ⇒ Object
Forwarder to execute block in contrast scope under current method execution context. On completion exits scope.
108 109 110 111 112 113 |
# File 'lib/contrast/components/scope.rb', line 108 def with_contrast_scope scope_for_current_ec.enter_contrast_scope! yield ensure scope_for_current_ec.exit_contrast_scope! end |
#with_deserialization_scope ⇒ Object
Forwarder to execute block in deserialization scope under current method execution context. On completion exits scope.
117 118 119 120 121 122 |
# File 'lib/contrast/components/scope.rb', line 117 def with_deserialization_scope scope_for_current_ec.enter_deserialization_scope! yield ensure scope_for_current_ec.exit_deserialization_scope! end |
#with_split_scope ⇒ Object
Forwarder to execute block in split scope under current method execution context. On completion exits scope.
126 127 128 129 130 131 |
# File 'lib/contrast/components/scope.rb', line 126 def with_split_scope scope_for_current_ec.enter_split_scope! yield ensure scope_for_current_ec.exit_split_scope! end |