docs(10_Wiki): 위키 전체 재구성 — Topic_* 폴더를 4개 카테고리로 통합 + 대규모 중복 제거

Topic_Agent/Topic_Blog/Topics/Topics_Biz/Topics_Meeting/Topics_Rag의 마크다운 지식 문서를
Topic_General/Topic_Programming/Topic_Graphic/Topic_Business 4개 카테고리로 재분류.

- 중복 제거: frontmatter의 status:duplicate/merged + duplicate_of/redirect_to 필드로
  자기 자신을 중복으로 선언한 리다이렉트 stub 1032개 제거, 완전 동일 내용 파일 472개 제거,
  동일 파일명·다른 내용 충돌 시 더 큰(완전한) 버전만 유지(162개 제거) — 총 1639개 중복 제거.
- 분류: 폴더 단위로 명확한 항목(AI_and_ML/Coding/Architecture 등 → Programming,
  Comfyui/Visual_Effects → Graphic, Topics_Biz/Topics_Meeting/사업 등 → Business,
  Poetic_Blog_Writing/창의성/Game_Design 등 → General)은 폴더 우선순위로,
  나머지 혼재 폴더(Topic_Agent/Topic_Blog/Topics 루트/Thinking & Reasoning/Other/UI_UX_Assets)는
  title/tags 키워드 스코어링으로 파일 단위 분류(불명확한 경우 General로 폴백).
  원본 폴더명은 "From_*" 서브폴더로 보존해 추적 가능성 유지.
- 최종 배치: Programming 2784 / General 1608 / Graphic 285 / Business 249 = 4926개 문서.
- 에이전트 운영 상태(.astra/.agent/.obsidian/sessions/memory/_company/docs/lessons/_shared/src)는
  지식 콘텐츠가 아니므로 재분류 대상에서 제외하고 원위치 유지.
