Sha256: a3c4493a36848d06ce25898e122d968ddf76fb36a979130cd1160e9c8ed5fb6b
Contents?: true
Size: 1.69 KB
Versions: 16
Compression:
Stored size: 1.69 KB
Contents
/* Copyright (c) 2022 Contrast Security, Inc. See * https://www.contrastsecurity.com/enduser-terms-0317a for more details. */ #include "cs__assess_array.h" #include "../cs__common/cs__common.h" #include <ruby.h> /* * If String#split is called without an argument, it defaults to use `$;`. * We have to make this patch in C so as not to change that value. * -HM */ static VALUE contrast_assess_array_join(const int argc, const VALUE *argv, const VALUE ary) { VALUE sep, result; /* We need to figure out the separator the join method actually used. */ /* First, check if one was provided. */ rb_scan_args(argc, argv, "01", &sep); /* Second, check to see if `$;` is set*/ if (NIL_P(sep)) { sep = rb_output_fs; } /* Finally, default to empty String. Implicit since nil.to_s is ''*/ /* call the Array.join but patched one */ result = rb_funcall2(ary, rb_sym_assess_array_join, argc, argv); /* call the Contrast::Extensions::Assess::ArrayPropagator#cs__track_join */ result = rb_funcall(array_propagator, rb_sym_assess_track_array_join, 3, ary, sep, result); return result; } void Init_cs__assess_array(void) { array_propagator = rb_define_class_under(core_assess, "ArrayPropagator", rb_cObject); rb_sym_assess_track_array_join = rb_intern("cs__track_join"); /* * Here we need to check before using the alias or prepend spec * This patch is happening here, we register the cs__track_join * method of the Array propagator, and call it here from Ruby. */ rb_sym_assess_array_join = contrast_register_patch("Array", "join", contrast_assess_array_join); }
Version data entries
16 entries across 16 versions & 1 rubygems