SOY NV AI
commited on
Commit
Β·
4434cfe
1
Parent(s):
208adf4
Security: Remove all hardcoded Hugging Face tokens from history
Browse files- fix_history.ps1 +62 -0
- fix_history.sh +30 -0
- remove_token_from_git_history.ps1 +68 -0
fix_history.ps1
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Git νμ€ν 리μμ Hugging Face ν ν° μ κ±° μ€ν¬λ¦½νΈ
|
| 2 |
+
|
| 3 |
+
$token = "YOUR_HUGGINGFACE_TOKEN_HERE"
|
| 4 |
+
$replacement = "YOUR_HUGGINGFACE_TOKEN_HERE"
|
| 5 |
+
|
| 6 |
+
$files = @(
|
| 7 |
+
"remove_token_from_history.ps1",
|
| 8 |
+
"EXAONE_μΆκ°_μλ΄.md",
|
| 9 |
+
"add_exaone_with_token.py",
|
| 10 |
+
"download_exaone_model.py",
|
| 11 |
+
"install_exaone_direct.py",
|
| 12 |
+
"install_exaone_simple.py"
|
| 13 |
+
)
|
| 14 |
+
|
| 15 |
+
Write-Host "Git νμ€ν 리μμ ν ν° μ κ±° μ€..." -ForegroundColor Yellow
|
| 16 |
+
|
| 17 |
+
# κ° νμΌμ λν΄ tree-filter μ€ν
|
| 18 |
+
foreach ($file in $files) {
|
| 19 |
+
Write-Host "μ²λ¦¬ μ€: $file" -ForegroundColor Cyan
|
| 20 |
+
|
| 21 |
+
# νμΌμ΄ μ‘΄μ¬νλμ§ νμΈ
|
| 22 |
+
if (Test-Path $file) {
|
| 23 |
+
# νμ¬ νμΌμμ ν ν° κ΅μ²΄
|
| 24 |
+
$content = Get-Content $file -Raw -Encoding UTF8
|
| 25 |
+
if ($content -match $token) {
|
| 26 |
+
$content = $content -replace [regex]::Escape($token), $replacement
|
| 27 |
+
Set-Content $file -Value $content -Encoding UTF8 -NoNewline
|
| 28 |
+
Write-Host " β νμ¬ νμΌμμ ν ν° κ΅μ²΄ μλ£" -ForegroundColor Green
|
| 29 |
+
}
|
| 30 |
+
}
|
| 31 |
+
}
|
| 32 |
+
|
| 33 |
+
# Git νμ€ν 리μμ ν ν° μ κ±°
|
| 34 |
+
Write-Host "`nGit νμ€ν 리 μ 리 μ€..." -ForegroundColor Yellow
|
| 35 |
+
|
| 36 |
+
# git filter-branchλ₯Ό μ¬μ©νμ¬ νμ€ν 리μμ ν ν° μ κ±°
|
| 37 |
+
$script = @"
|
| 38 |
+
if [ -f `$file ]; then
|
| 39 |
+
sed -i 's/$token/$replacement/g' `$file 2>/dev/null || \
|
| 40 |
+
(powershell -Command "(Get-Content '`$file') -replace '$token', '$replacement' | Set-Content '`$file'")
|
| 41 |
+
fi
|
| 42 |
+
"@
|
| 43 |
+
|
| 44 |
+
# Windowsμμλ git filter-branchκ° λ³΅μ‘νλ―λ‘,
|
| 45 |
+
# λμ κ° νμΌμ λν΄ κ°λ³μ μΌλ‘ μ²λ¦¬
|
| 46 |
+
foreach ($file in $files) {
|
| 47 |
+
Write-Host "νμ€ν 리 μ²λ¦¬ μ€: $file" -ForegroundColor Cyan
|
| 48 |
+
|
| 49 |
+
# git filter-branch μ€ν (tree-filter μ¬μ©)
|
| 50 |
+
$filterCmd = "if [ -f `"$file`" ]; then powershell -Command `"(Get-Content `"$file`" -Raw) -replace '$token', '$replacement' | Set-Content `"$file`" -NoNewline`"; fi"
|
| 51 |
+
|
| 52 |
+
git filter-branch --force --tree-filter $filterCmd --prune-empty --tag-name-filter cat -- --all 2>&1 | Out-Null
|
| 53 |
+
|
| 54 |
+
if ($LASTEXITCODE -eq 0) {
|
| 55 |
+
Write-Host " β νμ€ν 리μμ ν ν° μ κ±° μλ£" -ForegroundColor Green
|
| 56 |
+
} else {
|
| 57 |
+
Write-Host " β νμ€ν 리 μ²λ¦¬ μ€ν¨ (νμΌμ΄ νμ€ν 리μ μμ μ μμ)" -ForegroundColor Yellow
|
| 58 |
+
}
|
| 59 |
+
}
|
| 60 |
+
|
| 61 |
+
Write-Host "`nμλ£! μ΄μ git push --forceλ₯Ό μ€ννμΈμ." -ForegroundColor Green
|
| 62 |
+
|
fix_history.sh
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
|
| 3 |
+
TOKEN="YOUR_HUGGINGFACE_TOKEN_HERE"
|
| 4 |
+
REPLACEMENT="YOUR_HUGGINGFACE_TOKEN_HERE"
|
| 5 |
+
|
| 6 |
+
FILES=(
|
| 7 |
+
"remove_token_from_history.ps1"
|
| 8 |
+
"EXAONE_μΆκ°_μλ΄.md"
|
| 9 |
+
"add_exaone_with_token.py"
|
| 10 |
+
"download_exaone_model.py"
|
| 11 |
+
"install_exaone_direct.py"
|
| 12 |
+
"install_exaone_simple.py"
|
| 13 |
+
)
|
| 14 |
+
|
| 15 |
+
echo "Git νμ€ν 리μμ ν ν° μ κ±° μ€..."
|
| 16 |
+
|
| 17 |
+
for file in "${FILES[@]}"; do
|
| 18 |
+
echo "μ²λ¦¬ μ€: $file"
|
| 19 |
+
|
| 20 |
+
# PowerShellμ μ¬μ©νμ¬ νμΌ λ΄μ© κ΅μ²΄
|
| 21 |
+
git filter-branch --force --tree-filter \
|
| 22 |
+
"if [ -f \"$file\" ]; then \
|
| 23 |
+
powershell -Command \"(Get-Content '$file' -Raw) -replace '$TOKEN', '$REPLACEMENT' | Set-Content '$file' -NoNewline\" 2>/dev/null || \
|
| 24 |
+
sed -i 's/$TOKEN/$REPLACEMENT/g' \"$file\" 2>/dev/null; \
|
| 25 |
+
fi" \
|
| 26 |
+
--prune-empty --tag-name-filter cat -- --all 2>&1 | grep -E "(Rewrite|Already)" || true
|
| 27 |
+
done
|
| 28 |
+
|
| 29 |
+
echo "μλ£!"
|
| 30 |
+
|
remove_token_from_git_history.ps1
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Git νμ€ν 리μμ ν ν°μ μμ ν μ κ±°νλ μ€ν¬λ¦½νΈ
|
| 2 |
+
# μ΄ μ€ν¬λ¦½νΈλ λ¬Έμ κ° λλ νμΌλ€μ Git νμ€ν 리μμ μμ ν μ κ±°ν©λλ€.
|
| 3 |
+
|
| 4 |
+
$env:FILTER_BRANCH_SQUELCH_WARNING = "1"
|
| 5 |
+
|
| 6 |
+
$files = @(
|
| 7 |
+
"remove_token_from_history.ps1",
|
| 8 |
+
"add_exaone_with_token.py",
|
| 9 |
+
"download_exaone_model.py",
|
| 10 |
+
"install_exaone_direct.py",
|
| 11 |
+
"install_exaone_simple.py"
|
| 12 |
+
)
|
| 13 |
+
|
| 14 |
+
Write-Host "Git νμ€ν 리μμ ν ν°μ΄ ν¬ν¨λ νμΌ μ κ±° μ€..." -ForegroundColor Yellow
|
| 15 |
+
Write-Host "μ£Όμ: μ΄ μμ
μ Git νμ€ν 리λ₯Ό λ€μ μμ±ν©λλ€." -ForegroundColor Red
|
| 16 |
+
|
| 17 |
+
# κ° νμΌμ λν΄ Git νμ€ν 리μμ μ κ±°
|
| 18 |
+
foreach ($file in $files) {
|
| 19 |
+
Write-Host "`nμ²λ¦¬ μ€: $file" -ForegroundColor Cyan
|
| 20 |
+
|
| 21 |
+
# νμΌμ΄ μ‘΄μ¬νλμ§ νμΈ
|
| 22 |
+
if (Test-Path $file) {
|
| 23 |
+
# νμ¬ νμΌμμ ν ν°μ΄ μλμ§ νμΈ
|
| 24 |
+
$content = Get-Content $file -Raw -Encoding UTF8 -ErrorAction SilentlyContinue
|
| 25 |
+
if ($content -and $content -match "YOUR_HUGGINGFACE_TOKEN_HERE") {
|
| 26 |
+
Write-Host " νμ¬ νμΌμμ ν ν° λ°κ²¬, μ κ±° μ€..." -ForegroundColor Yellow
|
| 27 |
+
$content = $content -replace [regex]::Escape("YOUR_HUGGINGFACE_TOKEN_HERE"), "YOUR_HUGGINGFACE_TOKEN_HERE"
|
| 28 |
+
Set-Content $file -Value $content -Encoding UTF8 -NoNewline
|
| 29 |
+
Write-Host " β νμ¬ νμΌμμ ν ν° μ κ±° μλ£" -ForegroundColor Green
|
| 30 |
+
}
|
| 31 |
+
}
|
| 32 |
+
|
| 33 |
+
# Git νμ€ν 리μμ νμΌ μ κ±° (ν ν°μ΄ ν¬ν¨λ λͺ¨λ 컀λ°μμ)
|
| 34 |
+
Write-Host " Git νμ€ν 리μμ μ κ±° μ€..." -ForegroundColor Yellow
|
| 35 |
+
|
| 36 |
+
# git filter-branchλ₯Ό μ¬μ©νμ¬ νμΌμ νμ€ν 리μμ μ κ±°
|
| 37 |
+
$result = git filter-branch --force --index-filter "git rm --cached --ignore-unmatch `"$file`"" --prune-empty --tag-name-filter cat -- --all 2>&1
|
| 38 |
+
|
| 39 |
+
if ($LASTEXITCODE -eq 0) {
|
| 40 |
+
Write-Host " β Git νμ€ν 리μμ μ κ±° μλ£" -ForegroundColor Green
|
| 41 |
+
} else {
|
| 42 |
+
Write-Host " β νμ€ν 리 μ²λ¦¬ μ€ν¨ λλ νμΌμ΄ νμ€ν 리μ μμ" -ForegroundColor Yellow
|
| 43 |
+
}
|
| 44 |
+
}
|
| 45 |
+
|
| 46 |
+
# EXAONE_μΆκ°_μλ΄.md νμΌ μ²λ¦¬ (νκΈ νμΌλͺ
)
|
| 47 |
+
Write-Host "`nμ²λ¦¬ μ€: EXAONE_μΆκ°_μλ΄.md" -ForegroundColor Cyan
|
| 48 |
+
|
| 49 |
+
if (Test-Path "EXAONE_μΆκ°_μλ΄.md") {
|
| 50 |
+
$content = Get-Content "EXAONE_μΆκ°_μλ΄.md" -Raw -Encoding UTF8 -ErrorAction SilentlyContinue
|
| 51 |
+
if ($content -and $content -match "YOUR_HUGGINGFACE_TOKEN_HERE") {
|
| 52 |
+
Write-Host " νμ¬ νμΌμμ ν ν° λ°κ²¬, μ κ±° μ€..." -ForegroundColor Yellow
|
| 53 |
+
$content = $content -replace [regex]::Escape("YOUR_HUGGINGFACE_TOKEN_HERE"), "YOUR_HUGGINGFACE_TOKEN_HERE"
|
| 54 |
+
Set-Content "EXAONE_μΆκ°_μλ΄.md" -Value $content -Encoding UTF8 -NoNewline
|
| 55 |
+
Write-Host " β νμ¬ νμΌμμ ν ν° μ κ±° μλ£" -ForegroundColor Green
|
| 56 |
+
}
|
| 57 |
+
}
|
| 58 |
+
|
| 59 |
+
# Git νμ€ν 리 μ 리
|
| 60 |
+
Write-Host "`nGit νμ€ν 리 μ 리 μ€..." -ForegroundColor Yellow
|
| 61 |
+
git reflog expire --expire=now --all
|
| 62 |
+
git gc --prune=now --aggressive
|
| 63 |
+
|
| 64 |
+
Write-Host "`nμλ£!" -ForegroundColor Green
|
| 65 |
+
Write-Host "μ΄μ λ€μ λͺ
λ Ήμ΄λ‘ κ°μ νΈμνμΈμ:" -ForegroundColor Yellow
|
| 66 |
+
Write-Host " git push origin master --force" -ForegroundColor Cyan
|
| 67 |
+
Write-Host " git push space master:main --force" -ForegroundColor Cyan
|
| 68 |
+
|