本文整理汇总了Python中sandbox.Sandbox.policy方法的典型用法代码示例。如果您正苦于以下问题:Python Sandbox.policy方法的具体用法?Python Sandbox.policy怎么用?Python Sandbox.policy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sandbox.Sandbox
的用法示例。
在下文中一共展示了Sandbox.policy方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_clone
# 需要导入模块: from sandbox import Sandbox [as 别名]
# 或者: from sandbox.Sandbox import policy [as 别名]
def test_clone(self):
s = Sandbox(self.task[2])
s.policy = MinimalPolicy()
s.run()
self.assertEqual(s.status, Sandbox.S_STATUS_FIN)
self.assertEqual(s.result, Sandbox.S_RESULT_RF)
pass
示例2: test_open
# 需要导入模块: from sandbox import Sandbox [as 别名]
# 或者: from sandbox.Sandbox import policy [as 别名]
def test_open(self):
s = Sandbox(self.task[0])
s.policy = SelectiveOpenPolicy(s, set([(b"/dev/zero", O_RDONLY), ]))
s.run()
self.assertEqual(s.status, Sandbox.S_STATUS_FIN)
self.assertEqual(s.result, Sandbox.S_RESULT_OK)
pass
示例3: test_sigbus_adraln
# 需要导入模块: from sandbox import Sandbox [as 别名]
# 或者: from sandbox.Sandbox import policy [as 别名]
def test_sigbus_adraln(self):
s = Sandbox(self.task[0])
s.policy = MinimalPolicy()
s.run()
self.assertEqual(s.status, Sandbox.S_STATUS_FIN)
self.assertEqual(s.result, Sandbox.S_RESULT_RT)
d = s.probe(False)
self.assertEqual(d['signal_info'], (SIGBUS, BUS_ADRALN))
pass
示例4: test_rlimit_cpu
# 需要导入模块: from sandbox import Sandbox [as 别名]
# 或者: from sandbox.Sandbox import policy [as 别名]
def test_rlimit_cpu(self):
s = Sandbox(self.task[6])
s.policy = AllowResLimitPolicy(s)
s.run()
self.assertEqual(s.status, Sandbox.S_STATUS_FIN)
self.assertEqual(s.result, Sandbox.S_RESULT_RT)
d = s.probe(False)
self.assertEqual(d['signal_info'], (SIGXCPU, SI_KERNEL))
pass
示例5: test_sigtrap_user
# 需要导入模块: from sandbox import Sandbox [as 别名]
# 或者: from sandbox.Sandbox import policy [as 别名]
def test_sigtrap_user(self):
s = Sandbox(self.task[4])
s.policy = KillerPolicy(s, SIGTRAP)
s.run()
self.assertEqual(s.status, Sandbox.S_STATUS_FIN)
self.assertEqual(s.result, Sandbox.S_RESULT_RT)
d = s.probe(False)
self.assertEqual(d['signal_info'], (SIGTRAP, SI_USER))
pass
示例6: test_sigkill
# 需要导入模块: from sandbox import Sandbox [as 别名]
# 或者: from sandbox.Sandbox import policy [as 别名]
def test_sigkill(self):
s = Sandbox(self.task[4])
s.policy = KillerPolicy(s, SIGKILL)
s.run()
self.assertEqual(s.status, Sandbox.S_STATUS_FIN)
self.assertEqual(s.result, Sandbox.S_RESULT_RT)
d = s.probe(False)
self.assertEqual(d['signal_info'][0], SIGKILL)
pass
示例7: test_sigsegv_accerr
# 需要导入模块: from sandbox import Sandbox [as 别名]
# 或者: from sandbox.Sandbox import policy [as 别名]
def test_sigsegv_accerr(self):
s = Sandbox(self.task[3])
s.policy = MinimalPolicy()
s.run()
self.assertEqual(s.status, Sandbox.S_STATUS_FIN)
self.assertEqual(s.result, Sandbox.S_RESULT_RT)
d = s.probe(False)
self.assertEqual(d['signal_info'], (SIGSEGV, SEGV_ACCERR))
pass
示例8: test_sigfpe_intdiv
# 需要导入模块: from sandbox import Sandbox [as 别名]
# 或者: from sandbox.Sandbox import policy [as 别名]
def test_sigfpe_intdiv(self):
s = Sandbox(self.task[1])
s.policy = MinimalPolicy()
s.run()
self.assertEqual(s.status, Sandbox.S_STATUS_FIN)
self.assertEqual(s.result, Sandbox.S_RESULT_RT)
d = s.probe(False)
self.assertEqual(d['signal_info'], (SIGFPE, FPE_INTDIV))
pass
示例9: test_kill_ppid
# 需要导入模块: from sandbox import Sandbox [as 别名]
# 或者: from sandbox.Sandbox import policy [as 别名]
def test_kill_ppid(self):
s = Sandbox(self.task[0])
s.policy = AllowSelfKillPolicy(s)
s.run()
self.assertEqual(s.status, Sandbox.S_STATUS_FIN)
self.assertEqual(s.result, Sandbox.S_RESULT_RF)
d = s.probe(False)
sc = d['syscall_info'] if machine() == 'x86_64' else d['syscall_info'][0]
self.assertTrue(sc in AllowSelfKillPolicy.SC_kill)
pass
示例10: test_ml_static
# 需要导入模块: from sandbox import Sandbox [as 别名]
# 或者: from sandbox.Sandbox import policy [as 别名]
def test_ml_static(self):
s = Sandbox(self.task[0], quota=dict(wallclock=60000, cpu=2000, memory=2 ** 24))
s.policy = MinimalPolicy()
s.run()
self.assertEqual(s.status, Sandbox.S_STATUS_FIN)
self.assertEqual(s.result, Sandbox.S_RESULT_ML)
d = s.probe(False)
mem = d['mem_info'][1] * 1024
self.assertLess(s.quota[Sandbox.S_QUOTA_MEMORY], mem)
pass
示例11: test_int80_fork
# 需要导入模块: from sandbox import Sandbox [as 别名]
# 或者: from sandbox.Sandbox import policy [as 别名]
def test_int80_fork(self):
# syscall #2: (fork, i686) vs (open, x86_64)
s = Sandbox(self.task[1])
s.policy = MinimalPolicy()
s.run()
self.assertEqual(s.status, Sandbox.S_STATUS_FIN)
self.assertEqual(s.result, Sandbox.S_RESULT_RF)
d = s.probe(False)
self.assertEqual(d['syscall_info'], (2, 1))
pass
示例12: test_rlimit_fsz
# 需要导入模块: from sandbox import Sandbox [as 别名]
# 或者: from sandbox.Sandbox import policy [as 别名]
def test_rlimit_fsz(self):
s_wr = open(config.touch("rlimit_fsz.out"), "wb")
s = Sandbox(self.task[5], stdout=s_wr)
s.policy = AllowResLimitPolicy(s)
s.run()
s_wr.close()
self.assertEqual(s.status, Sandbox.S_STATUS_FIN)
self.assertEqual(s.result, Sandbox.S_RESULT_OL)
d = s.probe(False)
self.assertEqual(d['signal_info'], (SIGXFSZ, SI_USER))
pass
示例13: test_exec_rf
# 需要导入模块: from sandbox import Sandbox [as 别名]
# 或者: from sandbox.Sandbox import policy [as 别名]
def test_exec_rf(self):
# minimal policy forbids execve()
s = Sandbox(self.task[:])
s.policy = MinimalPolicy()
s.run()
self.assertEqual(s.status, Sandbox.S_STATUS_FIN)
self.assertEqual(s.result, Sandbox.S_RESULT_RF)
d = s.probe(False)
sc = d['syscall_info'] if machine() == 'x86_64' else d['syscall_info'][0]
self.assertTrue(sc in AllowExecOncePolicy.SC_execve)
pass
示例14: test_open_bogus
# 需要导入模块: from sandbox import Sandbox [as 别名]
# 或者: from sandbox.Sandbox import policy [as 别名]
def test_open_bogus(self):
# dumping bad address should cause RT not BP/IE
s = Sandbox(self.task[2])
s.policy = SelectiveOpenPolicy(s, set())
s.run()
self.assertEqual(s.status, Sandbox.S_STATUS_FIN)
self.assertEqual(s.result, Sandbox.S_RESULT_RT)
d = s.probe(False)
sc = d['syscall_info'] if machine() == 'x86_64' else d['syscall_info'][0]
self.assertTrue(sc in SelectiveOpenPolicy.SC_open)
pass
示例15: test_exec_nested
# 需要导入模块: from sandbox import Sandbox [as 别名]
# 或者: from sandbox.Sandbox import policy [as 别名]
def test_exec_nested(self):
# nested execve(): ./exec.exe ./exec.exe ./hello.exe
s = Sandbox([self.task[0], ] + self.task[:])
s.policy = AllowExecOncePolicy()
s.run()
self.assertEqual(s.status, Sandbox.S_STATUS_FIN)
self.assertEqual(s.result, Sandbox.S_RESULT_RF)
d = s.probe(False)
sc = d['syscall_info'] if machine() == 'x86_64' else d['syscall_info'][0]
self.assertTrue(sc in AllowExecOncePolicy.SC_execve)
pass