1

由于pre-commit 钩子甚至不允许bandit发出警告和提交,我需要找到一种方法来从 python 脚本执行 bash 命令而不会抱怨 bandit。

强盗-lintings

使用subprocess python 包,到目前为止,bandit 一直在抱怨,不管我做什么。我使用了“.run()”、“.check_call()”、“.Popen()”、.. 都没有shell=True,但还是无济于事。

如果有子流程的安全替代方案,我也会感兴趣,但我确信它也必须以某种方式与子流程一起使用。


强盗不接受的示例:

import shlex
import subprocess

...

bash_command = (
    f'aws s3 cp {source_dir} s3://{target_bucket_name} --recursive'
    f' --profile {profile_name}')
subprocess.check_call(shlex.split(bash_command), text=True)
4

0 回答 0