-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Update BashV3 * Update PowerShellV2 * Update SshV0 * Update batchScriptV1 * Update variables names * Use tool from utility common * Fix regex for Bash & Ssh * Update powershell regex * Bump task versions * Update warning messages * Fix powershell condition * Hide new logic under more detailed conditions
- Loading branch information
1 parent
4dd7910
commit e215597
Showing
22 changed files
with
450 additions
and
171 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
function Publish-Telemetry($Telemetry) { | ||
$area = 'TaskHub' | ||
$feature = 'PowerShellV2' | ||
$telemetryJson = $Telemetry | ConvertTo-Json -Compress | ||
Write-Host "##vso[telemetry.publish area=$area;feature=$feature]$telemetryJson" | ||
} | ||
|
||
function Sanitize-FileArguments([string]$InputArgs) { | ||
|
||
$featureFlags = @{ | ||
audit = [System.Convert]::ToBoolean($env:AZP_75787_ENABLE_NEW_LOGIC_LOG) | ||
activate = [System.Convert]::ToBoolean($env:AZP_75787_ENABLE_NEW_LOGIC) | ||
telemetry = [System.Convert]::ToBoolean($env:AZP_75787_ENABLE_COLLECT) | ||
} | ||
|
||
$removedSymbolSign = '_#removed#_'; | ||
$argsSplitSymbols = '``'; | ||
|
||
# We're splitting by ``, removing all suspicious characters and then join | ||
$argsArr = $InputArgs -split $argsSplitSymbols; | ||
for ($i = 0; $i -lt $argsArr.Length; $i++ ) { | ||
## '?<!`' - checking if before character no backtick. '^a-zA-Z0-9` _'"-' - checking if character is allowed. Insead replacing to #removed# | ||
$argsArr[$i] = $argsArr[$i] -replace '(?<!`)([^a-zA-Z0-9\\` _''"\-=\/:\.])', $removedSymbolSign; | ||
} | ||
|
||
$resultArgs = $argsArr -join $argsSplitSymbols; | ||
|
||
if ( $resultArgs -like "*$removedSymbolSign*") { | ||
|
||
if ($featureFlags.audit -or $featureFlags.activate) { | ||
Write-Warning (Get-VstsLocString -Key 'PS_SanitizerOutput' -ArgumentList $resultArgs); | ||
} | ||
|
||
if ($featureFlags.telemetry) { | ||
$removedSymbolsCount = [regex]::matches($resultArgs, $removedSymbolSign).count | ||
Publish-Telemetry @{ 'removedSymbolsCount' = $removedSymbolsCount } | ||
} | ||
} | ||
|
||
return $resultArgs; | ||
} |
Oops, something went wrong.