推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
swt1993
V2EX  ›  Python

Python 如何避免注入恶意代码?

  •  
  •   swt1993 · Jun 6, 2018 · 3629 views
    This topic created in 2928 days ago, the information mentioned may be changed or developed.
    我有一个项目,需要接收 python 脚本,这些脚本都是字符串,我会对这些字符串进行编译然后执行。这是前提也是基础必要,如果在这种前提下,如何避免脚本中出现的恶意代码,例如写 while 死循环,创建文件,创建进程线程,或者通过 os,sys 模块调用系统功能?或者如何实现对脚本的检测,或者将整个编译过程放置一个沙盒中运行?有没有朋友可以提供些有用建议,万分感谢
    6 replies    2018-06-07 08:05:44 +08:00
    hahastudio
        1
    hahastudio  
       Jun 6, 2018
    swt1993
        2
    swt1993  
    OP
       Jun 6, 2018
    @hahastudio 感谢
    Hyponet
        3
    Hyponet  
       Jun 6, 2018
    可以使用扔到 docker 里执行,然后 wait 一个超时时间
    docker-py 很调几个 api 就能实现
    Hyponet
        4
    Hyponet  
       Jun 6, 2018
    @HypoChen fix 很调 /调用
    Greatshu
        5
    Greatshu  
       Jun 6, 2018
    OJ ?
    ybping
        6
    ybping  
       Jun 7, 2018 via iPhone
    @Greatshu OJ +1
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5378 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 51ms · UTC 08:49 · PVG 16:49 · LAX 01:49 · JFK 04:49
    ♥ Do have faith in what you're doing.