Skip to content

Commit 5c61eee

Browse files
ajmu1mabe13nsindhu26ThomasC-Kainosajmu1
authored
Release/shared resources nine (#1047)
# Release Branch Pull Request ## Description of Changes - DI Pen test WAF and DynamoDB changes - Integration test case optimization --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: Matthew Begley <60427904+mabe13@users.noreply.github.com> Co-authored-by: Sindhu Natarajan <nsindhupriya@hotmail.co.uk> Co-authored-by: ThomasC-Kainos <106971950+ThomasC-Kainos@users.noreply.github.com> Co-authored-by: ajmu1 <ajmu1@hscic.gov.uk> Co-authored-by: ManithaSrinivasa <142212846+ManithaSrinivasa@users.noreply.github.com>
1 parent bd99f32 commit 5c61eee

14 files changed

Lines changed: 107 additions & 27 deletions

File tree

build/automation/var/profile/demo.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ SLACK_ALERT_CHANNEL := dos-integration-dev-status
4040

4141
# WAF
4242
WAF_ENABLED := true
43+
DDB_DELETE_PROTECTION :=false
4344

4445
# ==============================================================================
4546
# Performance variables

build/automation/var/profile/dev.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ SLACK_ALERT_CHANNEL := dos-integration-dev-status
3939

4040
# WAF
4141
WAF_ENABLED := false
42+
DDB_DELETE_PROTECTION :=false
4243

4344
# ==============================================================================
4445
# Performance variables

build/automation/var/profile/live.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ SLACK_ALERT_CHANNEL := dos-integration-live-status
4141

4242
# WAF
4343
WAF_ENABLED := true
44+
DDB_DELETE_PROTECTION :=true
4445

4546
# ==============================================================================
4647
# Performance variables

build/automation/var/profile/pen.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22

33
# WAF
44
WAF_ENABLED := true
5+
DDB_DELETE_PROTECTION :=false

build/automation/var/profile/perf.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ SLACK_ALERT_CHANNEL := dos-integration-dev-status
3939

4040
# WAF
4141
WAF_ENABLED := true
42+
DDB_DELETE_PROTECTION :=false
4243

4344
# ==============================================================================
4445
# Performance variables

build/automation/var/profile/perf2.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ SLACK_ALERT_CHANNEL := dos-integration-dev-status
3939

4040
# WAF
4141
WAF_ENABLED := true
42+
DDB_DELETE_PROTECTION :=false
4243

4344
# ==============================================================================
4445
# Performance variables

build/automation/var/project.mk

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ TF_VAR_change_event_dlq := $(PROJECT_ID)-$(SHARED_ENVIRONMENT)-change-event-dead
109109
# Dynamodb
110110
TF_VAR_change_events_table_name := $(PROJECT_ID)-$(SHARED_ENVIRONMENT)-change-events
111111
DYNAMO_DB_TABLE := $(TF_VAR_change_events_table_name)
112+
TF_VAR_ddb_delete_protection :=$(DDB_DELETE_PROTECTION)
112113

113114
# Log Group Filters for Firehose
114115
TF_VAR_change_event_gateway_subscription_filter_name := $(PROJECT_ID)-$(SHARED_ENVIRONMENT)-change-event-api-gateway-cw-logs-firehose-subscription
@@ -140,6 +141,7 @@ TF_VAR_waf_ip_allow_list_rule_name := $(PROJECT_ID)-$(SHARED_ENVIRONMENT)-waf-ip
140141
TF_VAR_waf_rate_based_rule_name := $(PROJECT_ID)-$(SHARED_ENVIRONMENT)-waf-rate-based-rule
141142
TF_VAR_waf_aws_known_bad_inputs_rule_name := $(PROJECT_ID)-$(SHARED_ENVIRONMENT)-waf-aws-known-bad-inputs-rule
142143
TF_VAR_waf_aws_sqli_rule_name := $(PROJECT_ID)-$(SHARED_ENVIRONMENT)-waf-aws-sqli-rule
144+
TF_VAR_waf_custom_sqli_rule_name := $(PROJECT_ID)-$(SHARED_ENVIRONMENT)-waf-custom-sqli-rule
143145

144146
# -------------------------------
145147
# BLUE/GREEN ENVIRONMENT VARIABLES

infrastructure/stacks/shared-resources/cloudwatch-waf-alarms.tf

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,26 @@ resource "aws_cloudwatch_metric_alarm" "waf_aws_managed_sql_injection_blocked_re
118118
threshold = "1"
119119
}
120120

121+
resource "aws_cloudwatch_metric_alarm" "waf_custom_sql_injection_count_requests" {
122+
count = var.waf_enabled ? 1 : 0
123+
alarm_actions = [aws_sns_topic.shared_resources_sns_topic_app_alerts_for_slack_default_region.arn]
124+
alarm_description = "WAF Custom SQL Injection Count Requests"
125+
alarm_name = "${var.project_id} | ${var.shared_environment} | WAF Custom SQL Injection Count Requests"
126+
comparison_operator = "GreaterThanThreshold"
127+
datapoints_to_alarm = "1"
128+
dimensions = {
129+
Rule = var.waf_custom_sqli_rule_name
130+
WebACL = var.waf_acl_name,
131+
Region = var.aws_region
132+
}
133+
evaluation_periods = "1"
134+
metric_name = "CountedRequests"
135+
namespace = "AWS/WAFV2"
136+
period = "60"
137+
statistic = "Sum"
138+
threshold = "1"
139+
}
140+
121141
resource "aws_cloudwatch_metric_alarm" "waf_aws_managed_ip_reputation_list_blocked_requests" {
122142
count = var.waf_enabled ? 1 : 0
123143
alarm_actions = [aws_sns_topic.shared_resources_sns_topic_app_alerts_for_slack_default_region.arn]

infrastructure/stacks/shared-resources/dynamodb.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ resource "aws_dynamodb_table" "message-history-table" {
33
billing_mode = "PAY_PER_REQUEST"
44
hash_key = "Id"
55
range_key = "ODSCode"
6+
deletion_protection_enabled = var.ddb_delete_protection
67

78
server_side_encryption {
89
enabled = true

infrastructure/stacks/shared-resources/variables.tf

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,11 @@ variable "waf_enabled" {
158158
description = "Whether to enable WAF"
159159
}
160160

161+
variable "ddb_delete_protection" {
162+
type = bool
163+
description = "Whether to enable delete protection"
164+
}
165+
161166
variable "waf_acl_name" {
162167
type = string
163168
description = "Name of the WAF ACL"
@@ -211,3 +216,8 @@ variable "waf_aws_sqli_rule_name" {
211216
type = string
212217
description = "WAF AWS SQLi rule name"
213218
}
219+
220+
variable "waf_custom_sqli_rule_name" {
221+
type = string
222+
description = "WAF custom SQLi rule name"
223+
}

0 commit comments

Comments
 (0)