| 层次 | 提交前(pre-commit)、推送时(平台扫描)、历史(全量扫描) |
|---|---|
| 处置 | 判定有效性 → 立即轮换 → 清理历史(视情况) |
| 姿势 | 密钥「进过」仓库就视为已泄露,不要赌是否被看到 |
全历史扫描
全历史扫描
gitleaks detect --source . --redact
# 平台侧:
# GitHub → Settings → Code security → Secret scanning发现密钥后应优先轮换,而不是删文件:删除不能撤回已发生的暴露。
对仓库内容与历史做密钥检测:平台内置扫描(GitHub secret scanning / GitLab secret detection)叠加预提交钩子,发现即轮换。
| 层次 | 提交前(pre-commit)、推送时(平台扫描)、历史(全量扫描) |
|---|---|
| 处置 | 判定有效性 → 立即轮换 → 清理历史(视情况) |
| 姿势 | 密钥「进过」仓库就视为已泄露,不要赌是否被看到 |
gitleaks detect --source . --redact
# 平台侧:
# GitHub → Settings → Code security → Secret scanning