Skip to content

Commit f7cfb26

Browse files
sseehraTibap
andauthored
feat(google_fastly_waf): add baseline protection variable and adjust immediate block logic (#447)
* add baseline protection variable and adjust immediate block logic * Add possibility of customizing thresholds if necessary * Add validation rule --------- Co-authored-by: DimitriKirchner <dimitri.kirchner@gmail.com>
1 parent 522f76d commit f7cfb26

File tree

2 files changed

+38
-1
lines changed

2 files changed

+38
-1
lines changed

google_fastly_waf/main.tf

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,15 @@ resource "sigsci_site" "ngwaf_edge_site" {
310310
block_duration_seconds = 86400
311311
agent_anon_mode = ""
312312
agent_level = var.ngwaf_agent_level # this setting dictates blocking mode
313-
immediate_block = var.ngwaf_immediate_block
313+
immediate_block = var.ngwaf_baseline_protection ? false : var.ngwaf_immediate_block
314+
315+
dynamic "attack_threshold" {
316+
for_each = var.ngwaf_baseline_protection ? var.ngwaf_attack_thresholds : []
317+
content {
318+
interval = attack_threshold.value.interval
319+
threshold = attack_threshold.value.threshold
320+
}
321+
}
314322
}
315323

316324
resource "sigsci_edge_deployment_service_backend" "ngwaf_edge_service_backend_sync" {

google_fastly_waf/variables.tf

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,3 +133,32 @@ variable "ngwaf_percent_enabled" {
133133
type = number
134134
default = 100
135135
}
136+
137+
variable "ngwaf_baseline_protection" {
138+
type = bool
139+
default = false
140+
description = "When true, disables immediate blocking and enables baseline attack threshold alerts."
141+
}
142+
143+
variable "ngwaf_attack_thresholds" {
144+
type = list(object({
145+
interval = number
146+
threshold = number
147+
}))
148+
# To override the default thresholds, pass a custom list. Example:
149+
# ngwaf_attack_thresholds = [
150+
# { interval = 1, threshold = 50 },
151+
# { interval = 10, threshold = 200 },
152+
# { interval = 60, threshold = 1000 },
153+
# ]
154+
default = [
155+
{ interval = 1, threshold = 10 },
156+
{ interval = 10, threshold = 100 },
157+
{ interval = 60, threshold = 600 },
158+
]
159+
description = "Attack threshold configurations applied when ngwaf_baseline_protection is enabled."
160+
validation {
161+
condition = length(var.ngwaf_attack_thresholds) == 3
162+
error_message = "ngwaf_attack_thresholds must contain exactly 3 entries (one each for the 1, 10, and 60 minute intervals)."
163+
}
164+
}

0 commit comments

Comments
 (0)