Skip to content

Commit

Permalink
v6_major_20230320_1
Browse files Browse the repository at this point in the history
  • Loading branch information
JulianHayward committed Mar 20, 2023
1 parent c5c32df commit 07c3e68
Show file tree
Hide file tree
Showing 7 changed files with 115 additions and 9 deletions.
53 changes: 53 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,59 @@ Listed as [security monitoring tool](https://docs.microsoft.com/en-us/azure/arch

## Release history

__Changes__ (2023-Mar-20 / Major)

* Fix/update feature Policy Remediation
* Optimze the Azure Resource Graph query by adding sort, due to duplicates/missing entries for results > 1k
* __Analysis__ on issue #[175](https://github.com/JulianHayward/Azure-MG-Sub-Governance-Reporting/issues/175) (no real explanation, but fixed by using `IsNullOrWhiteSpace` instead of `IsNullOrEmpty`)

``` powershell
$htdetails0 = @"
{
"then": {
"details": [
{
"field": "Microsoft.ContainerInstance/containerGroups/diagnostics.logAnalytics.workspaceId",
"value": "[parameters('workspaceId')]"
}
]
}
}
"@
$htdetails1 = @"
{
"then": {
"details": [
{
"field": "Microsoft.ContainerInstance/containerGroups/diagnostics.logAnalytics.workspaceId",
"value": "[parameters('workspaceId')]"
},
{
"field": "Microsoft.ContainerInstance/containerGroups/diagnostics.logAnalytics.workspaceKey",
"value": "[parameters('workspaceKey')]"
}
]
}
}
"@
$obj0 = $htdetails0 | ConvertFrom-Json
if (-not [string]::IsNullOrEmpty($obj0.then.details.roleDefinitionIds)) {
Write-Host 'obj0 roleDefinitionIds not empty'
}
else {
Write-Host 'obj0 roleDefinitionIds empty'
}
$obj1 = $htdetails1 | ConvertFrom-Json
if (-not [string]::IsNullOrEmpty($obj1.then.details.roleDefinitionIds)) {
Write-Host 'obj1 roleDefinitionIds not empty'
}
else {
Write-Host 'obj1 roleDefinitionIds empty'
}
```

__Changes__ (2023-Mar-17 / Major)

* Fix issue #[175](https://github.com/JulianHayward/Azure-MG-Sub-Governance-Reporting/issues/175) / occured with new policy definition [Configure diagnostics for container group to log analytics workspace (21c469fa-a887-4363-88a9-60bfd6911a15)](https://www.azadvertizer.net/azpolicyadvertizer/21c469fa-a887-4363-88a9-60bfd6911a15.html). Cache built-in Policy definitions failed.
Expand Down
53 changes: 53 additions & 0 deletions history.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,59 @@

### Azure Governance Visualizer version 6

__Changes__ (2023-Mar-20 / Major)

* Fix/update feature Policy Remediation
* Optimze the Azure Resource Graph query by adding sort, due to duplicates/missing entries for results > 1k
* __Analysis__ on issue #[175](https://github.com/JulianHayward/Azure-MG-Sub-Governance-Reporting/issues/175) (no real explanation, but fixed by using `IsNullOrWhiteSpace` instead of `IsNullOrEmpty`)

``` powershell
$htdetails0 = @"
{
"then": {
"details": [
{
"field": "Microsoft.ContainerInstance/containerGroups/diagnostics.logAnalytics.workspaceId",
"value": "[parameters('workspaceId')]"
}
]
}
}
"@
$htdetails1 = @"
{
"then": {
"details": [
{
"field": "Microsoft.ContainerInstance/containerGroups/diagnostics.logAnalytics.workspaceId",
"value": "[parameters('workspaceId')]"
},
{
"field": "Microsoft.ContainerInstance/containerGroups/diagnostics.logAnalytics.workspaceKey",
"value": "[parameters('workspaceKey')]"
}
]
}
}
"@
$obj0 = $htdetails0 | ConvertFrom-Json
if (-not [string]::IsNullOrEmpty($obj0.then.details.roleDefinitionIds)) {
Write-Host 'obj0 roleDefinitionIds not empty'
}
else {
Write-Host 'obj0 roleDefinitionIds empty'
}
$obj1 = $htdetails1 | ConvertFrom-Json
if (-not [string]::IsNullOrEmpty($obj1.then.details.roleDefinitionIds)) {
Write-Host 'obj1 roleDefinitionIds not empty'
}
else {
Write-Host 'obj1 roleDefinitionIds empty'
}
```

__Changes__ (2023-Mar-17 / Major)

* Fix issue #[175](https://github.com/JulianHayward/Azure-MG-Sub-Governance-Reporting/issues/175) / occured with new policy definition [Configure diagnostics for container group to log analytics workspace (21c469fa-a887-4363-88a9-60bfd6911a15)](https://www.azadvertizer.net/azpolicyadvertizer/21c469fa-a887-4363-88a9-60bfd6911a15.html). Cache built-in Policy definitions failed.
Expand Down
8 changes: 4 additions & 4 deletions pwsh/AzGovVizParallel.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ Param
$AzAPICallVersion = '1.1.70',

[string]
$ProductVersion = 'v6_major_20230317_1',
$ProductVersion = 'v6_major_20230320_1',

[string]
$GithubRepository = 'aka.ms/AzGovViz',
Expand Down Expand Up @@ -3889,15 +3889,15 @@ function getPolicyRemediation {
policyresources
| where type == 'microsoft.policyinsights/policystates' and properties.policyAssignmentScope startswith '/providers/Microsoft.Management/managementGroups/' and (properties.policyDefinitionAction =~ 'deployifnotexists' or properties.policyDefinitionAction =~ 'modify') and properties.complianceState =~ 'NonCompliant'
| summarize count() by assignmentScope = tostring(properties.policyAssignmentScope), assignmentName = tostring(properties.policyAssignmentName), assignmentId = tostring(properties.policyAssignmentId), definitionName = tostring(properties.policyDefinitionName), definitionId = tostring(properties.policyDefinitionId), policyDefinitionReferenceId = tostring(properties.policyDefinitionReferenceId), effect = tostring(properties.policyDefinitionAction)
| order by ['count_'] desc
| sort by count_, assignmentId, definitionId, policyDefinitionReferenceId, effect
'@
}
else {
$queryNonCompliant = @'
policyresources
| where (properties.policyDefinitionAction =~ 'deployifnotexists' or properties.policyDefinitionAction =~ 'modify') and properties.complianceState =~ 'NonCompliant'
| summarize count() by assignmentScope = tostring(properties.policyAssignmentScope), assignmentName = tostring(properties.policyAssignmentName), assignmentId = tostring(properties.policyAssignmentId), definitionName = tostring(properties.policyDefinitionName), definitionId = tostring(properties.policyDefinitionId), policyDefinitionReferenceId = tostring(properties.policyDefinitionReferenceId), effect = tostring(properties.policyDefinitionAction)
| order by ['count_'] desc
| sort by count_, assignmentId, definitionId, policyDefinitionReferenceId, effect
'@
}

Expand Down Expand Up @@ -17055,7 +17055,7 @@ extensions: [{ name: 'sort' }]
"@)

$htmlSUMMARYPolicyRemediation = $null
$arrayRemediatableSorted = $arrayRemediatable | Sort-Object -Property policyDefinitionId, policyAssignmentId
$arrayRemediatableSorted = $arrayRemediatable | Sort-Object -Property nonCompliantResourcesCount, policySetPolicyDefinitionReferenceId, policyDefinitionId, policyAssignmentId -Descending
if (-not $NoCsvExport) {
$csvFilename = "$($filename)_PolicyRemediation"
Write-Host " Exporting PolicyRemediation CSV '$($outputPath)$($DirectorySeparatorChar)$($csvFilename).csv'"
Expand Down
2 changes: 1 addition & 1 deletion pwsh/dev/devAzGovVizParallel.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ Param
$AzAPICallVersion = '1.1.70',

[string]
$ProductVersion = 'v6_major_20230317_1',
$ProductVersion = 'v6_major_20230320_1',

[string]
$GithubRepository = 'aka.ms/AzGovViz',
Expand Down
4 changes: 2 additions & 2 deletions pwsh/dev/functions/getPolicyRemediation.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ function getPolicyRemediation {
policyresources
| where type == 'microsoft.policyinsights/policystates' and properties.policyAssignmentScope startswith '/providers/Microsoft.Management/managementGroups/' and (properties.policyDefinitionAction =~ 'deployifnotexists' or properties.policyDefinitionAction =~ 'modify') and properties.complianceState =~ 'NonCompliant'
| summarize count() by assignmentScope = tostring(properties.policyAssignmentScope), assignmentName = tostring(properties.policyAssignmentName), assignmentId = tostring(properties.policyAssignmentId), definitionName = tostring(properties.policyDefinitionName), definitionId = tostring(properties.policyDefinitionId), policyDefinitionReferenceId = tostring(properties.policyDefinitionReferenceId), effect = tostring(properties.policyDefinitionAction)
| order by ['count_'] desc
| sort by count_, assignmentId, definitionId, policyDefinitionReferenceId, effect
'@
}
else {
$queryNonCompliant = @'
policyresources
| where (properties.policyDefinitionAction =~ 'deployifnotexists' or properties.policyDefinitionAction =~ 'modify') and properties.complianceState =~ 'NonCompliant'
| summarize count() by assignmentScope = tostring(properties.policyAssignmentScope), assignmentName = tostring(properties.policyAssignmentName), assignmentId = tostring(properties.policyAssignmentId), definitionName = tostring(properties.policyDefinitionName), definitionId = tostring(properties.policyDefinitionId), policyDefinitionReferenceId = tostring(properties.policyDefinitionReferenceId), effect = tostring(properties.policyDefinitionAction)
| order by ['count_'] desc
| sort by count_, assignmentId, definitionId, policyDefinitionReferenceId, effect
'@
}

Expand Down
2 changes: 1 addition & 1 deletion pwsh/dev/functions/processTenantSummary.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -4402,7 +4402,7 @@ extensions: [{ name: 'sort' }]
"@)

$htmlSUMMARYPolicyRemediation = $null
$arrayRemediatableSorted = $arrayRemediatable | Sort-Object -Property policyDefinitionId, policyAssignmentId
$arrayRemediatableSorted = $arrayRemediatable | Sort-Object -Property nonCompliantResourcesCount, policySetPolicyDefinitionReferenceId, policyDefinitionId, policyAssignmentId -Descending
if (-not $NoCsvExport) {
$csvFilename = "$($filename)_PolicyRemediation"
Write-Host " Exporting PolicyRemediation CSV '$($outputPath)$($DirectorySeparatorChar)$($csvFilename).csv'"
Expand Down
2 changes: 1 addition & 1 deletion version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v6_major_20230317_1
v6_major_20230320_1

0 comments on commit 07c3e68

Please sign in to comment.