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

[Enhancement] - GR5 Allowed Location Check + Policy Compliance Status Information #371

Merged
merged 7 commits into from
Jan 23, 2025

Conversation

alalvi00
Copy link
Contributor

@alalvi00 alalvi00 commented Jan 22, 2025

Overview/Summary

This update improves the logic for determining compliance status based on assigned policies and initiatives and their resource compliance in Azure Policy Compliance Checks.

✅ Ensured Proper Handling of Undefined Variables

  • Initialized $TotalInitResources, $TotalPolicyResources, $InitCompliantResources, $InitNonCompliantResources, $PolicyCompliantResources, and $PolicyNonCompliantResources to avoid potential null reference errors.

✅ Optimized Compliance Evaluation for Policies & Initiatives

  • If only an initiative has assigned resources, compliance is checked solely for that initiative.
  • If only a policy has assigned resources, compliance is checked solely for that policy.
  • If both an initiative and a policy have assigned resources, compliance is evaluated for both.

✅ Refined Compliance Status Determination

  • Fully non-compliant resources: Marked as non-compliant.
  • Partially non-compliant resources: Marked as non-compliant with a specific count.
  • All resources compliant: Marked as compliant.
  • No assigned resources: Marked as compliant with a note indicating no resources were found.

GR5 control will now take into account resource compliance for any policy or initiative that has the correct parameters and any exemptions attached to it

This PR fixes/adds/changes/removes

  1. guardrails.bicep file has a new initiative ID value
  2. config.json has a new initiative ID value
  3. Check-AllowedLocationPolicy.psm1 and Check-AllowedLocationPolicy.psd1 files are updated
  4. GR-ComplianceChecks-Msgs.psd1 messages typo fixed
  5. GR-Common.psm1 typo fixed

Breaking Changes

No breaking changes were made

Testing Evidence

Some resources were made non compliant for our CSPM Allowed Location Initiative:

image

The result corresponds to our requirements

As part of this Pull Request I have

  • Checked for duplicate Pull Requests
  • Associated it with relevant GitHub Issues
  • Ensured my code/branch is up-to-date with the latest changes in the main branch
  • Performed testing and provided evidence.
  • Updated relevant and associated documentation.
  • Ensure PowerShell module versions have been updated (manually or with the ./tools/Update-ModuleVersions.ps1 script)

@alalvi00 alalvi00 linked an issue Jan 22, 2025 that may be closed by this pull request
@alalvi00 alalvi00 changed the title Gr5 allowed location resource compliance aalvi [Enhancement] - GR5 Allowed Location Check + Policy Compliance Status Information Jan 22, 2025
Copy link
Contributor

@dutt0 dutt0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need to show the management groups in the workbook. Only subscription.

@alalvi00
Copy link
Contributor Author

We don't need to show the management groups in the workbook. Only subscription.

Please create a new ticket for this request as the current PR does not affect what is shown in the workbook

@alalvi00 alalvi00 requested a review from dutt0 January 23, 2025 15:27
@alalvi00 alalvi00 merged commit 20db195 into main Jan 23, 2025
4 checks passed
@alalvi00 alalvi00 deleted the gr5-allowedLocation-resourceCompliance_aalvi branch January 23, 2025 20:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

GR5: Allowed Location Check + Policy Compliance Status Information
3 participants