-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from Azure/main
Update 7/27
- Loading branch information
Showing
1,093 changed files
with
149,497 additions
and
26,293 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
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,103 @@ | ||
<# | ||
.SYNOPSIS | ||
Filters PoliCheck Result. | ||
.DESCRIPTION | ||
This script will read data speciefied in one or more PoliCheckAllowList.yml files, | ||
It then reamoves all allwed entries from the PoliCheckResult | ||
.PARAMETER PoliCheckResultFilePath | ||
The Path to the PoliCheck Result. Usually named PoliCheck.sarif | ||
.PARAMETER ServiceDirtectory | ||
If the PoliCheck scan is scoped to a particular service provide the ServiceDirectory | ||
.EXAMPLE | ||
PS> ./FilterPoliCheckResults.ps1 -PoliCheckResultFilePath .\PoliCheck.sarif | ||
#> | ||
[CmdletBinding()] | ||
param( | ||
[Parameter(Mandatory=$true)] | ||
[String] $PoliCheckResultFilePath, | ||
[String] $ServiceDirtectory | ||
) | ||
|
||
. "${PSScriptRoot}\logging.ps1" | ||
|
||
$RepoRoot = Resolve-Path -Path "${PSScriptRoot}\..\..\..\" | ||
$PathToAllowListFiles = Join-Path $RepoRoot $ServiceDirtectory | ||
$PolicCheckAllowListFiles = Get-ChildItem -Path $PathToAllowListFiles -Recurse -File -Include "PoliCheckAllowList.yml" | ||
$allowListData = @{} | ||
|
||
# Combine all AllowLists Found | ||
foreach ($file in $PolicCheckAllowListFiles) | ||
{ | ||
$allowListDataInFile = ConvertFrom-Yaml (Get-Content $file.FullName -Raw) | ||
$allowListData["PC1001"] += $allowListDataInFile["PC1001"] | ||
$allowListData["PC1002"] += $allowListDataInFile["PC1002"] | ||
$allowListData["PC1003"] += $allowListDataInFile["PC1003"] | ||
$allowListData["PC1004"] += $allowListDataInFile["PC1004"] | ||
$allowListData["PC1005"] += $allowListDataInFile["PC1005"] | ||
$allowListData["PC1006"] += $allowListDataInFile["PC1006"] | ||
} | ||
|
||
$poliCheckData = Get-Content $PoliCheckResultFilePath | ConvertFrom-Json | ||
$poliCheckResultsCount = $poliCheckData.runs[0].results.Count | ||
$newCount | ||
|
||
$updatedRuns = @() | ||
|
||
foreach ($run in $poliCheckData.runs) | ||
{ | ||
$updatedResults = @() | ||
foreach ($result in $run.results) | ||
{ | ||
$ruleId = $result.ruleId | ||
$allowedEntries = $allowListData[$ruleId] | ||
if ($allowedEntries) | ||
{ | ||
$updatedLocations = @() | ||
|
||
foreach ($location in $result.locations) | ||
{ | ||
$filePath = $location.physicalLocation.artifactLocation.uri | ||
$text = $location.physicalLocation.region.snippet.text | ||
$contextRegion = $location.physicalLocation.contextRegion.snippet.text | ||
|
||
$allowedEntry = $allowedEntries[0] | Where-Object { $_.FilePath -eq $filePath } | ||
|
||
if ($allowedEntry.Count -gt 0) | ||
{ | ||
$foundAllowedInstance = $false | ||
foreach ($instance in $allowedEntry.instances) | ||
{ | ||
if (($instance.Text.Trim() -eq $text.Trim()) -and ($instance.ContextRegion.Trim() -eq $contextRegion.Trim())) | ||
{ | ||
Write-Host "Found instance" -ForegroundColor Green | ||
$foundAllowedInstance = $true | ||
} | ||
} | ||
if ($foundAllowedInstance -eq $true) | ||
{ | ||
continue | ||
} | ||
} | ||
|
||
$updatedLocations += $location | ||
} | ||
|
||
$result.locations = $updatedLocations | ||
} | ||
|
||
if ($result.locations.Count -gt 0) | ||
{ | ||
$updatedResults += $result | ||
} | ||
} | ||
$run.results = $updatedResults | ||
$newCount = $run.results.Count | ||
$updatedRuns += $run | ||
} | ||
|
||
$poliCheckData.runs = $updatedRuns | ||
|
||
Set-Content -Path $PoliCheckResultFilePath -Value ($poliCheckData | ConvertTo-Json -Depth 100) | ||
|
||
LogDebug "Original Result Count: ${poliCheckResultsCount}" | ||
LogDebug "New Result Count: ${newCount}" |
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
pip==20.2 | ||
pip==20.3 | ||
|
||
# requirements leveraged by ci for testing | ||
pytest==4.6.9; python_version == '2.7' | ||
|
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
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
-e ../../../tools/azure-sdk-tools | ||
-e ../../keyvault/azure-mgmt-keyvault | ||
-e ../../network/azure-mgmt-network | ||
azure-mgmt-keyvault<9.0.0 | ||
azure-mgmt-network<19.0.0 | ||
-e ../../../tools/azure-devtools |
Oops, something went wrong.