/* Copyright (c) 2020 Contrast Security, Inc. See * https://www.contrastsecurity.com/enduser-terms-0317a for more details. */ #include "cs__common.h" #include /* Globals */ /* These are defined w/ `extern` in the header */ VALUE contrast, agent, patching, policy, assess; VALUE core_extensions, core_assess; VALUE assess_policy, assess_propagator; VALUE rb_sym_enter_scope; VALUE rb_sym_exit_scope; VALUE rb_sym_in_scope; VALUE rb_sym_skip_contrast_analysis; VALUE rb_sym_skip_assess_analysis; VALUE rb_sym_method; VALUE rb_sym_cs_tracked; /* end globals */ void contrast_alias_method(const VALUE target, const char *to, const char *from) { rb_funcall(target, cs__send_method, 3, cs__alias_method_sym, ID2SYM(rb_intern(to)), ID2SYM(rb_intern(from))); } VALUE contrast_patcher() { return patcher; } void Init_cs__common(void) { cs__send_method = rb_intern("send"); cs__alias_method_sym = ID2SYM(rb_intern("alias_method")); /* Define symbols */ rb_sym_enter_scope = rb_intern("enter_contrast_scope!"); rb_sym_exit_scope = rb_intern("exit_contrast_scope!"); rb_sym_in_scope = rb_intern("in_contrast_scope?"); rb_sym_skip_contrast_analysis = rb_intern("skip_contrast_analysis?"); rb_sym_skip_assess_analysis = rb_intern("skip_assess_analysis?"); rb_sym_method = rb_intern("__method__"); rb_sym_cs_tracked = rb_intern("cs__tracked?"); /* Ensure definition of core Contrast instrumentation modules */ contrast = rb_define_module("Contrast"); agent = rb_define_module_under(contrast, "Agent"); assess = rb_define_module_under(agent, "Assess"); patching = rb_define_module_under(agent, "Patching"); policy = rb_define_module_under(patching, "Policy"); patcher = rb_define_module_under(policy, "Patch"); assess_policy = rb_define_module_under(assess, "Policy"); assess_propagator = rb_define_module_under(assess_policy, "Propagator"); core_extensions = rb_define_module_under(contrast, "CoreExtensions"); core_assess = rb_define_module_under(core_extensions, "Assess"); }