Tell if a certain operation is safe: : tainted « Class « Ruby






Tell if a certain operation is safe:



def code_is_safe?(code)
  code =~ /[`;*-]/ ? false : true
end

while x = gets
  x.untaint if code_is_safe?(x)
  next if x.tainted?
  puts "=> #{eval(x)}"
end

 








Related examples in the same category

1.Check if an object is considered tainted by using the tainted? method:
2.Force an object to be seen as untainted by calling the untaint method on the object.