Files
vibe_coding/.cursor/rules/002-safety.mdc
2026-03-05 21:27:11 +08:00

76 lines
2.5 KiB
Plaintext
Raw 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.
---
description: "安全与权限边界 — 操作分级与敏感信息防护"
alwaysApply: true
---
# 🔒 Safety & Permissions
## 权限等级
| 等级 | 操作 | 审批 |
|------|------|------|
| 🟢 GREEN | 读取、查询、生成代码(不写入) | 无需 |
| 🟡 YELLOW | 创建/修改代码文件 | 说明影响 |
| 🟠 ORANGE | 删除文件、改配置、装依赖 | 需确认 |
| 🔴 RED | 数据库写入、部署、密钥操作 | 强制审批 |
## 敏感操作 — 必须确认
- 删除任何文件
- 修改 `.env*` / `package.json` / `jsconfig.json` / `docker-compose*`
- 修改 CI/CD 配置 (`.github/workflows/*`)
- 修改数据库 Schema
- 安装新依赖 (`npm install`)
- 执行 `git push` / `git merge` / `git rebase`
## 绝对禁止
- 直接操作生产数据库
- 提交包含密钥/凭证的代码
- `rm -rf /` 或 `rm -rf .`
- `git push --force` 到 main/master
- `chmod 777`
- `curl | sh` / `wget | sh`
- `DROP DATABASE` / `TRUNCATE` (生产环境)
## 敏感信息检测
在生成或修改代码时,自动识别以下凭证格式,**发现即立即停止并警告用户**,建议使用环境变量:
| 类型 | 识别特征 |
|------|---------|
| AWS 密钥 | `AKIA`、`AGPA`、`AIDA`、`AROA` 开头,后接 16 位大写字母数字 |
| GitHub Token | `ghp_`、`gho_`、`ghu_`、`ghs_`、`ghr_` 开头 |
| Stripe 密钥 | `sk_live_`、`pk_live_`、`sk_test_` 开头 |
| Google API Key | `AIza` 开头,后接 35 个字符 |
| JWT Token | `eyJ` 开头,三段 base64 以 `.` 分隔 |
| 私钥块 | `-----BEGIN` ... `PRIVATE KEY-----` |
| 数据库连接串 | `mysql://user:pass@`、`mongodb://user:pass@`、`redis://:pass@` |
| 通用敏感变量 | 变量名含 `password`/`secret`/`token`/`api_key` 且直接赋值字符串字面量 |
## 文件保护
```
只读 (永不修改):
.env* / *.pem / *.key / secrets/**
需确认才能修改:
package.json / jsconfig.json / composer.json
databases/migrations/ / .github/** / docker-compose*
禁止访问:
.git/config / *credentials* / *.secret
```
## 当前信任等级
> 手动切换:修改下方 `项目状态` 值即可调整权限上限。
**项目状态**: `new_project`
| 状态 | 权限上限 | 适用场景 |
|------|---------|---------|
| `new_project` | 🟡 YELLOW | 新项目初期,所有 ORANGE/RED 操作均需确认 |
| `established` | 🟠 ORANGE | 已有测试和 CI 的项目ORANGE 操作说明影响即可 |
| `trusted` | 🔴 RED | 成熟项目,仅 RED 操作需要确认 |