Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/powershell/tests/Test-Assessment.25537.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Azure Firewall Threat intelligence-based filtering alerts and denies traffic from/to known malicious IP addresses, FQDNs, and URLs. The IP addresses, domains, and URLs are sourced from the Microsoft Threat Intelligence feed, which includes multiple sources including the Microsoft Cyber Security team. When threat intelligence-based filtering is enabled, Azure Firewall evaluates traffic against the threat intelligence rules before applying NAT, network, or application rules.

This check verifies that Threat Intelligence feature is enabled in “Alert and Deny” mode in the Azure Firewall policy configuration. The check will fail if Threat Intelligence is either “Disabled” or if it is not configured in “Alert and Deny” mode, in the firewall policy attached to the firewall.
Copy link

Copilot AI Jan 19, 2026

Choose a reason for hiding this comment

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

The description says the check evaluates “the firewall policy attached to the firewall”, but the implementation evaluates all firewall policies in the subscription(s), including potentially unattached policies. Please either update the implementation to scope to policies actually associated with Azure Firewalls, or adjust this documentation to match the implemented scope.

Suggested change
This check verifies that Threat Intelligence feature is enabled in “Alert and Deny” mode in the Azure Firewall policy configuration. The check will fail if Threat Intelligence is either “Disabled” or if it is not configured in “Alert and Deny” mode, in the firewall policy attached to the firewall.
This check verifies that the Threat Intelligence feature is enabled in “Alert and Deny” mode on Azure Firewall policies in the subscription. The check will fail if Threat Intelligence is either “Disabled” or not configured in “Alert and Deny” mode on any evaluated firewall policy.

Copilot uses AI. Check for mistakes.

**Remediation action**

Please check this article for guidance on how to enable Threat Intelligence in “Alert and Deny” mode in the Azure Firewall Policy:
Comment on lines +3 to +7
Copy link

Copilot AI Jan 19, 2026

Choose a reason for hiding this comment

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

This markdown uses smart quotes (“ ”) around mode names. The rest of the repo’s markdown files appear to use straight quotes; consider switching to standard ASCII quotes to avoid encoding/rendering inconsistencies across tooling.

