Skip to content

Firewall Policy ThreatIntelWhitelist #12078

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

Merged
merged 14 commits into from Jun 11, 2020
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,13 @@ public void TestAzureFirewallPolicyCRUD()
{
TestRunner.RunTestScript("Test-AzureFirewallPolicyCRUD");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
[Trait(Category.Owner, NrpTeamAlias.azurefirewall)]
public void TestAzureFirewallPolicyWithThreatIntelWhitelistCRUD()
{
TestRunner.RunTestScript("Test-AzureFirewallPolicyWithThreatIntelWhitelistCRUD");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -236,4 +236,68 @@ function Test-AzureFirewallPolicyCRUD {
# Cleanup
Clean-ResourceGroup $rgname
}
}


<#
.SYNOPSIS
Tests AzureFirewallPolicyCRUD with ThreatIntelWhitelist.
#>
function Test-AzureFirewallPolicyWithThreatIntelWhitelistCRUD {
# Setup
$rgname = Get-ResourceGroupName
$azureFirewallPolicyName = Get-ResourceName
$azureFirewallPolicyAsJobName = Get-ResourceName
$resourceTypeParent = "Microsoft.Network/FirewallPolicies"
$location = "eastus2euap"

$ruleGroupName = Get-ResourceName
$threatIntelWhiteListIp1 = "20.3.4.5"
$threatIntelWhiteListIp2 = "37.1.2.3"
$threatIntelWhiteListIp3 = "208.199.20.37"
$threatIntelWhiteListFqdn1 = "microsoft.com"

try {
# Create the resource group
$resourceGroup = New-AzResourceGroup -Name $rgname -Location $location -Tags @{ testtag = "testval" }

$tiWhiteList = New-AzFirewallPolicyThreatIntelWhitelist -IpAddress $threatIntelWhiteListIp1,$threatIntelWhiteListIp2 -FQDN $threatIntelWhiteListFqdn1

# Create AzureFirewallPolicy (with no rules, ThreatIntel is in Alert mode by default)
$azureFirewallPolicy = New-AzFirewallPolicy -Name $azureFirewallPolicyName -ResourceGroupName $rgname -Location $location -ThreatIntelWhitelist $tiWhiteList

# Get AzureFirewallPolicy
$getAzureFirewallPolicy = Get-AzFirewallPolicy -Name $azureFirewallPolicyName -ResourceGroupName $rgname

#verification
Assert-AreEqual $rgName $getAzureFirewallPolicy.ResourceGroupName
Assert-AreEqual $azureFirewallPolicyName $getAzureFirewallPolicy.Name
Assert-NotNull $getAzureFirewallPolicy.Location
Assert-AreEqual $location $getAzureFirewallPolicy.Location
Assert-AreEqual "Alert" $getAzureFirewallPolicy.ThreatIntelMode
Assert-NotNull $getAzureFirewallPolicy.ThreatIntelWhitelist
Assert-AreEqual $threatIntelWhiteListIp1 $getAzureFirewallPolicy.ThreatIntelWhitelist.IpAddresses[0]
Assert-AreEqual $threatIntelWhiteListIp2 $getAzureFirewallPolicy.ThreatIntelWhitelist.IpAddresses[1]
Assert-AreEqual $threatIntelWhiteListFqdn1 $getAzureFirewallPolicy.ThreatIntelWhitelist.FQDNs[0]

# # Update ThreatIntel Whitelist
$azureFirewallPolicy.ThreatIntelWhitelist.IpAddresses[0] = $threatIntelWhiteListIp3

# Set AzureFirewallPolicy
Set-AzFirewallPolicy -InputObject $azureFirewallPolicy
# Get AzureFirewallPolicy
$getAzureFirewallPolicy = Get-AzFirewallPolicy -Name $azureFirewallPolicyName -ResourceGroupName $rgName

# #verification
Assert-AreEqual $rgName $getAzureFirewallPolicy.ResourceGroupName
Assert-AreEqual $azureFirewallPolicyName $getAzureFirewallPolicy.Name
Assert-NotNull $getAzureFirewallPolicy.Location
Assert-AreEqual $location $getAzureFirewallPolicy.Location
Assert-NotNull $getAzureFirewallPolicy.ThreatIntelWhitelist
Assert-AreEqual $threatIntelWhiteListIp3 $getAzureFirewallPolicy.ThreatIntelWhitelist.IpAddresses[0]
}
finally {
# Cleanup
Clean-ResourceGroup $rgname
}
}
Loading