简体   繁体   English

阻止嵌入式Python运行Shell命令?

[英]Preventing Embedded Python from Running Shell Commands?

I want to embed Python 3.x in our C++ application to allow scripting of maintenance and other tasks. 我想在我们的C ++应用程序中嵌入Python 3.x,以允许编写维护和其他任务的脚本。 It so far does everything we need including file manipulation. 到目前为止,我们所需的一切都包括文件操作在内。

The problem is that to meet some specifications (like PCI), we aren't allowed to arbitrarily run shell commands such as with subprocess.call or popen. 问题在于,为了满足某些规范(如PCI),我们不允许随意运行诸如subprocess.call或popen之类的shell命令。

Is there a way to prevent and similar calls from working in embedded Python? 有没有办法防止嵌入式Python中的类似调用?

一种选择是删除所有允许运行任意shell命令的模块,例如:subprocess.py *,os.py * ...,并仅包括允许最终用户立即访问的模块。

除非您的应用程序确实被锁定,否则我认为您无法阻止某人从任意目录(带有导入)加载其自己的python模块,因此,只要嵌入了python,我就无法阻止执行任意代码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM