soyailabs / fix_history.ps1
SOY NV AI
Security: Remove all hardcoded Hugging Face tokens from history
4434cfe
raw
history blame
2.36 kB
# Git ํžˆ์Šคํ† ๋ฆฌ์—์„œ Hugging Face ํ† ํฐ ์ œ๊ฑฐ ์Šคํฌ๋ฆฝํŠธ
$token = "YOUR_HUGGINGFACE_TOKEN_HERE"
$replacement = "YOUR_HUGGINGFACE_TOKEN_HERE"
$files = @(
"remove_token_from_history.ps1",
"EXAONE_์ถ”๊ฐ€_์•ˆ๋‚ด.md",
"add_exaone_with_token.py",
"download_exaone_model.py",
"install_exaone_direct.py",
"install_exaone_simple.py"
)
Write-Host "Git ํžˆ์Šคํ† ๋ฆฌ์—์„œ ํ† ํฐ ์ œ๊ฑฐ ์ค‘..." -ForegroundColor Yellow
# ๊ฐ ํŒŒ์ผ์— ๋Œ€ํ•ด tree-filter ์‹คํ–‰
foreach ($file in $files) {
Write-Host "์ฒ˜๋ฆฌ ์ค‘: $file" -ForegroundColor Cyan
# ํŒŒ์ผ์ด ์กด์žฌํ•˜๋Š”์ง€ ํ™•์ธ
if (Test-Path $file) {
# ํ˜„์žฌ ํŒŒ์ผ์—์„œ ํ† ํฐ ๊ต์ฒด
$content = Get-Content $file -Raw -Encoding UTF8
if ($content -match $token) {
$content = $content -replace [regex]::Escape($token), $replacement
Set-Content $file -Value $content -Encoding UTF8 -NoNewline
Write-Host " โœ“ ํ˜„์žฌ ํŒŒ์ผ์—์„œ ํ† ํฐ ๊ต์ฒด ์™„๋ฃŒ" -ForegroundColor Green
}
}
}
# Git ํžˆ์Šคํ† ๋ฆฌ์—์„œ ํ† ํฐ ์ œ๊ฑฐ
Write-Host "`nGit ํžˆ์Šคํ† ๋ฆฌ ์ •๋ฆฌ ์ค‘..." -ForegroundColor Yellow
# git filter-branch๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ํžˆ์Šคํ† ๋ฆฌ์—์„œ ํ† ํฐ ์ œ๊ฑฐ
$script = @"
if [ -f `$file ]; then
sed -i 's/$token/$replacement/g' `$file 2>/dev/null || \
(powershell -Command "(Get-Content '`$file') -replace '$token', '$replacement' | Set-Content '`$file'")
fi
"@
# Windows์—์„œ๋Š” git filter-branch๊ฐ€ ๋ณต์žกํ•˜๋ฏ€๋กœ,
# ๋Œ€์‹  ๊ฐ ํŒŒ์ผ์— ๋Œ€ํ•ด ๊ฐœ๋ณ„์ ์œผ๋กœ ์ฒ˜๋ฆฌ
foreach ($file in $files) {
Write-Host "ํžˆ์Šคํ† ๋ฆฌ ์ฒ˜๋ฆฌ ์ค‘: $file" -ForegroundColor Cyan
# git filter-branch ์‹คํ–‰ (tree-filter ์‚ฌ์šฉ)
$filterCmd = "if [ -f `"$file`" ]; then powershell -Command `"(Get-Content `"$file`" -Raw) -replace '$token', '$replacement' | Set-Content `"$file`" -NoNewline`"; fi"
git filter-branch --force --tree-filter $filterCmd --prune-empty --tag-name-filter cat -- --all 2>&1 | Out-Null
if ($LASTEXITCODE -eq 0) {
Write-Host " โœ“ ํžˆ์Šคํ† ๋ฆฌ์—์„œ ํ† ํฐ ์ œ๊ฑฐ ์™„๋ฃŒ" -ForegroundColor Green
} else {
Write-Host " โš  ํžˆ์Šคํ† ๋ฆฌ ์ฒ˜๋ฆฌ ์‹คํŒจ (ํŒŒ์ผ์ด ํžˆ์Šคํ† ๋ฆฌ์— ์—†์„ ์ˆ˜ ์žˆ์Œ)" -ForegroundColor Yellow
}
}
Write-Host "`n์™„๋ฃŒ! ์ด์ œ git push --force๋ฅผ ์‹คํ–‰ํ•˜์„ธ์š”." -ForegroundColor Green