Skip to content

Security: Mike4Ellis/liquid-memory

Security

SECURITY.md

Security Guidelines - Gre 安全规范

最后更新:2026-02-03 严重事件:API Key 误提交 GitHub 已修复


🚨 严重安全事件记录

事件:API Key 误提交 GitHub

时间:2026-02-03
发现者:莲桑
修复者:Gre

问题

  • .keys/ 目录包含 API Key 被提交到 GitHub
  • 提交哈希:fb44b5f 及之前

修复措施

  1. git rm -r --cached .keys - 从 Git 移除
  2. ✅ 添加 .keys/.gitignore
  3. ✅ 提交修复:34f4b65

教训

  • 提交前必须检查 git status 内容
  • 敏感文件必须第一时间加入 .gitignore
  • 使用 git add . 前确认不包含敏感文件

🔒 安全规范清单

提交前必须检查

# 1. 检查即将提交的内容
git status

# 2. 确认没有敏感文件
# - .keys/
# - .env
# - *.pem
# - *.key
# - config/secrets.json

# 3. 查看具体修改
git diff --cached

# 4. 确认无误后再提交
git commit -m "..."

敏感文件类型

类型 示例 处理方式
API Keys .keys/keys.json 加入 .gitignore,使用环境变量
环境变量 .env 加入 .gitignore,提供 .env.example
证书 *.pem, *.key 加入 .gitignore,使用密钥管理服务
配置文件 config/secrets.json 加入 .gitignore,使用模板文件
日志 *.log 加入 .gitignore
依赖 node_modules/ 加入 .gitignore

.gitignore 模板

# Security - Never commit
.keys/
.env
.env.local
.env.production
*.pem
*.key
*.p12
*.pfx
secrets.json
config/local*

# Dependencies
node_modules/
__pycache__/
*.pyc

# Logs
*.log
logs/

# OS
.DS_Store
Thumbs.db

# IDE
.vscode/
.idea/
*.swp
*.swo

🛡️ 预防措施

1. 项目初始化时

# 第一步:创建 .gitignore
echo ".keys/" >> .gitignore
echo ".env" >> .gitignore
git add .gitignore
git commit -m "chore: add .gitignore with security rules"

# 第二步:创建敏感目录
mkdir .keys
# 不要 git add .keys/

# 第三步:提供示例文件
cp .env .env.example
# 编辑 .env.example,移除真实值
git add .env.example
git commit -m "chore: add env example"

2. 日常开发

  • 绝不使用 git add . 不加检查
  • 绝不在代码中硬编码 API Key
  • 总是使用环境变量或密钥管理服务
  • 总是在提交前审查 git status

3. 代码审查

  • 检查 PR 是否包含敏感文件
  • 检查是否有硬编码的密钥
  • 检查 .gitignore 是否完整

📝 违规处理流程

如果发现敏感信息已提交:

  1. 立即撤销

    git rm -r --cached <敏感目录>
    echo "<敏感目录>/" >> .gitignore
    git add .gitignore
    git commit -m "security: remove sensitive data"
  2. 轮换密钥

    • 立即撤销已暴露的 API Key
    • 生成新的 API Key
    • 更新环境变量
  3. 审查历史

    # 检查是否还有其他提交包含敏感信息
    git log --all --full-history -- .keys/
  4. 记录事件

    • 更新 SECURITY.md
    • 记录教训
    • 改进流程

✅ 提交前检查清单

  • 运行 git status 检查文件
  • 确认没有 .keys/.env 等敏感文件
  • 检查代码中没有硬编码密钥
  • 审查 git diff 确认修改内容
  • 提交信息遵循规范

严格遵守安全规范,保护项目安全! 🔒🦎

There aren’t any published security advisories