我尝试写剧本,将运行我所有的自动测试和检查故障,水木清华这样的(保护脚本只需运行与“红宝石file.rb”和解析输出测试):从黑客(读目录,修改文件)
def failures?(test_file)
io = IO.popen("ruby #{test_file}")
log = io.readlines
io.close
# parsing output for failures "1 tests, 1 assertions, 0 failures, 0 errors"
log.last.split(',').select{ |s| s =~ /failures/ }.first[/\d+/] != "0"
end
puts failures?("test.rb")
但有人可以轻松地放置在“test_file里面”的一些恶意代码和粉碎一切:
Dir.glob("*")
Dir.mkdir("HACK_DIR")
File.delete("some_file")
的目的是保护Ruby脚本从这些黑客的方式吗?
不同的操作系统有不同的权限模型。你在使用哪种操作系统? – 2012-03-04 18:11:40
我只能重复一遍:如果你想要安全,不要按照接受的答案给出的建议。你会被黑客入侵。 – 2012-03-04 19:21:20