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 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
+