Sha256: ba5f8a816ceadb45de59241cc3b07abb3b381a1dec873e70b6072f7aeb453c81

Contents?: true

Size: 1002 Bytes

Versions: 11

Compression:

Stored size: 1002 Bytes

Contents

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

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

static VALUE rb_yield_hook(VALUE val, const VALUE self) {
    VALUE method = rb_funcall(rb_mKernel, rb_sym_method, 0);

    if (method == split_method && RB_TYPE_P(val, T_STRING)) {
        rb_funcall(split_class, propagate_yield, 1, val);
    }
    VALUE result = rb_yield_original(val);
    return result;
}

static int install_yield_hooks() {
    rb_yield_original = rb_yield;
    patch_via_funchook(&rb_yield_original, &rb_yield_hook);
    return 0;
}

void Init_cs__assess_yield_track(void) {
    VALUE base = rb_define_class_under(assess_propagator, "Base", rb_cObject);
    split_class = rb_define_class_under(assess_propagator, "Split", base);
    propagate_yield = rb_intern("propagate_yield");
    split_method = ID2SYM(rb_intern("split"));
    install_yield_hooks();
}

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
contrast-agent-4.4.1 ext/cs__assess_yield_track/cs__assess_yield_track.c
contrast-agent-4.4.0 ext/cs__assess_yield_track/cs__assess_yield_track.c
contrast-agent-4.3.2 ext/cs__assess_yield_track/cs__assess_yield_track.c
contrast-agent-4.3.1 ext/cs__assess_yield_track/cs__assess_yield_track.c
contrast-agent-4.3.0 ext/cs__assess_yield_track/cs__assess_yield_track.c
contrast-agent-4.2.0 ext/cs__assess_yield_track/cs__assess_yield_track.c
contrast-agent-4.1.0 ext/cs__assess_yield_track/cs__assess_yield_track.c
contrast-agent-4.0.0 ext/cs__assess_yield_track/cs__assess_yield_track.c
contrast-agent-3.16.0 ext/cs__assess_yield_track/cs__assess_yield_track.c
contrast-agent-3.15.0 ext/cs__assess_yield_track/cs__assess_yield_track.c
contrast-agent-3.14.0 ext/cs__assess_yield_track/cs__assess_yield_track.c