claude-code/claude-zh/rules/python/security.md

31 lines
585 B
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
paths:
- "**/*.py"
- "**/*.pyi"
---
# Python 安全性 (Security)
> 本檔案擴展了 [common/security.md](../common/security.md),包含 Python 特定內容。
## 金鑰管理 (Secret Management)
```python
import os
from dotenv import load_dotenv
load_dotenv()
api_key = os.environ["OPENAI_API_KEY"] # 若缺失則會引發 KeyError
```
## 安全掃描 (Security Scanning)
- 使用 **bandit** 進行靜態安全分析:
```bash
bandit -r src/
```
## 參考資源
參見技能 (Skill)`django-security`,獲取 Django 特定的安全指引 (若適用)。