Skip to content
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

Add booleans support for sanitizer #19110

Merged
2 changes: 1 addition & 1 deletion Tasks/AzureFileCopyV1/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"author": "Microsoft Corporation",
"version": {
"Major": 1,
"Minor": 229,
"Minor": 230,
"Patch": 0
},
"demands": [
Expand Down
2 changes: 1 addition & 1 deletion Tasks/AzureFileCopyV1/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"author": "Microsoft Corporation",
"version": {
"Major": 1,
"Minor": 229,
"Minor": 230,
"Patch": 0
},
"demands": [
Expand Down
4 changes: 2 additions & 2 deletions Tasks/AzureFileCopyV2/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
"author": "Microsoft Corporation",
"version": {
"Major": 2,
"Minor": 229,
"Patch": 1
"Minor": 230,
"Patch": 0
},
"demands": [
"azureps"
Expand Down
4 changes: 2 additions & 2 deletions Tasks/AzureFileCopyV2/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
"author": "Microsoft Corporation",
"version": {
"Major": 2,
"Minor": 229,
"Patch": 1
"Minor": 230,
"Patch": 0
},
"demands": [
"azureps"
Expand Down
4 changes: 2 additions & 2 deletions Tasks/AzureFileCopyV3/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
"author": "Microsoft Corporation",
"version": {
"Major": 3,
"Minor": 229,
"Patch": 1
"Minor": 230,
"Patch": 0
},
"demands": [
"azureps"
Expand Down
4 changes: 2 additions & 2 deletions Tasks/AzureFileCopyV3/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
"author": "Microsoft Corporation",
"version": {
"Major": 3,
"Minor": 229,
"Patch": 1
"Minor": 230,
"Patch": 0
},
"demands": [
"azureps"
Expand Down
2 changes: 1 addition & 1 deletion Tasks/AzureFileCopyV4/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"author": "Microsoft Corporation",
"version": {
"Major": 4,
"Minor": 229,
"Minor": 230,
"Patch": 0
},
"demands": [
Expand Down
2 changes: 1 addition & 1 deletion Tasks/AzureFileCopyV4/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"author": "Microsoft Corporation",
"version": {
"Major": 4,
"Minor": 229,
"Minor": 230,
"Patch": 0
},
"demands": [
Expand Down
2 changes: 1 addition & 1 deletion Tasks/AzureFileCopyV5/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"author": "Microsoft Corporation",
"version": {
"Major": 5,
"Minor": 229,
"Minor": 230,
"Patch": 0
},
"demands": [
Expand Down
2 changes: 1 addition & 1 deletion Tasks/AzureFileCopyV5/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"author": "Microsoft Corporation",
"version": {
"Major": 5,
"Minor": 229,
"Minor": 230,
"Patch": 0
},
"demands": [
Expand Down
8 changes: 5 additions & 3 deletions Tasks/Common/Sanitizer/ArgumentsSanitizer.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,11 @@ function Get-SanitizedArguments([string]$inputArgs) {
$argsSplitSymbols = '``';
[string[][]]$matchesChunks = @()

# regex rule for removing symbols and telemetry.
# '?<!`' - checking if before character no backtick. '([allowedchars])' - checking if character is allowed. Otherwise, replace to $removedSymbolSign
$regex = '(?<!`)([^a-zA-Z0-9\\` _''"\-=\/:\.*,+~?%\n])';
## PowerShell Regex is case insensitive by default, so we don't need to specify a-zA-Z.
## ('?<!`') - checking if before character no backtick.
## ([^\w` _'"-=\/:\.*,+~?%\n#]) - checking if character is allowed. Insead replacing to #removed#
## (?!true|false) - checking if after characters sequence no $true or $false.
$regex = '(?<!`)([^\w\\` _''"\-=\/:\.*,+~?%\n#])(?!true|false)'

# We're splitting by ``, removing all suspicious characters and then join
$argsArr = $inputArgs -split $argsSplitSymbols;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,19 @@ $inputArgsSuites = @(
"--parameter", # Many modern applications accept parameters with double hyphen
"parameter=value", # Format for passing values to parameters
"parameter value.txt", # Argument with dot in the middle
"-parameter", # Single hyphen followed by a single letter or digit (POSIX style)
"-parameter value", # When the parameter needs a value
"--parameter", # Double hyphen followed by a word (GNU style)
"--parameter=value", # Value directly attached to the parameter with an equals sign
"parameter=value", # Used to pass environment variables to a command
"parameter value.txt", # Argument with dot in the middle
"-Parameter Value", # Most common form
"-Parameter:Value", # Colon connects the parameter and its value
"/p:Parameter=Value", # Specific syntax for tools like MSBuild or NuGet
"--Parameter Value", # Used by cmdlets or scripts for cross-platform compatibility
"--Parameter=Value", # Used by cross-platform tools
"parameter value.txt" # Argument with dot in the middle
'a A 1 \ ` _ '' " - = / : . * , + ~ ? %', # Just each allowed symbol
'a A z Z 1 9 \ ` _ '' " - = / : . * , + ~ ? % #', # Just each allowed symbol
'',
'test 1',
'test `; whoami `&`& echo test',
"line 1 `n line 2"
"line 1 `n line 2",
'$TrUe $true $fAlsE $false'
)

foreach ($inputArgs in $inputArgsSuites) {
Expand Down
23 changes: 23 additions & 0 deletions Tasks/Common/Sanitizer/runTests.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
## Temp script to run L0 tests for Sanitizer.
## TODO: Remove after https://github.com/microsoft/azure-pipelines-tasks/pull/19108 will be merged.

$startLoc = Get-Location

$projectRoot = "$PSScriptRoot/../../.."
Set-Location $projectRoot

$buildPath = "$projectRoot/_build/Tasks/Common/Sanitizer"

try {
Remove-Item $buildPath -Recurse -Force -ErrorAction SilentlyContinue

## Workaround to build common package
node make build --task WindowsMachineFileCopyV1

Write-Host "Running L0 tests..."
Set-Location $buildPath/Tests
mocha ./L0.js
}
finally {
Set-Location $startLoc
}
6 changes: 6 additions & 0 deletions Tasks/Common/Sanitizer/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"compilerOptions": {
"target": "ES6",
"module": "commonjs"
}
}
2 changes: 1 addition & 1 deletion Tasks/WindowsMachineFileCopyV1/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"author": "Microsoft Corporation",
"version": {
"Major": 1,
"Minor": 229,
"Minor": 230,
"Patch": 0
},
"minimumAgentVersion": "1.104.0",
Expand Down
2 changes: 1 addition & 1 deletion Tasks/WindowsMachineFileCopyV1/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"author": "Microsoft Corporation",
"version": {
"Major": 1,
"Minor": 229,
"Minor": 230,
"Patch": 0
},
"minimumAgentVersion": "1.104.0",
Expand Down
2 changes: 1 addition & 1 deletion Tasks/WindowsMachineFileCopyV2/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"author": "Microsoft Corporation",
"version": {
"Major": 2,
"Minor": 229,
"Minor": 230,
"Patch": 0
},
"releaseNotes": "What's new in Version 2.0: <br/>&nbsp;&nbsp;Proxy support is being added. <br/>&nbsp;&nbsp; Removed support of legacy DTL machines.",
Expand Down
2 changes: 1 addition & 1 deletion Tasks/WindowsMachineFileCopyV2/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"author": "Microsoft Corporation",
"version": {
"Major": 2,
"Minor": 229,
"Minor": 230,
"Patch": 0
},
"releaseNotes": "ms-resource:loc.releaseNotes",
Expand Down
4 changes: 2 additions & 2 deletions _generated/AzureFileCopyV2.versionmap.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Default|2.229.1
Node16-225|2.229.0
Default|2.230.0
Node16-225|2.230.1
8 changes: 4 additions & 4 deletions _generated/AzureFileCopyV2/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
"author": "Microsoft Corporation",
"version": {
"Major": 2,
"Minor": 229,
"Patch": 1
"Minor": 230,
"Patch": 0
},
"demands": [
"azureps"
Expand Down Expand Up @@ -370,7 +370,7 @@
"ExpiredServicePrincipal": "Could not fetch access token for Azure. Verify if the Service Principal used is valid and not expired."
},
"_buildConfigMapping": {
"Default": "2.229.1",
"Node16-225": "2.229.0"
"Default": "2.230.0",
"Node16-225": "2.230.1"
}
}
8 changes: 4 additions & 4 deletions _generated/AzureFileCopyV2/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
"author": "Microsoft Corporation",
"version": {
"Major": 2,
"Minor": 229,
"Patch": 1
"Minor": 230,
"Patch": 0
},
"demands": [
"azureps"
Expand Down Expand Up @@ -370,7 +370,7 @@
"ExpiredServicePrincipal": "ms-resource:loc.messages.ExpiredServicePrincipal"
},
"_buildConfigMapping": {
"Default": "2.229.1",
"Node16-225": "2.229.0"
"Default": "2.230.0",
"Node16-225": "2.230.1"
}
}
8 changes: 4 additions & 4 deletions _generated/AzureFileCopyV2_Node16/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
"author": "Microsoft Corporation",
"version": {
"Major": 2,
"Minor": 229,
"Patch": 0
"Minor": 230,
"Patch": 1
},
"demands": [
"azureps"
Expand Down Expand Up @@ -374,7 +374,7 @@
"ExpiredServicePrincipal": "Could not fetch access token for Azure. Verify if the Service Principal used is valid and not expired."
},
"_buildConfigMapping": {
"Default": "2.229.1",
"Node16-225": "2.229.0"
"Default": "2.230.0",
"Node16-225": "2.230.1"
}
}
8 changes: 4 additions & 4 deletions _generated/AzureFileCopyV2_Node16/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
"author": "Microsoft Corporation",
"version": {
"Major": 2,
"Minor": 229,
"Patch": 0
"Minor": 230,
"Patch": 1
},
"demands": [
"azureps"
Expand Down Expand Up @@ -374,7 +374,7 @@
"ExpiredServicePrincipal": "ms-resource:loc.messages.ExpiredServicePrincipal"
},
"_buildConfigMapping": {
"Default": "2.229.1",
"Node16-225": "2.229.0"
"Default": "2.230.0",
"Node16-225": "2.230.1"
}
}
4 changes: 2 additions & 2 deletions _generated/AzureFileCopyV3.versionmap.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Default|3.229.1
Node16-225|3.229.0
Default|3.230.0
Node16-225|3.230.1
8 changes: 4 additions & 4 deletions _generated/AzureFileCopyV3/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
"author": "Microsoft Corporation",
"version": {
"Major": 3,
"Minor": 229,
"Patch": 1
"Minor": 230,
"Patch": 0
},
"demands": [
"azureps"
Expand Down Expand Up @@ -309,7 +309,7 @@
"ExpiredServicePrincipal": "Could not fetch access token for Azure. Verify if the Service Principal used is valid and not expired."
},
"_buildConfigMapping": {
"Default": "3.229.1",
"Node16-225": "3.229.0"
"Default": "3.230.0",
"Node16-225": "3.230.1"
}
}
8 changes: 4 additions & 4 deletions _generated/AzureFileCopyV3/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
"author": "Microsoft Corporation",
"version": {
"Major": 3,
"Minor": 229,
"Patch": 1
"Minor": 230,
"Patch": 0
},
"demands": [
"azureps"
Expand Down Expand Up @@ -309,7 +309,7 @@
"ExpiredServicePrincipal": "ms-resource:loc.messages.ExpiredServicePrincipal"
},
"_buildConfigMapping": {
"Default": "3.229.1",
"Node16-225": "3.229.0"
"Default": "3.230.0",
"Node16-225": "3.230.1"
}
}
8 changes: 4 additions & 4 deletions _generated/AzureFileCopyV3_Node16/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
"author": "Microsoft Corporation",
"version": {
"Major": 3,
"Minor": 229,
"Patch": 0
"Minor": 230,
"Patch": 1
},
"demands": [
"azureps"
Expand Down Expand Up @@ -313,7 +313,7 @@
"ExpiredServicePrincipal": "Could not fetch access token for Azure. Verify if the Service Principal used is valid and not expired."
},
"_buildConfigMapping": {
"Default": "3.229.1",
"Node16-225": "3.229.0"
"Default": "3.230.0",
"Node16-225": "3.230.1"
}
}
8 changes: 4 additions & 4 deletions _generated/AzureFileCopyV3_Node16/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
"author": "Microsoft Corporation",
"version": {
"Major": 3,
"Minor": 229,
"Patch": 0
"Minor": 230,
"Patch": 1
},
"demands": [
"azureps"
Expand Down Expand Up @@ -313,7 +313,7 @@
"ExpiredServicePrincipal": "ms-resource:loc.messages.ExpiredServicePrincipal"
},
"_buildConfigMapping": {
"Default": "3.229.1",
"Node16-225": "3.229.0"
"Default": "3.230.0",
"Node16-225": "3.230.1"
}
}