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

patch1 #1732

Closed
Closed

patch1 #1732

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
155 commits
Select commit Hold shift + click to select a range
80c8305
Update FabricBot Config for Jeff Portal Review Action (#1261)
jtracey93 Mar 23, 2023
94531c1
Merging policy-refresh branch into main (#1276)
Springstone Apr 6, 2023
07fffb2
Portal Accelerator Bug Bix (#1277)
Springstone Apr 7, 2023
e3bc610
metadata alignment deprecated policies (#1284)
JulianHayward Apr 17, 2023
289d4b9
ALZ Zero Trust hub and spoke (#1270)
JefferyMitchell Apr 18, 2023
3c7a203
Update ENFORCE-GuardrailsKeyVaultPolicyAssignment.json (#1286)
anwather Apr 20, 2023
9f48de7
Spelling Fixes in Policy Definition Display Names & Descriptions (#1289)
jtracey93 Apr 21, 2023
655a15d
remove allowed effect modify issue #1290 (#1291)
JulianHayward Apr 25, 2023
f145680
Fairfax Portal RI Fix (#1293)
Springstone Apr 25, 2023
18ea839
Update Guide in ALZ Wiki to include the ALZ 1.7 (#1292)
brsteph Apr 25, 2023
977050d
Add Non-Compliance Messages to Policy Assignments (#1217)
jaredfholgate Apr 26, 2023
550875f
Publish April Community Call Content (#1295)
jtracey93 Apr 27, 2023
7399e9c
ALZ Wiki Update for Managed Identities (#1294)
amillerb Apr 28, 2023
3af3daa
Change the default on policy set definitions from null to empty array…
jaredfholgate Apr 28, 2023
64463fc
Spelling of correlation (#1299)
sangling Apr 29, 2023
b547ac3
Spelling correction of pre-requisites (#1298)
sangling Apr 29, 2023
152d284
Removed Service Map (#1297)
arjenhuitema Apr 30, 2023
564c16c
Wiki deployments and Excel content update (#1302)
Springstone May 2, 2023
d3162d6
Update Whats new (#1304)
jtracey93 May 4, 2023
09aea43
Bug - Fix case for azureIotPrivateDnsZoneId parameter in policy assig…
jaredfholgate May 4, 2023
3c50bc3
PR for Portal RI DevOps removal (USER STORY 25574) (#1310)
pkorolo May 9, 2023
b822081
Bug Fix - Correcting a typo in the Deploy-MDFC-Config initiative. (#1…
Springstone May 12, 2023
54341a2
Remove workloads folder contents (#1316)
jtracey93 May 12, 2023
1cd0615
Add Azure Firewall basic sku to ALZ portal Accelerator (#1314)
maheshbenke May 13, 2023
58b0be5
Updating ALZ Policy graphics to reflect changes (#1317)
Springstone May 13, 2023
6295867
PR for GH1319 (#1322)
pkorolo May 16, 2023
869b40d
Bug fix: Deny MgmtPorts (#1323)
Springstone May 17, 2023
8871021
Fixed grammar in compliance messages (#1321)
anwather May 22, 2023
cb3dfa1
Added support for resource-specific destination table for API Managem…
chrholt May 22, 2023
8a20cc6
Bug fix #1326: AppService append sites with minimum TLS version to en…
Springstone May 22, 2023
a909647
Wiki updates- New Policy FAQ (#1328)
Springstone May 22, 2023
0c6b330
Fixing wiki URLs (#1329)
Springstone May 23, 2023
227dbd4
Updating hybrid networking assignments for consistency (#1336)
Springstone May 30, 2023
6b247e9
Whats New Updating TOC to last 6 months only (#1337)
Springstone May 30, 2023
8ed3a3e
Added support for resource-specific destination table for Firewall (#…
picccard May 30, 2023
b31c153
Main contribute guide updates (#1338)
Springstone May 30, 2023
efb0012
Spelling correction (#1341)
sangling May 31, 2023
18acf62
Add new parameter file to ensure correct reference arch for TF sync (…
matt-FFFFFF May 31, 2023
b58f6b3
fix: add missing params to TF sync param file (#1343)
matt-FFFFFF Jun 1, 2023
aa76452
fix: duplicate param in file (#1344)
matt-FFFFFF Jun 1, 2023
7ca12a6
fix: enable lzddos for tf sync (#1345)
matt-FFFFFF Jun 1, 2023
2ed333f
Spelling Correction (#1347)
sangling Jun 5, 2023
790ad2f
Fix for Premium Firewall Deployment Issue (#1346)
maheshbenke Jun 5, 2023
5660e4f
Update sidebar to correspond to content (#1349)
jfaurskov Jun 12, 2023
87842a9
Policy Refresh Q4FY23 (#1354)
Springstone Jun 20, 2023
e80d781
Spelling Correction (#1364)
sangling Jun 24, 2023
55e4880
Diagnostic Settings for MGs (#1363)
lachaves Jun 28, 2023
35df153
Fix #1370 - Remove DNS Proxy Option When AZ FW == Basic (#1371)
jtracey93 Jul 4, 2023
5c02b5e
FabricBot: Onboarding to GitOps.ResourceManagement because of FabricB…
microsoft-github-policy-service[bot] Jul 6, 2023
7cf68de
Feature: Policy Unittests (#1362)
oZakari Jul 7, 2023
b288103
Change to Ubuntu Runner - Policy Unit Tests (#1374)
jtracey93 Jul 7, 2023
1697b5d
Deny-MgmtPorts-From-Internet does not always block NSG creation (#1365)
DavidRobson Jul 7, 2023
a55c876
Fix #1355 - Deploy-Sql-vulnerabilityAssessments (#1369)
Springstone Jul 7, 2023
71f9807
Bug: Fixed function results to not return string for Unit Tests (#1375)
oZakari Jul 7, 2023
868ed44
Enhance pester outputs (#1376)
jtracey93 Jul 10, 2023
5002060
Enhance security on privileged workflows (#1385)
jtracey93 Jul 20, 2023
26928c4
New policy definition for Auditing Azure Hybrid Benefit usage (#1332)
fbinotto Jul 25, 2023
6840e6a
Update to Sentinel simplified pricing tiers (#1387)
jtracey93 Jul 25, 2023
ad4afdf
fix: make mg diag settings deployment name unique (#1398)
matt-FFFFFF Aug 4, 2023
53f886c
Remove branch filter
jtracey93 Aug 4, 2023
fb67f44
Add base ref for policy unit tests (#1401)
jtracey93 Aug 4, 2023
c0294f7
Update PolicyPesterTestHelper.psm1
jtracey93 Aug 4, 2023
7f80225
Update PolicyPesterTestHelper.psm1
jtracey93 Aug 4, 2023
687003e
Update PolicyPesterTestHelper.psm1
jtracey93 Aug 4, 2023
236a023
Enhancement to Unit-Test-Policies workflow (#1402)
Springstone Aug 9, 2023
12e12bb
Casing fixes of param for Azure Files DNS (#1407)
jtracey93 Aug 25, 2023
8790878
Update ALZ Repo (Enterprise-scale) with Entra product names (#1411)
lachaves Aug 31, 2023
8d75c8f
Add September 2023 Community Call (#1432)
jtracey93 Sep 25, 2023
2224bc4
Policy Refresh Q1 FY24 (#1426)
Springstone Sep 27, 2023
99ee3d6
Update ALZ-Policies.md (#1435)
anwather Oct 2, 2023
947d508
ALZ Portal Accelerator add Active-active option for VPN Gateway (#1415)
terrymandin Oct 4, 2023
f9facfd
Include AMBA policies in portal accelerator (#1414)
jfaurskov Oct 4, 2023
5ccb8e6
Add Databricks to Audit-PrivateLinkDnsZones (#1438)
jtracey93 Oct 5, 2023
5071ba5
Update AUDIT-PeDnsZonesPolicyAssignment.json
jtracey93 Oct 5, 2023
59e2490
Rename inconsistent policy files (#1442)
rozkurt Oct 11, 2023
6ab72ee
Azure vWAN Routing Intent support for Portal Deployment (#1437)
rozkurt Oct 11, 2023
60b34a2
Fix version in Deploy-MDFC-Config initiative (#1446)
Springstone Oct 12, 2023
9b18dbf
Update AMBA version 2023-10-06 (#1448)
arjenhuitema Oct 13, 2023
5e3d800
Update Deploying-ALZ-ZTNetwork.md (#1449)
sangling Oct 16, 2023
726b55b
Portal RI: Fix IP address space overlap with FW/VPN (#1443)
Springstone Oct 17, 2023
9b5da44
Add support for Italy North (#1450)
jtracey93 Oct 17, 2023
97537b1
Included routing intent link (#1453)
paulgrimley Oct 17, 2023
b93ff6f
Update eslzArm.terraform-sync.param.json for TF policy assignment syn…
jtracey93 Oct 19, 2023
df45741
Update eslzArm.terraform-sync.param.json (#1456)
jtracey93 Oct 19, 2023
6da7b2d
FAQ Guidance for Services that won't deploy in ALZ (#1463)
ripadrao Oct 30, 2023
0eb642e
Wiki Doc updates - GH Releases (#1464)
Springstone Oct 31, 2023
a339243
Fix: Wiki ALZ Azure Setup Bash command (#1469)
baartch Nov 9, 2023
e687bbb
vWAN hub routing preference and autoscale (#1468)
rozkurt Nov 9, 2023
8a57430
Update README.md (#1471)
jtracey93 Nov 9, 2023
a6caa4f
vWAN with single subscription deployment bug fix (#1472)
rozkurt Nov 14, 2023
866a4e1
Update AMBA version 2023-11-14 (#1474)
arjenhuitema Nov 15, 2023
1a640ce
Update README.md to reference the use of managed identities. (#1475)
BeatrizSilv Nov 15, 2023
12c1d7c
Add document describing Policy Testing concept (#1480)
Springstone Dec 5, 2023
9a50491
Add December 2023 Community Call (#1503)
jtracey93 Dec 13, 2023
983c725
Fix Slide Link (#1504)
jtracey93 Dec 13, 2023
847c4de
Adjusting references to point to IaC accelerators (#1433)
oZakari Dec 21, 2023
3e7d813
New Policy Submission form (#1492)
Springstone Dec 21, 2023
4a5ed2d
ALZ Policies doc - updating images for Platform initiative assignment…
Springstone Dec 21, 2023
6164dfc
Add CSV for ALZ Standard Repo Labels (#1515)
jtracey93 Jan 3, 2024
42fe09d
Update alz-repo-standard-labels.csv and add PS1 script to apply to re…
jtracey93 Jan 3, 2024
d02f904
Portal update Private DNS Zone enablement to include a dropdown of se…
rozkurt Jan 7, 2024
1894ae7
Portal Accelerator Bug Fixes (#1520)
Springstone Jan 7, 2024
cb1b176
Fixed broken links in Zero Trust page (#1525)
brsteph Jan 15, 2024
ea3724f
GH Workflow update for Policy Testing (#1538)
Springstone Jan 26, 2024
4428780
Fix for GHA testing workflow (#1548)
Springstone Jan 30, 2024
8d1c1e5
Policy Refresh Q2FY24 (#1552)
Springstone Jan 31, 2024
a80bb9f
AMA doc updates (#1554)
arjenhuitema Jan 31, 2024
d128e8b
Create ALZ-Resource-Provider-Recommendations (#1539)
alisakina99 Feb 1, 2024
046e49f
Fix permissions Microsoft Defender for SQL policy assignment (#1564)
arjenhuitema Feb 5, 2024
c863db6
Update enforcement mode for Policy "Deploy-UserAssignedManagedIdentit…
arjenhuitema Feb 6, 2024
73f8b46
Fix for #1565: pass `userAssignedIdentityResourceGroup` to deployment…
SvenAelterman Feb 7, 2024
134ce1e
Created easily readable AMA policy table (#1569)
paulgrimley Feb 8, 2024
9ead68e
Fixes 1570 portal deployment issue (#1572)
arjenhuitema Feb 12, 2024
eaa0792
Fix subscriptionIds for no network deployment scenario (#1574)
arjenhuitema Feb 14, 2024
18b2685
Add new AMA Policies and Initiatives to ALZ Policies documentation (#…
arjenhuitema Mar 1, 2024
888e241
Added New Region FAQ (#1586)
paulgrimley Mar 3, 2024
2281ffd
Add Regulatory Compliance Policy Assignment Flexibility Feature (#1588)
jtracey93 Mar 4, 2024
915df23
Minor Policy Doc update (#1575)
Springstone Mar 4, 2024
9f44e1d
Portal Accelerator Update: Defender for Cloud ARM template and AzFW A…
Springstone Mar 4, 2024
cd5370b
Update wiki-sync.yml (#1591)
jtracey93 Mar 6, 2024
59b2ca1
Fixes bug with ama role assignments (#1593)
arjenhuitema Mar 8, 2024
339a3e9
fix: resource case error (#1598)
matt-FFFFFF Mar 12, 2024
1eae30a
Update community call wiki page with March 2024 recording and slides …
jtracey93 Mar 12, 2024
711fecc
AMA Script for Assigning Identity to Platform MG (#1607)
Brunoga-MS Mar 21, 2024
9131d8a
feat: Add additional, optional, telemetry for ALZ team to identify de…
jtracey93 Apr 23, 2024
45d5c2b
Add Azure Landing Zones Roadmap to README.md (#1629)
Springstone Apr 26, 2024
85f0993
Archive outdated readme content in eslzArm folder (#1634)
Springstone May 2, 2024
2fbd92f
Minor changes to the deprecated policies and services page (#1614)
paulgrimley May 3, 2024
d60ba34
Policy Refresh H2 FY24 (#1651)
Springstone Jun 3, 2024
42f2fd8
Update ALZ-Policies.md (#1656)
jtracey93 Jun 3, 2024
befa244
chore: Update policySetDefinitions version to 5.1.0 (#1658)
Springstone Jun 5, 2024
9b578dd
Add policy set definition workaround (#1659)
jaredfholgate Jun 5, 2024
6ca76b7
fix: cAsInG (#1661)
matt-FFFFFF Jun 5, 2024
0c81c91
New custom policy DenyAction Delete UAMI used by AMA (#1662)
arjenhuitema Jun 6, 2024
c71f0cf
ci: Use GITHUB_OUTPUT envvar instead of set-output command (#1526)
arunsathiya Jun 6, 2024
f9ba35d
Fix tiny typo (#1664)
anwather Jun 7, 2024
f92e25f
chore: Update Deploy-ASC-SecurityContacts version to 2.0.0 (#1663)
Springstone Jun 10, 2024
c6fe0fe
Add OpenSSF Scorecard (#1668)
jaredfholgate Jun 11, 2024
726c218
Add June Community Call (#1671)
jtracey93 Jun 12, 2024
2ea22fb
Update CODEOWNERS (#1673)
jtracey93 Jun 12, 2024
389d2bd
Update Wiki Flow (#1677)
jtracey93 Jun 13, 2024
d31d985
Update Community-Calls.md (#1672)
jtracey93 Jun 18, 2024
6d8b116
Adding Multi-Region Network Deployment (#1608)
brsteph Jun 18, 2024
16afa92
Update TF Sync Param File to align to portal defaults (#1686)
jtracey93 Jun 20, 2024
ff05e4a
AMA Migration Guidance (#1684)
arjenhuitema Jun 21, 2024
abb7d9d
Update Update-ALZ-Custom-Policies-to-Latest.md (#1685)
Pawel1985 Jun 25, 2024
819c353
Workflow OIDC Update (#1675)
Springstone Jun 27, 2024
f775451
Multiregion bugfix (#1692)
brsteph Jul 1, 2024
66b79d1
fix: casing in set params (#1701)
matt-FFFFFF Jul 4, 2024
0b8d048
Fix Supplementry typo (#1714)
jamiepla1 Aug 12, 2024
cbbf394
Updating GH Workflow to validate policy file and meta names are the s…
Springstone Aug 12, 2024
7b7ff1d
allowedValues alignment (#1702)
Brunoga-MS Aug 13, 2024
24ae46a
Sentinel Deployment Fix (#1709)
Springstone Aug 14, 2024
328b900
New policy build workflow (#1725)
Springstone Aug 14, 2024
c1650a5
Update test to remove deprecated parameter (#1730)
Springstone Aug 16, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
3 changes: 1 addition & 2 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,4 @@
# review when someone opens a pull request.

.github/CODEOWNERS @Azure/eslz-codeownersadmins
.github/** @Azure/eslz-admins
eslzArm/** @Azure/eslz-armteam
* @Azure/alz-core-team-technical
84 changes: 84 additions & 0 deletions .github/ISSUE_TEMPLATE/Policy_Submission.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
name: Policy Submission
description: Submit an Azure policy/initiative for Azure Landing Zone
title: "[Policy]: "
labels: ["policy"]
projects: []
assignees:
- springstone
body:
- type: markdown
attributes:
value: Thanks for taking the time to fill out this policy submission!
- type: dropdown
id: policytype
attributes:
label: Policy Definition or Initiative
description: Are you proposing a policy definition or initiative definition?
options:
- Definition
- Initiative
- Not sure
default: 0
validations:
required: true
- type: dropdown
id: builtincustom
attributes:
label: Built-in/Custom
description: Is the policy definition or initiative built-in or are you proposing a custom one?
options:
- Built-in
- Custom
- Not sure
default: 0
validations:
required: true
- type: input
id: resourceid
attributes:
label: Built-in policy definition or initiative ID
description: If this is for a built in policy definition or initiative, please provide the resource ID
value: "<GUID>"
validations:
required: false
- type: textarea
id: description
attributes:
label: Custom policy definition or initiative description
description: If this is a custom policy definition or initiative, please provide a description of what it should do.
placeholder: A policy that
value: "A policy that does ..."
validations:
required: true
- type: dropdown
id: assignmentscope
attributes:
label: Scope
description: What scope (Management Group) should the policy definition or initiative be assigned to?
options:
- Intermediate Root
- Platform
- Connectivity
- Management
- Identity
- Landing Zones
- Corp
- Online
- Decommissioned
- Sandbox
- Multiple / Other
default: 0
validations:
required: true
- type: checkboxes
id: defaultassignment
attributes:
label: Default Assignment
description: Should the policy definition or initiative be assigned by default to the scope above in Azure Landing Zone?
options:
- label: "Yes"
- type: textarea
id: Comments
attributes:
label: Comments/thoughts
description: Do you have any additional comments/thoughts?
63 changes: 63 additions & 0 deletions .github/actions-pester/PTF-TestPolicies.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
Import-Module -Name $PSScriptRoot\PolicyPesterTestHelper.psm1 -Force -Verbose
Import-Module Pester -Force

function RunPester
{
param (
[Parameter()]
[String]$PolicyTest
)

$pesterConfiguration = @{
Run = @{
Container = New-PesterContainer -Path $PolicyTest
PassThru = $true
}
Output = @{
Verbosity = 'Detailed'
CIFormat = 'Auto'
}
}
$result = Invoke-Pester -Configuration $pesterConfiguration
#exit $result.FailedCount
}

$ModifiedFiles = @(Get-PolicyFiles -DiffFilter "M")
if ([String]::IsNullOrEmpty($ModifiedFiles))
{
Write-Warning "These are the modified policies: $($ModifiedFiles)"
}
else
{
Write-Warning "There are no modified policies"
}

$AddedFiles = @(Get-PolicyFiles -DiffFilter "A")
if ([String]::IsNullOrEmpty($AddedFiles))
{
Write-Warning "These are the added policies: $($AddedFiles)"
}
else
{
Write-Warning "There are no added policies"
}

$ModifiedAddedFiles = $ModifiedFiles + $AddedFiles

$ModifiedAddedFiles | ForEach-Object {

$PolicyFile = Split-Path $_ -Leaf
$PolicyFileClean = $PolicyFile -replace ".json", ""

$testPath = "tests/policy/$($PolicyFileClean).Tests.ps1"

if (Test-Path $testPath)
{
Write-Warning "Running pester tests on $PolicyFileClean"
RunPester($testPath)
}
else
{
Write-Warning "There are no tests for $PolicyFileClean"
}
}
133 changes: 133 additions & 0 deletions .github/actions-pester/PolicyPesterTestHelper.psm1
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
<#
.DESCRIPTION
Uses git diff to return a list of policy definitions and policy set definition file paths.
#>

function Get-PolicyFiles
{
[CmdletBinding(SupportsShouldProcess)]
param (
[Parameter()]
[String]$DiffFilter,

[Parameter()]
[String]$PolicyDir = "$($env:POLICY_DIR)",

[Parameter()]
[String]$PolicySetDir = "$($env:POLICYSET_DIR)",

[Parameter()]
[String]$PRBranch = "$($env:GITHUB_HEAD_REF)",

[Parameter()]
[String]$BaseBranch = "$($env:GITHUB_BASE_REF)"
)

$PolicyFiles = @(git diff --diff-filter=$DiffFilter --name-only origin/main $PRBranch -- $PolicyDir)
$PolicySetsFiles = @(git diff --diff-filter=$DiffFilter --name-only origin/main $PRBranch -- $PolicySetDir)

$PolicyAndSetFiles = $PolicyFiles + $PolicySetsFiles

$PolicyAndSetFiles | ForEach-Object {
return $_
}
}

function Remove-JSONMetadata {

[CmdletBinding()]
param (
[Parameter(Mandatory = $true)]
[hashtable] $TemplateObject
)
$TemplateObject.Remove('metadata')

# Differantiate case: With user defined types (resources property is hashtable) vs without user defined types (resources property is array)
if ($TemplateObject.resources.GetType().BaseType.Name -eq 'Hashtable') {
# Case: Hashtable
$resourceIdentifiers = $TemplateObject.resources.Keys
for ($index = 0; $index -lt $resourceIdentifiers.Count; $index++) {
if ($TemplateObject.resources[$resourceIdentifiers[$index]].type -eq 'Microsoft.Resources/deployments' -and $TemplateObject.resources[$resourceIdentifiers[$index]].properties.template.GetType().BaseType.Name -eq 'Hashtable') {
$TemplateObject.resources[$resourceIdentifiers[$index]] = Remove-JSONMetadata -TemplateObject $TemplateObject.resources[$resourceIdentifiers[$index]].properties.template
}
}
} else {
# Case: Array
for ($index = 0; $index -lt $TemplateObject.resources.Count; $index++) {
if ($TemplateObject.resources[$index].type -eq 'Microsoft.Resources/deployments' -and $TemplateObject.resources[$index].properties.template.GetType().BaseType.Name -eq 'Hashtable') {
$TemplateObject.resources[$index] = Remove-JSONMetadata -TemplateObject $TemplateObject.resources[$index].properties.template
}
}
}

return $TemplateObject
}

function ConvertTo-OrderedHashtable {

[CmdletBinding()]
param (
[Parameter(Mandatory = $true)]
[string] $JSONInputObject # Must be string to workaround auto-conversion
)

$JSONObject = ConvertFrom-Json $JSONInputObject -AsHashtable -Depth 99 -NoEnumerate
$orderedLevel = [ordered]@{}

if (-not ($JSONObject.GetType().BaseType.Name -eq 'Hashtable')) {
return $JSONObject # E.g. in primitive data types [1,2,3]
}

foreach ($currentLevelKey in ($JSONObject.Keys | Sort-Object -Culture 'en-US')) {

if ($null -eq $JSONObject[$currentLevelKey]) {
# Handle case in which the value is 'null' and hence has no type
$orderedLevel[$currentLevelKey] = $null
continue
}

switch ($JSONObject[$currentLevelKey].GetType().BaseType.Name) {
{ $PSItem -in @('Hashtable') } {
$orderedLevel[$currentLevelKey] = ConvertTo-OrderedHashtable -JSONInputObject ($JSONObject[$currentLevelKey] | ConvertTo-Json -Depth 99)
}
'Array' {
$arrayOutput = @()

# Case: Array of arrays
$arrayElements = $JSONObject[$currentLevelKey] | Where-Object { $_.GetType().BaseType.Name -eq 'Array' }
foreach ($array in $arrayElements) {
if ($array.Count -gt 1) {
# Only sort for arrays with more than one item. Otherwise single-item arrays are casted
$array = $array | Sort-Object -Culture 'en-US'
}
$arrayOutput += , (ConvertTo-OrderedHashtable -JSONInputObject ($array | ConvertTo-Json -Depth 99))
}

# Case: Array of objects
$hashTableElements = $JSONObject[$currentLevelKey] | Where-Object { $_.GetType().BaseType.Name -eq 'Hashtable' }
foreach ($hashTable in $hashTableElements) {
$arrayOutput += , (ConvertTo-OrderedHashtable -JSONInputObject ($hashTable | ConvertTo-Json -Depth 99))
}

# Case: Primitive data types
$primitiveElements = $JSONObject[$currentLevelKey] | Where-Object { $_.GetType().BaseType.Name -notin @('Array', 'Hashtable') } | ConvertTo-Json -Depth 99 | ConvertFrom-Json -AsHashtable -NoEnumerate -Depth 99
if ($primitiveElements.Count -gt 1) {
$primitiveElements = $primitiveElements | Sort-Object -Culture 'en-US'
}
$arrayOutput += $primitiveElements

if ($array.Count -gt 1) {
# Only sort for arrays with more than one item. Otherwise single-item arrays are casted
$arrayOutput = $arrayOutput | Sort-Object -Culture 'en-US'
}
$orderedLevel[$currentLevelKey] = $arrayOutput
}
Default {
# string/int/etc.
$orderedLevel[$currentLevelKey] = $JSONObject[$currentLevelKey]
}
}
}

return $orderedLevel
}
62 changes: 62 additions & 0 deletions .github/actions-pester/Test-BuildPolicies.Tests.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
Describe 'UnitTest-BuildPolicies' {

BeforeAll {
Import-Module -Name $PSScriptRoot\PolicyPesterTestHelper.psm1 -Force -Verbose

New-Item -Name "buildout" -Type Directory

# Build the PR policies, initiatives, and role definitions to a temp folder
bicep build ./src/templates/policies.bicep --outfile ./buildout/policies.json
bicep build ./src/templates/initiatives.bicep --outfile ./buildout/initiatives.json
bicep build ./src/templates/roles.bicep --outfile ./buildout/customRoleDefinitions.json
}

Context "Check Policy Builds" {

It "Check policies build done" {
$prFile = "./eslzArm/managementGroupTemplates/policyDefinitions/policies.json"
$buildFile = "./buildout/policies.json"

$buildJson = Remove-JSONMetadata -TemplateObject (Get-Content $buildFile -Raw | ConvertFrom-Json -Depth 99 -AsHashtable)
$buildJson = ConvertTo-OrderedHashtable -JSONInputObject (ConvertTo-Json $buildJson -Depth 99)

$prJson = Remove-JSONMetadata -TemplateObject (Get-Content $prFile -Raw | ConvertFrom-Json -Depth 99 -AsHashtable)
$prJson = ConvertTo-OrderedHashtable -JSONInputObject (ConvertTo-Json $prJson -Depth 99)

# Compare files we built to the PR files
(ConvertTo-Json $buildJson -Depth 99) | Should -Be (ConvertTo-Json $prJson -Depth 99) -Because "the [policies.json] should be based on the latest [policies.bicep] file. Please run [` bicep build ./src/templates/policies.bicep --outfile ./eslzArm/managementGroupTemplates/policyDefinitions/policies.json `] using the latest Bicep CLI version."
}

It "Check initiatives build done" {
$PRfile = "./eslzArm/managementGroupTemplates/policyDefinitions/initiatives.json"
$buildFile = "./buildout/initiatives.json"

$buildJson = Remove-JSONMetadata -TemplateObject (Get-Content $buildFile -Raw | ConvertFrom-Json -Depth 99 -AsHashtable)
$buildJson = ConvertTo-OrderedHashtable -JSONInputObject (ConvertTo-Json $buildJson -Depth 99)

$prJson = Remove-JSONMetadata -TemplateObject (Get-Content $prFile -Raw | ConvertFrom-Json -Depth 99 -AsHashtable)
$prJson = ConvertTo-OrderedHashtable -JSONInputObject (ConvertTo-Json $prJson -Depth 99)

# Compare files we built to the PR files
(ConvertTo-Json $buildJson -Depth 99) | Should -Be (ConvertTo-Json $prJson -Depth 99) -Because "the [initiatives.json] should be based on the latest [initiatives.bicep] file. Please run [` bicep build ./src/templates/initiatives.bicep --outfile ./eslzArm/managementGroupTemplates/policyDefinitions/initiatives.json `] using the latest Bicep CLI version."
}

It "Check role definitions build done" {
$PRfile = "./eslzArm/managementGroupTemplates/roleDefinitions/customRoleDefinitions.json"
$buildFile = "./buildout/customRoleDefinitions.json"

$buildJson = Remove-JSONMetadata -TemplateObject (Get-Content $buildFile -Raw | ConvertFrom-Json -Depth 99 -AsHashtable)
$buildJson = ConvertTo-OrderedHashtable -JSONInputObject (ConvertTo-Json $buildJson -Depth 99)

$prJson = Remove-JSONMetadata -TemplateObject (Get-Content $prFile -Raw | ConvertFrom-Json -Depth 99 -AsHashtable)
$prJson = ConvertTo-OrderedHashtable -JSONInputObject (ConvertTo-Json $prJson -Depth 99)

# Compare files we built to the PR files
(ConvertTo-Json $buildJson -Depth 99) | Should -Be (ConvertTo-Json $prJson -Depth 99) -Because "the [customRoleDefinitions.json] should be based on the latest [customRoleDefinitions.bicep] file. Please run [` bicep build ./src/templates/roles.bicep --outfile ./eslzArm/managementGroupTemplates/roleDefinitions/customRoleDefinitions.json `] using the latest Bicep CLI version."
}
}

AfterAll {
# These are not the droids you are looking for...
}
}
Loading
Loading