mirror of
https://github.com/taiki-e/install-action.git
synced 2026-05-08 05:40:31 +00:00
Simplify environment variable removal on Windows
This commit is contained in:
13
action.yml
13
action.yml
@@ -22,6 +22,8 @@ runs:
|
|||||||
using: composite
|
using: composite
|
||||||
steps:
|
steps:
|
||||||
- run: |
|
- run: |
|
||||||
|
# If /bin/sh is dash, environment variable containing % is not imported, but is fine
|
||||||
|
# because it also means that it will not be exposed to subprocess.
|
||||||
if /usr/bin/env | grep -Eq '^BASH_FUNC_'; then
|
if /usr/bin/env | grep -Eq '^BASH_FUNC_'; then
|
||||||
printf '::error::bash function injection via BASH_FUNC_ environment variable is not allowed for security reasons\n'
|
printf '::error::bash function injection via BASH_FUNC_ environment variable is not allowed for security reasons\n'
|
||||||
exit 1
|
exit 1
|
||||||
@@ -57,14 +59,9 @@ runs:
|
|||||||
# https://github.com/actions/partner-runner-images/issues/169
|
# https://github.com/actions/partner-runner-images/issues/169
|
||||||
- run: |
|
- run: |
|
||||||
Set-StrictMode -Version Latest
|
Set-StrictMode -Version Latest
|
||||||
if (Test-Path "Env:ENV") { Remove-Item Env:\ENV }
|
$remove_env = @('ENV','BASH_ENV','CDPATH','SHELLOPTS','BASHOPTS','BASH_FUNC_*')
|
||||||
if (Test-Path "Env:BASH_ENV") { Remove-Item Env:\BASH_ENV }
|
foreach ($name in $remove_env) {
|
||||||
if (Test-Path "Env:CDPATH") { Remove-Item Env:\CDPATH }
|
if (Test-Path "Env:$name") { Remove-Item "Env:\$name" }
|
||||||
if (Test-Path "Env:SHELLOPTS") { Remove-Item Env:\SHELLOPTS }
|
|
||||||
if (Test-Path "Env:BASHOPTS") { Remove-Item Env:\BASHOPTS }
|
|
||||||
if (Test-Path "Env:BASH_FUNC_*") {
|
|
||||||
Write-Output "::error::bash function injection via BASH_FUNC_ environment variable is not allowed for security reasons"
|
|
||||||
exit 1
|
|
||||||
}
|
}
|
||||||
for ($i=1; $i -le 10; $i++) {
|
for ($i=1; $i -le 10; $i++) {
|
||||||
$prev_err_action = $ErrorActionPreference
|
$prev_err_action = $ErrorActionPreference
|
||||||
|
|||||||
Reference in New Issue
Block a user