Copilot uses AI. Check for mistakes.
- [Azure Firewall threat intelligence configuration | Microsoft Learn](https://learn.microsoft.com/en-us/azure/firewall-manager/threat-intelligence-settings)

<!--- Results --->
%TestResult%
140 changes: 140 additions & 0 deletions src/powershell/tests/Test-Assessment.25537.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
<#
.SYNOPSIS
Validates Threat intelligence is Enabled in Deny Mode on Azure Firewall.
.DESCRIPTION
This test validates that Azure Firewall Policies have Threat Intelligence enabled in Deny mode.
Checks all firewall policies in the subscription and reports their threat intelligence status.
Copy link

Copilot AI Jan 19, 2026

Choose a reason for hiding this comment

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

The comment-based help says this “checks all firewall policies in the subscription”, but the implementation enumerates all subscriptions via Get-AzSubscription and loops through each. Please align the description with the actual behavior (either scope to current subscription only, or update the comment to say it iterates all accessible subscriptions).

Suggested change
Checks all firewall policies in the subscription and reports their threat intelligence status.
Checks all firewall policies across all accessible subscriptions and reports their threat intelligence status.

Copilot uses AI. Check for mistakes.
.NOTES
Test ID: 25537
Category: Azure Network Security
Required API: Azure Firewall Policies
#>

function Test-Assessment-25537 {
[ZtTest(
Category = 'Azure Network Security',
ImplementationCost = 'Low',
MinimumLicense = ('Azure_Firewall_Standard', 'Azure_Firewall_Premium'),
Pillar = 'Network',
RiskLevel = 'High',
SfiPillar = 'Protect networks',
TenantType = ('Workforce'),
TestId = 25537,
Title = 'Threat intelligence is Enabled in Deny Mode on Azure Firewall',
UserImpact = 'Low'
)]
[CmdletBinding()]
param()

Write-PSFMessage '🟦 Start' -Tag Test -Level VeryVerbose

#region Data Collection
Write-ZtProgress `
-Activity 'Azure Firewall Threat Intelligence' `
-Status 'Enumerating Firewall Policies'

$subscriptions = Get-AzSubscription
$results = @()
foreach ($sub in $subscriptions) {
Set-AzContext -SubscriptionId $sub.Id | Out-Null
# Get all firewall policies in the subscription
$policies = Get-AzResource -ResourceType 'Microsoft.Network/firewallPolicies' -ErrorAction Stop
Comment on lines +39 to +41
Copy link

Copilot AI Jan 19, 2026

Choose a reason for hiding this comment

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

Set-AzContext is invoked without -ErrorAction Stop / error handling. If context switching fails, the loop may continue using a previous context and attribute results to the wrong subscription. Please make context switching a terminating operation and handle failures explicitly (e.g., try/catch per subscription and continue/skip as appropriate).

Suggested change
Set-AzContext -SubscriptionId $sub.Id | Out-Null
# Get all firewall policies in the subscription
$policies = Get-AzResource -ResourceType 'Microsoft.Network/firewallPolicies' -ErrorAction Stop
try {
Set-AzContext -SubscriptionId $sub.Id -ErrorAction Stop | Out-Null
# Get all firewall policies in the subscription
$policies = Get-AzResource -ResourceType 'Microsoft.Network/firewallPolicies' -ErrorAction Stop
}
catch {
Write-PSFMessage "Failed to set context or enumerate firewall policies for subscription '$($sub.Id)': $($_.Exception.Message)" -Tag Test -Level Error
continue
}

Copilot uses AI. Check for mistakes.

Comment on lines +36 to +42
Copy link

Copilot AI Jan 19, 2026

Choose a reason for hiding this comment

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

This test uses Az cmdlets (Get-AzSubscription/Set-AzContext/Get-AzResource) but doesn’t follow the repo’s established Azure-connection handling. If the user isn’t connected to Azure or lacks subscription access, this will error rather than producing a skipped result. Consider following the pattern used in src/powershell/tests/Test-Assessment.21788.ps1:27-55 and Test-Assessment.21860.ps1:33-60 (Get-AzAccessToken check + catch 403) and call Add-ZtTestResultDetail -SkippedBecause NotConnectedAzure/NoAzureAccess accordingly.

Copilot uses AI. Check for mistakes.
if (-not $policies) {
continue
}

#endregion Data Collection
#region Assessment Logic

foreach ($policyResource in $policies) {
$policy = Get-AzFirewallPolicy `
-Name $policyResource.Name `
-ResourceGroupName $policyResource.ResourceGroupName `
-ErrorAction SilentlyContinue

if (-not $policy) {
continue
}

$subContext = Get-AzContext
$status = if ($policy.ThreatIntelMode -eq 'Deny') {
'Pass'
}
else {
'Fail'
}

$results += [PSCustomObject]@{
CheckName = 'Threat intelligence is Enabled in Deny Mode on Azure Firewall'
PolicyName = $policy.Name
ResourceGroup = $policy.ResourceGroupName
SubscriptionName = $subContext.Subscription.Name
SubscriptionId = $subContext.Subscription.Id
ThreatIntelMode = $policy.ThreatIntelMode
Status = $status
}
}
}
#endregion Assessment Logic

#region Assessment Logic Evaluation
if (-not $results) {
Write-PSFMessage 'No Azure Firewall policies found. Skipping test.' -Tag Firewall -Level Verbose
Copy link

Copilot AI Jan 19, 2026

Choose a reason for hiding this comment

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

When no firewall policies are found, the function returns without calling Add-ZtTestResultDetail. Since results are collected via Add-ZtTestResultDetail, this test will produce no report entry in that case. Please emit an explicit result (pass/not-applicable or a skipped status via -SkippedBecause NotSupported) instead of returning silently.

Suggested change
Write-PSFMessage 'No Azure Firewall policies found. Skipping test.' -Tag Firewall -Level Verbose
Write-PSFMessage 'No Azure Firewall policies found. Skipping test.' -Tag Firewall -Level Verbose
Add-ZtTestResultDetail -SkippedBecause NotSupported -Description 'No Azure Firewall policies found in any subscription.'

Copilot uses AI. Check for mistakes.
return
}
else {
$allModes = $results.ThreatIntelMode
$uniqueModes = $allModes | Select-Object -Unique

if ($uniqueModes.Count -eq 1 -and $uniqueModes -eq 'Deny') {

$passed = $true
$testResultMarkdown = 'Threat Intel is enabled in **Alert and Deny** mode.'

}
else {
Comment on lines +90 to +96
Copy link

Copilot AI Jan 19, 2026

Choose a reason for hiding this comment

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

The output messaging mixes “Deny mode” (test title/check name) with “Alert and Deny mode” (result text/title). Since the pass condition is ThreatIntelMode == 'Deny', consider standardizing the wording throughout (either consistently refer to the Azure enum value 'Deny' or consistently explain it as 'Alert and Deny') to avoid confusing users.

Copilot uses AI. Check for mistakes.

$passed = $false

if ($uniqueModes.Count -eq 1) {

switch ($uniqueModes) {
'Alert' {
$testResultMarkdown = 'Threat Intel is enabled in **Alert** mode.'
}
'Off' {
$testResultMarkdown = 'Threat Intel is **disabled**.'
}
default {
$testResultMarkdown = 'Threat Intel is not enabled in **Alert and Deny** mode for all Firewall policies.'
}
}
}
else {
$testResultMarkdown = 'Threat Intel is not enabled in **Alert and Deny** mode for all Firewall policies.'
}
}

# --- Markdown Table ---
$mdInfo = "`n`n## Firewall Policies`n`n"
$mdInfo += "| Check name | Policy name | Subscription name | Subscription id | Threat Intel Mode |`n"
$mdInfo += "| :--- | :--- | :--- | :--- | :---: |`n"

foreach ($item in $results | Sort-Object PolicyName) {
$mdInfo += "| $($item.CheckName) | $($item.PolicyName) | $($item.SubscriptionName) | $($item.SubscriptionId) | $($item.ThreatIntelMode) |`n"
Comment on lines +121 to +125
Copy link

Copilot AI Jan 19, 2026

Choose a reason for hiding this comment

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

The results table omits Resource Group (and per-policy pass/fail) even though you collect ResourceGroup/Status in $results. Without Resource Group it can be hard to uniquely identify a policy (names can repeat across RGs). Consider adding Resource Group (and optionally Status) columns to the markdown table.

Suggested change
$mdInfo += "| Check name | Policy name | Subscription name | Subscription id | Threat Intel Mode |`n"
$mdInfo += "| :--- | :--- | :--- | :--- | :---: |`n"
foreach ($item in $results | Sort-Object PolicyName) {
$mdInfo += "| $($item.CheckName) | $($item.PolicyName) | $($item.SubscriptionName) | $($item.SubscriptionId) | $($item.ThreatIntelMode) |`n"
$mdInfo += "| Check name | Policy name | Subscription name | Subscription id | Resource group | Status | Threat Intel Mode |`n"
$mdInfo += "| :--- | :--- | :--- | :--- | :--- | :---: | :---: |`n"
foreach ($item in $results | Sort-Object PolicyName) {
$mdInfo += "| $($item.CheckName) | $($item.PolicyName) | $($item.SubscriptionName) | $($item.SubscriptionId) | $($item.ResourceGroup) | $($item.Status) | $($item.ThreatIntelMode) |`n"

Copilot uses AI. Check for mistakes.
}

$testResultMarkdown += $mdInfo

#endregion Assessment Logic Evaluation

#region Report Generation
Add-ZtTestResultDetail `
-TestId '25537' `
-Title 'Azure Firewall Threat Intelligence is enabled in Alert and Deny mode' `
-Status $passed `
-Result $testResultMarkdown
#endregion Report Generation
}
}