-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Common/Sanitizer: allow PowerShell data constructors @ { } [ ] #22253
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
Closed
Vladimir Tretyakov (wawanawna)
wants to merge
8
commits into
master
from
users/wawanawna/relax-ps-sanitizer-allow-special-characters
Closed
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
4adac75
Common/Sanitizer: allow PowerShell data constructors @ { } [ ]
2921273
Potential fix for pull request finding
wawanawna bec6516
Potential fix for pull request finding
wawanawna 18606f5
Potential fix for pull request finding
wawanawna 913ba28
Bump _buildConfigMapping in 5 generated task families to match patche…
wawanawna 0e03478
Bump source patch +2 for tasks with Node24 build configs
wawanawna 608dd82
Use minimum patch bump (+1 from prior max) instead of +2
wawanawna b337815
Merge branch 'master' into users/wawanawna/relax-ps-sanitizer-allow-s…
wawanawna File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -14,7 +14,7 @@ | |
| "version": { | ||
| "Major": 1, | ||
| "Minor": 276, | ||
| "Patch": 0 | ||
| "Patch": 1 | ||
| }, | ||
| "demands": [ | ||
| "azureps" | ||
|
|
||
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -14,7 +14,7 @@ | |
| "version": { | ||
| "Major": 1, | ||
| "Minor": 276, | ||
| "Patch": 0 | ||
| "Patch": 1 | ||
| }, | ||
| "demands": [ | ||
| "azureps" | ||
|
|
||
This file contains hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -14,7 +14,7 @@ | |
| "version": { | ||
| "Major": 2, | ||
| "Minor": 276, | ||
| "Patch": 0 | ||
| "Patch": 1 | ||
| }, | ||
| "demands": [ | ||
| "azureps" | ||
|
|
||
This file contains hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -14,7 +14,7 @@ | |
| "version": { | ||
| "Major": 3, | ||
| "Minor": 276, | ||
| "Patch": 0 | ||
| "Patch": 1 | ||
| }, | ||
| "demands": [ | ||
| "azureps" | ||
|
|
||
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -14,7 +14,7 @@ | |
| "version": { | ||
| "Major": 4, | ||
| "Minor": 276, | ||
| "Patch": 0 | ||
| "Patch": 2 | ||
| }, | ||
| "demands": [ | ||
| "azureps" | ||
|
|
||
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -14,7 +14,7 @@ | |
| "version": { | ||
| "Major": 4, | ||
| "Minor": 276, | ||
| "Patch": 0 | ||
| "Patch": 2 | ||
| }, | ||
| "demands": [ | ||
| "azureps" | ||
|
|
||
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -14,7 +14,7 @@ | |
| "version": { | ||
| "Major": 5, | ||
| "Minor": 276, | ||
| "Patch": 0 | ||
| "Patch": 2 | ||
| }, | ||
| "demands": [ | ||
| "azureps" | ||
|
|
||
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -14,7 +14,7 @@ | |
| "version": { | ||
| "Major": 5, | ||
| "Minor": 276, | ||
| "Patch": 0 | ||
| "Patch": 2 | ||
| }, | ||
| "demands": [ | ||
| "azureps" | ||
|
|
||
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -14,7 +14,7 @@ | |
| "version": { | ||
| "Major": 6, | ||
| "Minor": 276, | ||
| "Patch": 0 | ||
| "Patch": 2 | ||
| }, | ||
| "demands": [ | ||
| "azureps" | ||
|
|
||
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -14,7 +14,7 @@ | |
| "version": { | ||
| "Major": 6, | ||
| "Minor": 276, | ||
| "Patch": 0 | ||
| "Patch": 2 | ||
| }, | ||
| "demands": [ | ||
| "azureps" | ||
|
|
||
This file contains hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -18,7 +18,7 @@ | |
| "version": { | ||
| "Major": 2, | ||
| "Minor": 276, | ||
| "Patch": 0 | ||
| "Patch": 1 | ||
| }, | ||
| "demands": [ | ||
| "azureps" | ||
|
|
||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
71 changes: 71 additions & 0 deletions
71
Tasks/Common/Sanitizer/Tests/L0Protect-ScriptArguments.AllowsDataConstructors.ps1
This file contains hidden or 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,71 @@ | ||
| [CmdletBinding()] | ||
| param() | ||
|
|
||
| Set-Item -Path env:AZP_75787_ENABLE_NEW_LOGIC -Value 'true' | ||
|
|
||
| . $PSScriptRoot\..\..\..\..\Tests\lib\Initialize-Test.ps1 | ||
| . $PSScriptRoot\..\ArgumentsSanitizer.ps1 | ||
|
|
||
| # PowerShell data constructors (@ { } [ ]) are not execution primitives and | ||
| # must pass so customers can pass `-Tag @{...}`, splatting `@params`, type | ||
| # accelerators `[string]`, and literal indices `[0]` in scriptArguments | ||
| # (PR #22171 regression follow-up; mirrors AzureCLI fix in PR #22249). | ||
| $testSuites = @( | ||
| @{ | ||
| Name = 'Accepts hashtable literal @{ K = "v" }' | ||
| Input = '-Tag @{ Owner = "team" }' | ||
| }, | ||
| @{ | ||
| Name = 'Accepts hashtable with newline separators (YAML folded scalar)' | ||
| Input = "-Tag @{ Solution = ""RunnerImagesGeneration""`n ManagedBy = ""Platform-Team"" }" | ||
| }, | ||
| @{ | ||
| Name = 'Accepts splatting @params' | ||
| Input = 'Invoke-Build @params' | ||
| }, | ||
| @{ | ||
| Name = 'Accepts type accelerator [string]' | ||
| Input = '-Cast [string]' | ||
| }, | ||
| @{ | ||
| Name = 'Accepts literal index [0]' | ||
| Input = '-Index [0]' | ||
| }, | ||
| @{ | ||
| Name = 'Accepts hashtable value containing @ (email)' | ||
| Input = '-Tag @{ Owner = "team@contoso.com" }' | ||
| }, | ||
| @{ | ||
| Name = 'Accepts hashtable with $env: substitution in value (no dangerous chars)' | ||
| Input = '-Tag @{ RequestedFor = $env:requestedFor }' | ||
| Variables = @('requestedFor=someone@contoso.com') | ||
| } | ||
| ) | ||
|
|
||
| foreach ($test in $testSuites) { | ||
| if ($null -eq $test.Variables) { | ||
| $test.Variables = @() | ||
| } | ||
| $test.Variables | ForEach-Object { | ||
| $name, $value = $_.Split('=') | ||
| if ($value) { | ||
| Set-Item -Path env:$name -Value $value | ||
| } | ||
|
wawanawna marked this conversation as resolved.
|
||
| else { | ||
| Remove-Item env:$name -ErrorAction SilentlyContinue | ||
| } | ||
| } | ||
|
|
||
| try { | ||
| Protect-ScriptArguments $test.Input | ||
| } | ||
| catch { | ||
| throw "Error occurred in '$($test.Name)' suite with input '$($test.Input)': $($_.Exception.Message)" | ||
| } | ||
| finally { | ||
| $test.Variables | ForEach-Object { | ||
| $name, $value = $_.Split('=') | ||
| Remove-Item env:$name -ErrorAction SilentlyContinue | ||
| } | ||
|
wawanawna marked this conversation as resolved.
|
||
| } | ||
| } | ||
This file contains hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -14,7 +14,7 @@ | |
| "version": { | ||
| "Major": 3, | ||
| "Minor": 276, | ||
| "Patch": 0 | ||
| "Patch": 1 | ||
| }, | ||
| "groups": [ | ||
| { | ||
|
|
||
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -14,7 +14,7 @@ | |
| "version": { | ||
| "Major": 3, | ||
| "Minor": 276, | ||
| "Patch": 0 | ||
| "Patch": 1 | ||
| }, | ||
| "groups": [ | ||
| { | ||
|
|
||
This file contains hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -18,7 +18,7 @@ | |
| "version": { | ||
| "Major": 1, | ||
| "Minor": 276, | ||
| "Patch": 0 | ||
| "Patch": 1 | ||
| }, | ||
| "demands": [ | ||
| "Cmd" | ||
|
|
||
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -18,7 +18,7 @@ | |
| "version": { | ||
| "Major": 1, | ||
| "Minor": 276, | ||
| "Patch": 0 | ||
| "Patch": 1 | ||
| }, | ||
| "demands": [ | ||
| "Cmd" | ||
|
|
||
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -17,7 +17,7 @@ | |
| "version": { | ||
| "Major": 1, | ||
| "Minor": 276, | ||
| "Patch": 1 | ||
| "Patch": 2 | ||
| }, | ||
| "demands": [ | ||
| "sqlpackage" | ||
|
|
||
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -17,7 +17,7 @@ | |
| "version": { | ||
| "Major": 1, | ||
| "Minor": 276, | ||
| "Patch": 1 | ||
| "Patch": 2 | ||
| }, | ||
| "demands": [ | ||
| "sqlpackage" | ||
|
|
||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.