当前位置: 首页>>代码示例>>Python>>正文


Python Sandbox.run方法代码示例

本文整理汇总了Python中sandbox.Sandbox.run方法的典型用法代码示例。如果您正苦于以下问题:Python Sandbox.run方法的具体用法?Python Sandbox.run怎么用?Python Sandbox.run使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sandbox.Sandbox的用法示例。


在下文中一共展示了Sandbox.run方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_clone

# 需要导入模块: from sandbox import Sandbox [as 别名]
# 或者: from sandbox.Sandbox import run [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
开发者ID:krishkoushik,项目名称:CVGWebsite,代码行数:9,代码来源:test_trace.py

示例2: test_open

# 需要导入模块: from sandbox import Sandbox [as 别名]
# 或者: from sandbox.Sandbox import run [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
开发者ID:krishkoushik,项目名称:CVGWebsite,代码行数:9,代码来源:test_trace.py

示例3: test_rlimit_cpu

# 需要导入模块: from sandbox import Sandbox [as 别名]
# 或者: from sandbox.Sandbox import run [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
开发者ID:krishkoushik,项目名称:CVGWebsite,代码行数:11,代码来源:test_signal.py

示例4: test_ol_file_write

# 需要导入模块: from sandbox import Sandbox [as 别名]
# 或者: from sandbox.Sandbox import run [as 别名]
 def test_ol_file_write(self):
     s = Sandbox(self.task[0], quota=dict(wallclock=60000, cpu=2000, disk=5))
     s.run()
     self.assertEqual(s.status, Sandbox.S_STATUS_FIN)
     self.assertEqual(s.result, Sandbox.S_RESULT_OL)
     with open(self.fout[0], "rb") as f:
         self.assertEqual(f.read(), b"Hello")
         f.close()
     pass
开发者ID:krishkoushik,项目名称:CVGWebsite,代码行数:11,代码来源:test_quota.py

示例5: test_sigtrap_user

# 需要导入模块: from sandbox import Sandbox [as 别名]
# 或者: from sandbox.Sandbox import run [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
开发者ID:krishkoushik,项目名称:CVGWebsite,代码行数:11,代码来源:test_signal.py

示例6: test_sigkill

# 需要导入模块: from sandbox import Sandbox [as 别名]
# 或者: from sandbox.Sandbox import run [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
开发者ID:krishkoushik,项目名称:CVGWebsite,代码行数:11,代码来源:test_signal.py

示例7: test_sigsegv_accerr

# 需要导入模块: from sandbox import Sandbox [as 别名]
# 或者: from sandbox.Sandbox import run [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
开发者ID:krishkoushik,项目名称:CVGWebsite,代码行数:11,代码来源:test_signal.py

示例8: test_sigfpe_intdiv

# 需要导入模块: from sandbox import Sandbox [as 别名]
# 或者: from sandbox.Sandbox import run [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
开发者ID:krishkoushik,项目名称:CVGWebsite,代码行数:11,代码来源:test_signal.py

示例9: test_sigbus_adraln

# 需要导入模块: from sandbox import Sandbox [as 别名]
# 或者: from sandbox.Sandbox import run [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
开发者ID:krishkoushik,项目名称:CVGWebsite,代码行数:11,代码来源:test_signal.py

示例10: test_int80_fork

# 需要导入模块: from sandbox import Sandbox [as 别名]
# 或者: from sandbox.Sandbox import run [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
开发者ID:krishkoushik,项目名称:CVGWebsite,代码行数:12,代码来源:test_trace.py

示例11: test_ml_static

# 需要导入模块: from sandbox import Sandbox [as 别名]
# 或者: from sandbox.Sandbox import run [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
开发者ID:krishkoushik,项目名称:CVGWebsite,代码行数:12,代码来源:test_quota.py

示例12: test_kill_ppid

# 需要导入模块: from sandbox import Sandbox [as 别名]
# 或者: from sandbox.Sandbox import run [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
开发者ID:krishkoushik,项目名称:CVGWebsite,代码行数:12,代码来源:test_signal.py

示例13: test_exec_rf

# 需要导入模块: from sandbox import Sandbox [as 别名]
# 或者: from sandbox.Sandbox import run [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
开发者ID:krishkoushik,项目名称:CVGWebsite,代码行数:13,代码来源:test_trace.py

示例14: test_exec_nested

# 需要导入模块: from sandbox import Sandbox [as 别名]
# 或者: from sandbox.Sandbox import run [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
开发者ID:krishkoushik,项目名称:CVGWebsite,代码行数:13,代码来源:test_trace.py

示例15: test_rlimit_fsz

# 需要导入模块: from sandbox import Sandbox [as 别名]
# 或者: from sandbox.Sandbox import run [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
开发者ID:krishkoushik,项目名称:CVGWebsite,代码行数:13,代码来源:test_signal.py


注:本文中的sandbox.Sandbox.run方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。