- Topics/Topic_email(상위 보호 폴더 Topic_email과 파일명 100% 중복) 삭제 — 보호 폴더 자체는 미변경.
- 완전히 비게 된 Topic_Agent/Topic_Blog/Topics_Biz/Topics_Rag 폴더 제거.
This commit is contained in:
Antigravity Agent
2026-07-05 00:33:48 +09:00
parent 1cfd3bbb56
commit 9148c358d0
6455 changed files with 1 additions and 86875 deletions
@@ -0,0 +1,221 @@
---
id: wiki-2026-0508-secrets-detection
title: Secrets Detection
category: 10_Wiki/Topics
status: verified
canonical_id: self
aliases: [Credential Scanning, Leaked Secrets, Git Secret Scanning]
duplicate_of: none
source_trust_level: A
confidence_score: 0.9
verification_status: applied
tags: [security, secrets, gitleaks, trufflehog, devsecops]
raw_sources: []
last_reinforced: 2026-05-10
github_commit: pending
tech_stack:
language: Go
framework: gitleaks
---
# Secrets Detection
## 매 한 줄
> **"매 secret 의 leak 은 git history 의 forever — 매 prevention(pre-commit) > detection(CI) > remediation(rotate + rewrite history)"**. 매 origin 은 2014 GitHub 의 AWS key 대량 leak; 매 modern state 는 gitleaks/trufflehog v3 (entropy + verifier), GitHub Push Protection, AI-aided context analysis (Claude Opus 4.7 으로 매 false positive triage).
## 매 핵심
### 매 detection 의 3 layer
- **Pre-commit (local)**: gitleaks pre-commit hook — 매 push 전 차단.
- **CI (PR)**: gitleaks/trufflehog GitHub Action — 매 PR diff scan.
- **Org-wide (continuous)**: GitHub Advanced Security secret scanning, GitGuardian, 매 historical scan.
### 매 detection 기법
- **Regex patterns**: AWS `AKIA[0-9A-Z]{16}`, GitHub `ghp_[A-Za-z0-9]{36}`.
- **Entropy analysis**: Shannon entropy > 4.5 base64-like.
- **Verification**: 매 detected key 를 actual API call 로 verify (live or revoked).
- **AI context analysis**: 매 LLM 으로 매 surrounding code + filename → false positive triage.
### 매 응용
1. Pre-commit gate (developer machine).
2. CI/CD PR check.
3. Org-wide historical audit.
4. Incident response (breach detected → rotate all).
## 💻 패턴
### 매 gitleaks pre-commit hook
```yaml
# .pre-commit-config.yaml
repos:
- repo: https://github.com/gitleaks/gitleaks
rev: v8.21.0
hooks:
- id: gitleaks
```
```bash
$ pre-commit install
$ git commit -m "feat: add api"
# gitleaks........Failed
# leak: aws-access-token at config/dev.env:3
```
### 매 gitleaks custom config (매 corp tokens)
```toml
# .gitleaks.toml
[extend]
useDefault = true
[[rules]]
id = "acme-internal-token"
description = "Acme internal API token"
regex = '''ACME_[A-Z0-9]{32}'''
keywords = ["acme_"]
entropy = 3.5
[[rules]]
id = "anthropic-api-key"
description = "Anthropic API key"
regex = '''sk-ant-[a-zA-Z0-9-_]{95,}'''
keywords = ["sk-ant-"]
[allowlist]
description = "test fixtures"
paths = [
'''(.*?)tests/fixtures/.*''',
'''(.*?)\.example\..*''',
]
```
### 매 GitHub Action (PR scan)
```yaml
# .github/workflows/secrets-scan.yml
name: Secrets Scan
on: [pull_request]
jobs:
gitleaks:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # 매 full history 필요
- uses: gitleaks/gitleaks-action@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITLEAKS_LICENSE: ${{ secrets.GITLEAKS_LICENSE }}
```
### 매 trufflehog v3 (with verification, 매 live key 만 alert)
```bash
# 매 git history 전체 scan, 매 verified live key 만
$ trufflehog git file://. --only-verified --json | jq .
# 매 GitHub org scan
$ trufflehog github --org=acme --token=$GH_PAT --only-verified
# 매 Docker image scan
$ trufflehog docker --image=acme/api:latest --only-verified
```
### 매 leaked key remediation (매 4-step)
```bash
# 1. 매 ROTATE first (매 코드 수정 전!) — 매 leak 시 attacker timer 시작
aws iam create-access-key --user-name svc-deploy
aws iam delete-access-key --access-key-id AKIA... --user-name svc-deploy
# 2. 매 history rewrite (BFG, 매 git filter-repo 보다 빠름)
bfg --replace-text passwords.txt repo.git
cd repo.git && git reflog expire --expire=now --all && git gc --prune=now --aggressive
# 3. 매 force push (매 collaborator 들에게 reclone 공지)
git push --force-with-lease
# 4. 매 audit logs — 매 attacker 가 이미 사용했는지
aws cloudtrail lookup-events --lookup-attributes \
AttributeKey=AccessKeyId,AttributeValue=AKIA...
```
### 매 AI-aided false-positive triage (Claude Opus 4.7)
```python
import anthropic
client = anthropic.Anthropic()
def triage(finding):
"""gitleaks finding -> {is_real_secret, severity, action}"""
prompt = f"""You are a security engineer. Decide if this is a real secret leak.
Finding:
File: {finding['file']}
Line: {finding['line']}
Match: {finding['match']}
Context (5 lines before/after):
{finding['context']}
Output JSON:
is_real_secret: bool
reason: str
severity: low|medium|high|critical
action: rotate|ignore|investigate
"""
msg = client.messages.create(
model="claude-opus-4-7",
max_tokens=512,
messages=[{"role": "user", "content": prompt}],
)
return msg.content[0].text
```
### 매 GitHub Push Protection (매 enable, free for public)
```bash
# 매 org-level: Settings → Code security → Push protection: Enabled
# 매 push 시 GitHub 가 server-side block — 매 partner pattern 매 200+ provider
gh api -X PATCH orgs/acme \
-F secret_scanning_push_protection_enabled_for_new_repositories=true
```
### 매 Doppler/Infisical (매 secret manager — 매 prevention root cause)
```bash
# 매 .env 의 X — 매 secret manager 에서 inject
$ doppler run -- python app.py
# 매 process env 에 inject, 매 disk 에 닿지 않음
```
## 매 결정 기준
| 상황 | Approach |
|---|---|
| 매 dev workstation | gitleaks pre-commit hook |
| 매 PR gate | gitleaks/trufflehog Action |
| 매 GitHub.com hosted | Push Protection enable |
| 매 large org historical | trufflehog --only-verified org-scan |
| 매 false-positive 많음 | Claude Opus 4.7 triage layer |
| 매 root-cause prevention | Doppler/Infisical, 매 .env 폐기 |
**기본값**: pre-commit (gitleaks) + CI (gitleaks Action) + GitHub Push Protection + Doppler.
## 🔗 Graph
- 부모: [[Application Security]] · [[CI/CD Pipeline & IDE Security Integration|DevSecOps]]
- 변형: [[Gitleaks]]
- Adjacent: [[Key Rotation]]
## 🤖 LLM 활용
**언제**: 매 finding triage (매 false positive vs real). 매 git history 의 narrative incident report.
**언제 X**: 매 detection 자체 — 매 deterministic regex/entropy 가 더 빠르고 cheap. 매 LLM 의 latency + cost 매 inline 부적절.
## ❌ 안티패턴
- **".env in repo"**: 매 매 the most common leak vector. 매 secret manager.
- **Commit-then-rotate skip**: 매 rotate skip — 매 history forever.
- **`.gitignore` rely**: 매 already-committed file 은 ignore 영향 X.
- **Force-push without coord**: 매 collaborator 의 reflog 에 leak 잔존.
- **Public-key panic**: 매 pub key 는 leak 의 X — 매 알고 commit.
## 🧪 검증 / 중복
- Verified (gitleaks docs v8.21, GitHub secret scanning docs 2026, OWASP Secrets Management Cheat Sheet).
- 신뢰도 A.
## 🕓 Changelog
| 날짜 | 변경 |
|---|---|
| 2026-05-08 | Phase 1 |
| 2026-05-10 | Manual cleanup — gitleaks + trufflehog + Push Protection + Claude triage |