mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* object.c (rb_obj_untrusted): new method Object#untrusted?.
(rb_obj_untrust): new method Object#untrust. (rb_obj_trust): new method Object#trust. * array.c, debug.c, time.c, include/ruby/ruby.h, re.c, variable.c, string.c, io.c, dir.c, vm_method.c, struct.c, class.c, hash.c, ruby.c, marshal.c: fixes for Object#untrusted?. * test/ruby/test_module.rb, test/ruby/test_array.rb, test/ruby/test_object.rb, test/ruby/test_string.rb, test/ruby/test_marshal.rb, test/ruby/test_hash.rb: added tests for Object#untrusted?. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18568 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
55c141c624
commit
f433d710d0
23 changed files with 364 additions and 88 deletions
|
@ -108,7 +108,8 @@ rb_add_method(VALUE klass, ID mid, NODE * node, int noex)
|
|||
if (NIL_P(klass)) {
|
||||
klass = rb_cObject;
|
||||
}
|
||||
if (rb_safe_level() >= 4 && (klass == rb_cObject || !OBJ_TAINTED(klass))) {
|
||||
if (rb_safe_level() >= 4 &&
|
||||
(klass == rb_cObject || !OBJ_UNTRUSTED(klass))) {
|
||||
rb_raise(rb_eSecurityError, "Insecure: can't define method");
|
||||
}
|
||||
if (!FL_TEST(klass, FL_SINGLETON) &&
|
||||
|
@ -307,7 +308,7 @@ remove_method(VALUE klass, ID mid)
|
|||
if (klass == rb_cObject) {
|
||||
rb_secure(4);
|
||||
}
|
||||
if (rb_safe_level() >= 4 && !OBJ_TAINTED(klass)) {
|
||||
if (rb_safe_level() >= 4 && !OBJ_UNTRUSTED(klass)) {
|
||||
rb_raise(rb_eSecurityError, "Insecure: can't remove method");
|
||||
}
|
||||
if (OBJ_FROZEN(klass))
|
||||
|
@ -474,7 +475,7 @@ rb_undef(VALUE klass, ID id)
|
|||
if (rb_vm_cbase() == rb_cObject && klass == rb_cObject) {
|
||||
rb_secure(4);
|
||||
}
|
||||
if (rb_safe_level() >= 4 && !OBJ_TAINTED(klass)) {
|
||||
if (rb_safe_level() >= 4 && !OBJ_UNTRUSTED(klass)) {
|
||||
rb_raise(rb_eSecurityError, "Insecure: can't undef `%s'",
|
||||
rb_id2name(id));
|
||||
}
|
||||
|
@ -810,7 +811,7 @@ rb_mod_alias_method(VALUE mod, VALUE newname, VALUE oldname)
|
|||
static void
|
||||
secure_visibility(VALUE self)
|
||||
{
|
||||
if (rb_safe_level() >= 4 && !OBJ_TAINTED(self)) {
|
||||
if (rb_safe_level() >= 4 && !OBJ_UNTRUSTED(self)) {
|
||||
rb_raise(rb_eSecurityError,
|
||||
"Insecure: can't change method visibility");
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue