-
-
Notifications
You must be signed in to change notification settings - Fork 131
fix: bat security #658
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
fix: bat security #658
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -55,8 +55,12 @@ if exist "%OLD_DIR%\covers\" ( | |||||||||||||||||||||||||||||
| if not exist "%NEW_DIR%\covers\" ( | ||||||||||||||||||||||||||||||
| move "%OLD_DIR%\covers" "%NEW_DIR%\" | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| rem Fix apps.json image path values that point at the old covers directory | ||||||||||||||||||||||||||||||
| powershell -c "(Get-Content '%NEW_DIR%\apps.json').replace('.\/covers\/', '.\/config\/covers\/') | Set-Content '%NEW_DIR%\apps.json'" | ||||||||||||||||||||||||||||||
| rem Fix apps.json image path values that point at the old covers directory. | ||||||||||||||||||||||||||||||
| rem Pass the path via environment to PowerShell and use -LiteralPath to avoid | ||||||||||||||||||||||||||||||
| rem PowerShell code injection if the install path contains characters like ' or $. | ||||||||||||||||||||||||||||||
| set "MIGRATE_APPS_JSON=%NEW_DIR%\apps.json" | ||||||||||||||||||||||||||||||
| powershell -NoProfile -Command "$p = $env:MIGRATE_APPS_JSON; (Get-Content -LiteralPath $p).Replace('.\/covers\/', '.\/config\/covers\/') | Set-Content -LiteralPath $p" | ||||||||||||||||||||||||||||||
| set "MIGRATE_APPS_JSON=" | ||||||||||||||||||||||||||||||
|
Comment on lines
+58
to
+63
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 缺少 Line 62 在 🔧 建议修改- set "MIGRATE_APPS_JSON=%NEW_DIR%\apps.json"
- powershell -NoProfile -Command "$p = $env:MIGRATE_APPS_JSON; (Get-Content -LiteralPath $p).Replace('.\/covers\/', '.\/config\/covers\/') | Set-Content -LiteralPath $p"
- set "MIGRATE_APPS_JSON="
+ if exist "%NEW_DIR%\apps.json" (
+ set "MIGRATE_APPS_JSON=%NEW_DIR%\apps.json"
+ powershell -NoProfile -Command "$p = $env:MIGRATE_APPS_JSON; (Get-Content -LiteralPath $p).Replace('.\/covers\/', '.\/config\/covers\/') | Set-Content -LiteralPath $p"
+ set "MIGRATE_APPS_JSON="
+ )📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
|
|
@@ -69,6 +73,8 @@ if exist "%NEW_DIR%\apps.json" ( | |||||||||||||||||||||||||||||
| powershell -ExecutionPolicy Bypass -File "%~dp0migrate-images.ps1" "%NEW_DIR%" | ||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| rem Remove log files | ||||||||||||||||||||||||||||||
| del "%OLD_DIR%\*.txt" | ||||||||||||||||||||||||||||||
| del "%OLD_DIR%\*.log" | ||||||||||||||||||||||||||||||
| rem Remove legacy Sunshine log files left at the install root by older versions. | ||||||||||||||||||||||||||||||
| rem Restrict to known patterns instead of all *.txt / *.log to avoid clobbering | ||||||||||||||||||||||||||||||
| rem user-placed files (e.g. notes, third-party README's) in the install dir. | ||||||||||||||||||||||||||||||
| if exist "%OLD_DIR%\sunshine.log" del /q "%OLD_DIR%\sunshine.log" >nul 2>&1 | ||||||||||||||||||||||||||||||
| for %%F in ("%OLD_DIR%\sunshine.log.*") do if exist "%%~fF" del /q "%%~fF" >nul 2>&1 | ||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: AlkaidLab/foundation-sunshine
Length of output: 860
🏁 Script executed:
Repository: AlkaidLab/foundation-sunshine
Length of output: 4892
避免在 PowerShell 命令字符串中直接嵌入批处理路径变量。
Line 65 将
%release_json%直接拼接到 PowerShell-Command参数的单引号字符串内。当该路径包含单引号字符时(如通过网络路径或特殊环境),会破坏 PowerShell 字符串边界,导致解析失败甚至命令注入风险。建议改用环境变量传参方案,由 PowerShell 本地解析环境变量,避免 cmd 层面的嵌入歧义。建议修改
🤖 Prompt for AI Agents