依赖安全扫描
# 使用 safety 扫描已知漏洞 pip install safety safety check # 使用 bandit 扫描代码安全问题 pip install bandit bandit -r myproject/
密钥管理
import os from cryptography.fernet import Fernet # 环境变量管理密钥 SECRET_KEY = os.getenv('SECRET_KEY') # 加密敏感数据 cipher = Fernet(SECRET_KEY.encode()) encrypted_data = cipher.encrypt(b"sensitive data")
转载请注明:周志洋的博客 » Python DevOps-安全实践