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

Add table azure_web_application_firewall_policy Closes #827 #834

Merged
merged 2 commits into from
Sep 2, 2024
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
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[
{
"id": "{{ output.resource_id.value }}",
"name": "{{ resourceName }}",
"region": "{{ output.region.value }}",
"resource_group": "{{ resourceName }}",
"subscription_id": "{{ output.subscription_id.value }}",
"type": "Microsoft.Network/ApplicationGatewayWebApplicationFirewallPolicies"
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
select name, id, type, region, resource_group, subscription_id
from azure.azure_web_application_firewall_policy
where name = '{{ resourceName }}' and resource_group = '{{ resourceName }}';
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[
{
"id": "{{ output.resource_id.value }}",
"name": "{{ resourceName }}",
"region": "{{ output.region.value }}",
"resource_group": "{{ resourceName }}",
"subscription_id": "{{ output.subscription_id.value }}",
"type": "Microsoft.Network/ApplicationGatewayWebApplicationFirewallPolicies"
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
select name, id, type, region, resource_group, subscription_id
from azure.azure_web_application_firewall_policy
where id = '{{ output.resource_id.value }}';
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[]
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
select name, id, type, region
from azure.azure_web_application_firewall_policy
where name = 'dummy-test{{ resourceName }}' and resource_group = '{{ resourceName }}';
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[
{
"akas": [
"{{ output.resource_aka.value }}",
"{{ output.resource_aka_lower.value }}"
],
"name": "{{ resourceName }}",
"title": "{{ resourceName }}"
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
select name, akas, title
from azure.azure_web_application_firewall_policy
where name = '{{ resourceName }}' and resource_group = '{{ resourceName }}';
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
142 changes: 142 additions & 0 deletions azure-test/tests/azure_web_application_firewall_policy/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
variable "resource_name" {
type = string
default = "turbot-test-20200125-create-update"
description = "Name of the resource used throughout the test."
}

variable "azure_environment" {
type = string
default = "public"
description = "Azure environment used for the test."
}

variable "azure_subscription" {
type = string
default = "3510ae4d-530b-497d-8f30-53b9616fc6c1"
description = "Azure environment used for the test."
}

terraform {
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = "=2.75.0"
}
}
}

provider "azurerm" {
# Cannot be passed as a variable
environment = var.azure_environment
subscription_id = var.azure_subscription
features {}
}

resource "azurerm_resource_group" "named_test_resource" {
name = var.resource_name
location = "West Europe"
}

resource "azurerm_web_application_firewall_policy" "named_test_resource" {
name = var.resource_name
resource_group_name = azurerm_resource_group.named_test_resource.name
location = azurerm_resource_group.named_test_resource.location

custom_rules {
name = "Rule1"
priority = 1
rule_type = "MatchRule"

match_conditions {
match_variables {
variable_name = "RemoteAddr"
}

operator = "IPMatch"
negation_condition = false
match_values = ["192.168.1.0/24", "10.0.0.0/24"]
}

action = "Block"
}

custom_rules {
name = "Rule2"
priority = 2
rule_type = "MatchRule"

match_conditions {
match_variables {
variable_name = "RemoteAddr"
}

operator = "IPMatch"
negation_condition = false
match_values = ["192.168.1.0/24"]
}

match_conditions {
match_variables {
variable_name = "RequestHeaders"
selector = "UserAgent"
}

operator = "Contains"
negation_condition = false
match_values = ["Windows"]
}

action = "Block"
}

policy_settings {
enabled = true
mode = "Prevention"
request_body_check = true
file_upload_limit_in_mb = 100
max_request_body_size_in_kb = 128
}

managed_rules {
exclusion {
match_variable = "RequestHeaderNames"
selector = "x-company-secret-header"
selector_match_operator = "Equals"
}
exclusion {
match_variable = "RequestCookieNames"
selector = "too-tasty"
selector_match_operator = "EndsWith"
}

managed_rule_set {
type = "OWASP"
version = "3.2"
}
}
}

output "region" {
value = azurerm_resource_group.named_test_resource.location
}

output "resource_aka" {
depends_on = [azurerm_web_application_firewall_policy.named_test_resource]
value = "azure://${azurerm_web_application_firewall_policy.named_test_resource.id}"
}

output "resource_aka_lower" {
value = "azure://${lower(azurerm_web_application_firewall_policy.named_test_resource.id)}"
}

output "resource_name" {
value = var.resource_name
}

output "resource_id" {
value = azurerm_web_application_firewall_policy.named_test_resource.id
}

output "subscription_id" {
value = var.azure_subscription
}
1 change: 1 addition & 0 deletions azure/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ func Plugin(ctx context.Context) *plugin.Plugin {
"azure_tenant": tableAzureTenant(ctx),
"azure_virtual_network": tableAzureVirtualNetwork(ctx),
"azure_virtual_network_gateway": tableAzureVirtualNetworkGateway(ctx),
"azure_web_application_firewall_policy": tableAzureWebApplicationFirewallPolicy(ctx),
},
}

Expand Down
Loading
Loading