Sha256: 6ac2e6173f38e5c8e487fa331faf36ce88420183bf76cae221b032f472635cad
Contents?: true
Size: 1.63 KB
Versions: 1
Compression:
Stored size: 1.63 KB
Contents
/* Copyright (c) 2020 Contrast Security, Inc. See * https://www.contrastsecurity.com/enduser-terms-0317a for more details. */ #include "cs__active_record_named.h" #include <ruby.h> #include "../cs__common/cs__common.h" VALUE contrast_assess_active_record_scope(const int argc, const VALUE *argv, const VALUE self) { /* * The ActiveRecord::Scoping::Named::ClassMethods#scope method allows for * the creation of methods at runtime. In order to trigger on interpolation * within that new method, we must rewrite the method body BEFORE it can be * used in the original #scope method, replacing interpolations with our * String append logic. As this deviates from standard Assess behavior * (changes the application behavior and acts on an input BEFORE it can be * passed to the original method), I think it deserves to be in a custom * call. -HM */ VALUE new_body, ret; VALUE new_args[3]; new_body = rb_funcall(self, rb_sym_assess_rewrite, 2, argv[0], argv[1]); new_args[0] = argv[0]; if (NIL_P(new_body)) { new_args[1] = argv[1]; } else { new_args[1] = new_body; } new_args[2] = argv[2]; ret = rb_funcall2(self, rb_sym_assess_scope, argc, new_args); return ret; } void Init_cs__assess_active_record_named(void) { rb_sym_assess_rewrite = rb_intern("_cs__rewrite"); rb_sym_assess_scope = contrast_register_patch("ActiveRecord::Scoping::Named::ClassMethods", "scope", contrast_assess_active_record_scope); }
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
contrast-agent-3.11.0 | ext/cs__assess_active_record_named/cs__active_record_named.c |