Sha256: 3584e2accb43e7518a94b1001b0cae3d603c38615448e458b82815d2ac64eccb

Contents?: true

Size: 1.58 KB

Versions: 6

Compression:

Stored size: 1.58 KB

Contents

/* Copyright (c) 2020 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 <ruby.h>

VALUE
contrast_patched_kernel_exec(const int argc, const VALUE *argv,
                             const VALUE self) {
    int nested_scope =
        RTEST(rb_funcall(contrast_patcher(), rb_sym_in_scope, 0));

    if (!nested_scope && argc > 0) {
        rb_funcall(contrast_patcher(), rb_sym_enter_scope, 0);
        VALUE data = argv[0];
        rb_funcall(kernel_propagator, exec_apply_trigger, 1, data);
        rb_funcall(contrast_patcher(), rb_sym_exit_scope, 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);
}

void Init_cs__assess_kernel(void) {
    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);

    /* 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

6 entries across 6 versions & 1 rubygems

Version Path
contrast-agent-3.13.2 ext/cs__assess_kernel/cs__assess_kernel.c
contrast-agent-3.13.1 ext/cs__assess_kernel/cs__assess_kernel.c
contrast-agent-3.13.0 ext/cs__assess_kernel/cs__assess_kernel.c
contrast-agent-3.12.2 ext/cs__assess_kernel/cs__assess_kernel.c
contrast-agent-3.12.1 ext/cs__assess_kernel/cs__assess_kernel.c
contrast-agent-3.12.0 ext/cs__assess_kernel/cs__assess_kernel.c