31 lines
585 B
Markdown
31 lines
585 B
Markdown
---
|
||
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 特定的安全指引 (若適用)。
|