Sha256: ff1c9ca2bb36ba0278d79a8eb1d2e4ee05158d50dbf3423166c407da58bf9bf8

Contents?: true

Size: 1.06 KB

Versions: 7

Compression:

Stored size: 1.06 KB

Contents

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

#include "cs__assess_string_interpolation26.h"
#include "../cs__common/cs__common.h"
#include <funchook.h>
#include <ruby.h>

static VALUE rb_str_concat_literals_hook(size_t num, VALUE *strary) {
    VALUE result = rb_str_concat_literals_original(num, strary);
    VALUE rb_params = rb_ary_new_from_values((int)num, strary);
    rb_funcall(string_class, track_interpolation, 2, rb_params, result);
    return result;
}

static int install_hooks() {
    funchook_t *funchook = funchook_create();

    rb_str_concat_literals_original = rb_str_concat_literals;
    funchook_prepare(funchook, (void **)&rb_str_concat_literals_original,
                     rb_str_concat_literals_hook);

    funchook_install(funchook, 0);
    return 0;
}

void Init_cs__assess_string_interpolation26(void) {
    string_class = rb_define_class_under(core_assess, "StringPropagator", rb_cObject);
    track_interpolation = rb_intern("track_interpolation");
    install_hooks();
}

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
contrast-agent-3.10.2 ext/cs__assess_string_interpolation26/cs__assess_string_interpolation26.c
contrast-agent-3.10.1 ext/cs__assess_string_interpolation26/cs__assess_string_interpolation26.c
contrast-agent-3.10.0 ext/cs__assess_string_interpolation26/cs__assess_string_interpolation26.c
contrast-agent-3.9.1 ext/cs__assess_string_interpolation26/cs__assess_string_interpolation26.c
contrast-agent-3.9.0 ext/cs__assess_string_interpolation26/cs__assess_string_interpolation26.c
contrast-agent-3.8.5 ext/cs__assess_string_interpolation26/cs__assess_string_interpolation26.c
contrast-agent-3.8.4 ext/cs__assess_string_interpolation26/cs__assess_string_interpolation26.c