Sha256: 2cb73c5cfde7d2c769e82ac5134cc297394242bb58703832e9539d52ff91abf4

Contents?: true

Size: 1.53 KB

Versions: 7

Compression:

Stored size: 1.53 KB

Contents

/* Copyright (c) 2020 Contrast Security, Inc.  See
 * https://www.contrastsecurity.com/enduser-terms-0317a for more details. */

#include "cs__assess_marshal_module.h"
#include "../cs__common/cs__common.h"
#include <ruby.h>

static VALUE contrast_assess_marshal_module_load(const int argc,
                                                 const VALUE *argv) {
    VALUE result;
    VALUE source_string;

    result = rb_call_super(argc, argv);

    if (argc >= 1) {
        source_string = argv[0];

        if (rb_respond_to(source_string, rb_sym_cs_tracked)) {
            VALUE tracked = rb_funcall(source_string, rb_sym_cs_tracked, 0);

            if (tracked == Qtrue) {
                VALUE skip = rb_funcall(contrast_patcher(),
                                        rb_sym_skip_assess_analysis, 0);

                if (skip == Qfalse) {
                    VALUE scope =
                        rb_funcall(contrast_patcher(), rb_sym_enter_scope, 0);
                    rb_funcall(marshal_module, rb_sym_assess_load_trigger_check,
                               2, source_string, result);
                    rb_funcall(contrast_patcher(), rb_sym_exit_scope, 1, scope);
                }
            }
        }
    }
    return result;
}

void Init_cs__assess_marshal_module(void) {
    rb_sym_assess_load_trigger_check = rb_intern("cs__load_trigger_check");

    contrast_register_singleton_prepend_patch("Marshal",
                                              "load",
                                              &contrast_assess_marshal_module_load);
}

Version data entries

7 entries across 7 versions & 1 rubygems

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