無法理解在實踐中如何使用以下命令行選項。無法理解在實踐中如何使用命令行選項「-T」
-T[level=1]
我試過這段代碼:
#commandoptionstest.rb
puts "hello world"
各種SAFE
層次:
輸出正確
@ubuntu:~/script$ ruby -x commandoptionstest.rb
# => hello world
爲什麼出錯?我需要做什麼commandoptionstest.rb
允許-x
與-T
?
@ubuntu:~/script$ ruby -x -T commandoptionstest.rb
# => ruby: no -x allowed in tainted mode (SecurityError)
輸出即將
@ubuntu:~/script$ ruby -T commandoptionstest.rb
# => hello world
輸出即將
@ubuntu:~/script$ ruby -T1 commandoptionstest.rb
# => hello world
輸出即將
@ubuntu:~/script$ ruby -T2 commandoptionstest.rb
# => hello world
輸出即將
@ubuntu:~/script$ ruby -T3 commandoptionstest.rb
# => hello world
再次爲什麼錯誤?
@ubuntu:~/script$ ruby -T4 commandoptionstest.rb
# => commandoptionstest.rb:15:in `write': Insecure operation `write' at level 4 (SecurityError)
# from commandoptionstest.rb:15:in `puts'
# from commandoptionstest.rb:15:in `puts'
# from commandoptionstest.rb:15:in `<main>'
與上面的代碼的幫助,請你解釋爲什麼SAFE
水平1
,2
,3
打印"hello world"
,而4
SAFE
水平呢?要允許SAFE
級別4
的寫入操作,這裏應該做什麼?
你沒有看到你重複的問題嗎? – hd1 2013-02-13 22:27:44
@ hd1 IMO這不是一個騙局,因爲'-T'影響的不僅僅是對象污點。 – 2013-02-13 22:29:40
請停止投票結束重複:不是。相關問題特別針對污點對象提出問題。 '-T'命令行選項設置了Ruby解釋器的'$ SAFE'級別,它比簡單地定義是否,以及何時以及什麼時候對象被污染了更多。 – 2013-02-13 23:21:38