Sha256: f93524bff6458879c85171e131a173972b3f1685dfd8408df787666cd4f1cff3
Contents?: true
Size: 1.87 KB
Versions: 15
Compression:
Stored size: 1.87 KB
Contents
/* Copyright (c) 2022 Contrast Security, Inc. See * https://www.contrastsecurity.com/enduser-terms-0317a for more details. */ #include "cs__assess_kernel.h" #include "../cs__common/cs__common.h" #include "../cs__scope/cs__scope.h" #include <ruby.h> VALUE contrast_patched_kernel_exec(const int argc, const VALUE *argv, const VALUE self) { VALUE nested_scope = inst_methods_in_cntr_scope(contrast_patcher(), 0); if (nested_scope == Qfalse && argc > 0) { /* enter scope */ inst_methods_enter_cntr_scope(contrast_patcher(), 0); VALUE data = argv[0]; rb_funcall(kernel_propagator, exec_apply_trigger, 1, data); /* exit scope */ inst_methods_exit_cntr_scope(contrast_patcher(), 0); } /* maybe this should be rb_funcall2. this works right now because *argv == * argv[0]. exec shouldn't ever be called with != 1 argc, so not a huge * problem */ return rb_funcall(self, rb_sym_assess_kernel_exec, argc, *argv); } /* Check and see if the Kernel#exec is already prepended */ VALUE contrast_is_kernel_exec_prepended() { return contrast_check_prepended( rb_const_get(rb_cObject, rb_intern("Kernel")), rb_sym_kernel_exec, Qfalse); } void Init_cs__assess_kernel(void) { VALUE rb_sym_kernel_exec = ID2SYM(rb_intern("exec")); kernel_propagator = rb_define_module_under(core_assess, "KernelPropagator"); exec_apply_trigger = rb_intern("apply_trigger"); rb_sym_assess_kernel_exec = contrast_register_patch("Kernel", "exec", contrast_patched_kernel_exec); /* check if prepended and register singleton patch if true */ if (contrast_is_kernel_exec_prepended() == Qtrue) { /* should return the same value as above */ rb_sym_assess_kernel_exec = contrast_register_singleton_patch( "Kernel", "exec", contrast_patched_kernel_exec); } }
Version data entries
15 entries across 15 versions & 1 rubygems