Skip to content

Commit 6ad9900

Browse files
authored
Merge branch 'main' into marrobi/add-soft-delete
2 parents de7291c + e58a472 commit 6ad9900

File tree

17 files changed

+115
-25
lines changed

17 files changed

+115
-25
lines changed

airlock_processor/BlobCreatedTrigger/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def main(msg: func.ServiceBusMessage,
3232
logging.error("environment variable 'ENABLE_MALWARE_SCANNING' does not exists. Cannot continue.")
3333
raise
3434

35-
if enable_malware_scanning and constants.STORAGE_ACCOUNT_NAME_IMPORT_INPROGRESS in topic:
35+
if enable_malware_scanning and (constants.STORAGE_ACCOUNT_NAME_IMPORT_INPROGRESS in topic or constants.STORAGE_ACCOUNT_NAME_EXPORT_INPROGRESS in topic):
3636
# If malware scanning is enabled, the fact that the blob was created can be dismissed.
3737
# It will be consumed by the malware scanning service
3838
logging.info('Malware scanning is enabled. no action to perform.')

airlock_processor/_version.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "0.8.3"
1+
__version__ = "0.8.4"

core/terraform/airlock/outputs.tf

+4
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,7 @@ output "event_grid_status_changed_topic_resource_id" {
1717
output "event_grid_airlock_notification_topic_resource_id" {
1818
value = azurerm_eventgrid_topic.airlock_notification.id
1919
}
20+
21+
output "airlock_malware_scan_result_topic_name" {
22+
value = local.scan_result_topic_name
23+
}

core/terraform/json-to-env.sh

+4
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,10 @@ jq -r '
113113
{
114114
"path": "event_grid_airlock_notification_topic_resource_id",
115115
"env_var": "EVENT_GRID_AIRLOCK_NOTIFICATION_TOPIC_RESOURCE_ID"
116+
},
117+
{
118+
"path": "airlock_malware_scan_result_topic_name",
119+
"env_var": "AIRLOCK_MALWARE_SCAN_RESULT_TOPIC_NAME"
116120
}
117121
]
118122
as $env_vars_to_extract

core/terraform/main.tf

+2
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,8 @@ module "resource_processor_vmss_porter" {
188188
enable_cmk_encryption = var.enable_cmk_encryption
189189
key_store_id = local.key_store_id
190190
kv_encryption_key_name = local.cmk_name
191+
enable_airlock_malware_scanning = var.enable_airlock_malware_scanning
192+
airlock_malware_scan_result_topic_name = module.airlock_resources.airlock_malware_scan_result_topic_name
191193

192194
depends_on = [
193195
module.network,

core/terraform/resource_processor/vmss_porter/locals.tf

+5-3
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,11 @@ locals {
1313
rp_bundle_values_all = merge(var.rp_bundle_values, {
1414
// Add any additional settings like ones from the config.yaml here
1515
// to make them available for bundles.
16-
firewall_sku = var.firewall_sku
17-
enable_cmk_encryption = var.enable_cmk_encryption
18-
key_store_id = var.key_store_id
16+
firewall_sku = var.firewall_sku
17+
enable_cmk_encryption = var.enable_cmk_encryption
18+
key_store_id = var.key_store_id
19+
enable_airlock_malware_scanning = var.enable_airlock_malware_scanning
20+
airlock_malware_scan_result_topic_name = var.airlock_malware_scan_result_topic_name
1921
})
2022
rp_bundle_values_dic = [for key in keys(local.rp_bundle_values_all) : "RP_BUNDLE_${key}=${local.rp_bundle_values_all[key]}"]
2123
rp_bundle_values_formatted = join("\n ", local.rp_bundle_values_dic)

core/terraform/resource_processor/vmss_porter/variables.tf

+10
Original file line numberDiff line numberDiff line change
@@ -93,3 +93,13 @@ variable "kv_encryption_key_name" {
9393
type = string
9494
description = "Name of Key Vault Encryption Key (only used if enable_cmk_encryption is true)"
9595
}
96+
97+
variable "enable_airlock_malware_scanning" {
98+
type = bool
99+
description = "If False, Airlock requests will skip the malware scanning stage"
100+
}
101+
102+
variable "airlock_malware_scan_result_topic_name" {
103+
type = string
104+
description = "Name of the topic to publish Airlock malware scan results to"
105+
}

core/version.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "0.12.10"
1+
__version__ = "0.12.11"

templates/workspaces/base/porter.yaml

+15-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
schemaVersion: 1.0.0
33
name: tre-workspace-base
4-
version: 2.1.1
4+
version: 2.1.2
55
description: "A base Azure TRE workspace"
66
dockerfile: Dockerfile.tmpl
77
registry: azuretre
@@ -126,6 +126,14 @@ parameters:
126126
type: string
127127
default: "GRS"
128128
description: "The redundancy option for the storage account in the workspace: GRS (Geo-Redundant Storage) or ZRS (Zone-Redundant Storage)."
129+
- name: enable_airlock_malware_scanning
130+
type: boolean
131+
default: false
132+
description: "Enable malware scanning on the workspace storage account"
133+
- name: airlock_malware_scan_result_topic_name
134+
type: string
135+
default: ""
136+
description: "The name of the topic to publish scan results to"
129137

130138
outputs:
131139
- name: app_role_id_workspace_owner
@@ -196,6 +204,8 @@ install:
196204
enable_cmk_encryption: ${ bundle.parameters.enable_cmk_encryption }
197205
key_store_id: ${ bundle.parameters.key_store_id }
198206
storage_account_redundancy: ${ bundle.parameters.storage_account_redundancy }
207+
enable_airlock_malware_scanning: ${ bundle.parameters.enable_airlock_malware_scanning }
208+
airlock_malware_scan_result_topic_name: ${ bundle.parameters.airlock_malware_scan_result_topic_name }
199209
backendConfig:
200210
use_azuread_auth: "true"
201211
use_oidc: "true"
@@ -241,6 +251,8 @@ upgrade:
241251
enable_cmk_encryption: ${ bundle.parameters.enable_cmk_encryption }
242252
key_store_id: ${ bundle.parameters.key_store_id }
243253
storage_account_redundancy: ${ bundle.parameters.storage_account_redundancy }
254+
enable_airlock_malware_scanning: ${ bundle.parameters.enable_airlock_malware_scanning }
255+
airlock_malware_scan_result_topic_name: ${ bundle.parameters.airlock_malware_scan_result_topic_name }
244256
backendConfig:
245257
use_azuread_auth: "true"
246258
use_oidc: "true"
@@ -309,6 +321,8 @@ uninstall:
309321
enable_cmk_encryption: ${ bundle.parameters.enable_cmk_encryption }
310322
key_store_id: ${ bundle.parameters.key_store_id }
311323
storage_account_redundancy: ${ bundle.parameters.storage_account_redundancy }
324+
enable_airlock_malware_scanning: ${ bundle.parameters.enable_airlock_malware_scanning }
325+
airlock_malware_scan_result_topic_name: ${ bundle.parameters.airlock_malware_scan_result_topic_name }
312326
backendConfig:
313327
use_azuread_auth: "true"
314328
use_oidc: "true"

templates/workspaces/base/terraform/airlock/data.tf

+6
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,9 @@ data "azurerm_servicebus_topic" "blob_created" {
2323
resource_group_name = local.core_resource_group_name
2424
namespace_name = data.azurerm_servicebus_namespace.airlock_sb.name
2525
}
26+
27+
data "azurerm_eventgrid_topic" "scan_result" {
28+
count = var.enable_airlock_malware_scanning ? 1 : 0
29+
name = local.airlock_malware_scan_result_topic_name
30+
resource_group_name = local.core_resource_group_name
31+
}

templates/workspaces/base/terraform/airlock/eventgrid_topics.tf

-1
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,6 @@ resource "azurerm_role_assignment" "servicebus_sender_export_blocked_blob_create
142142
]
143143
}
144144

145-
146145
## Subscriptions
147146
resource "azurerm_eventgrid_event_subscription" "import_approved_blob_created" {
148147
name = "import-approved-blob-created-${var.short_workspace_id}"

templates/workspaces/base/terraform/airlock/locals.tf

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ locals {
77
export_rejected_sys_topic_name = "evgt-airlock-export-rejected-${local.workspace_resource_name_suffix}"
88
export_blocked_sys_topic_name = "evgt-airlock-export-blocked-${local.workspace_resource_name_suffix}"
99

10-
blob_created_topic_name = "airlock-blob-created"
10+
blob_created_topic_name = "airlock-blob-created"
11+
airlock_malware_scan_result_topic_name = var.airlock_malware_scan_result_topic_name
1112

1213
# STorage AirLock IMport APProved
1314
import_approved_storage_name = lower(replace("stalimapp${substr(local.workspace_resource_name_suffix, -8, -1)}", "-", ""))

templates/workspaces/base/terraform/airlock/providers.tf

+4
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ terraform {
55
source = "hashicorp/azurerm"
66
version = ">= 3.117.0"
77
}
8+
azapi = {
9+
source = "Azure/azapi"
10+
version = ">= 1.15.0"
11+
}
812
}
913
}
1014

templates/workspaces/base/terraform/airlock/storage_accounts.tf

+26-2
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ resource "azurerm_storage_account" "sa_export_inprogress" {
162162
shared_access_key_enabled = false
163163
local_user_enabled = false
164164

165-
# Important! we rely on the fact that the blob craeted events are issued when the creation of the blobs are done.
165+
# Important! we rely on the fact that the blob created events are issued when the creation of the blobs are done.
166166
# This is true ONLY when Hierarchical Namespace is DISABLED
167167
is_hns_enabled = false
168168

@@ -207,7 +207,6 @@ resource "azurerm_storage_account_network_rules" "sa_export_inprogress_rules" {
207207
bypass = ["AzureServices"]
208208
}
209209

210-
211210
resource "azurerm_private_endpoint" "export_inprogress_pe" {
212211
name = "pe-sa-export-ip-blob-${var.short_workspace_id}"
213212
location = var.location
@@ -230,6 +229,31 @@ resource "azurerm_private_endpoint" "export_inprogress_pe" {
230229
}
231230
}
232231

232+
# Enable Airlock Malware Scanning on Core TRE for Export In-Progress
233+
resource "azapi_resource_action" "enable_defender_for_storage_export" {
234+
count = var.enable_airlock_malware_scanning ? 1 : 0
235+
type = "Microsoft.Security/defenderForStorageSettings@2022-12-01-preview"
236+
resource_id = "${azurerm_storage_account.sa_export_inprogress.id}/providers/Microsoft.Security/defenderForStorageSettings/current"
237+
method = "PUT"
238+
239+
body = jsonencode({
240+
properties = {
241+
isEnabled = true
242+
malwareScanning = {
243+
onUpload = {
244+
isEnabled = true
245+
capGBPerMonth = 5000
246+
},
247+
scanResultsEventGridTopicResourceId = data.azurerm_eventgrid_topic.scan_result[0].id
248+
}
249+
sensitiveDataDiscovery = {
250+
isEnabled = false
251+
}
252+
overrideSubscriptionLevelSettings = true
253+
}
254+
})
255+
}
256+
233257
# 'Rejected' location for export
234258
resource "azurerm_storage_account" "sa_export_rejected" {
235259
name = local.export_rejected_storage_name

templates/workspaces/base/terraform/airlock/variables.tf

+6
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,9 @@ variable "encryption_identity_id" {
3434
variable "encryption_key_versionless_id" {
3535
type = string
3636
}
37+
variable "enable_airlock_malware_scanning" {
38+
type = bool
39+
}
40+
variable "airlock_malware_scan_result_topic_name" {
41+
type = string
42+
}

templates/workspaces/base/terraform/variables.tf

+12
Original file line numberDiff line numberDiff line change
@@ -139,3 +139,15 @@ variable "storage_account_redundancy" {
139139
default = "GRS"
140140
description = "The redundancy option for the storage account in the workspace: GRS (Geo-Redundant Storage) or ZRS (Zone-Redundant Storage)."
141141
}
142+
143+
variable "enable_airlock_malware_scanning" {
144+
type = bool
145+
default = false
146+
description = "Enable Airlock malware scanning for the workspace"
147+
}
148+
149+
variable "airlock_malware_scan_result_topic_name" {
150+
type = string
151+
description = "The name of the topic to publish scan results to"
152+
default = null
153+
}

templates/workspaces/base/terraform/workspace.tf

+16-14
Original file line numberDiff line numberDiff line change
@@ -45,20 +45,22 @@ module "aad" {
4545
}
4646

4747
module "airlock" {
48-
count = var.enable_airlock ? 1 : 0
49-
source = "./airlock"
50-
location = var.location
51-
tre_id = var.tre_id
52-
tre_workspace_tags = local.tre_workspace_tags
53-
ws_resource_group_name = azurerm_resource_group.ws.name
54-
enable_local_debugging = var.enable_local_debugging
55-
services_subnet_id = module.network.services_subnet_id
56-
short_workspace_id = local.short_workspace_id
57-
airlock_processor_subnet_id = module.network.airlock_processor_subnet_id
58-
arm_environment = var.arm_environment
59-
enable_cmk_encryption = var.enable_cmk_encryption
60-
encryption_key_versionless_id = var.enable_cmk_encryption ? azurerm_key_vault_key.encryption_key[0].versionless_id : null
61-
encryption_identity_id = var.enable_cmk_encryption ? azurerm_user_assigned_identity.encryption_identity[0].id : null
48+
count = var.enable_airlock ? 1 : 0
49+
source = "./airlock"
50+
location = var.location
51+
tre_id = var.tre_id
52+
tre_workspace_tags = local.tre_workspace_tags
53+
ws_resource_group_name = azurerm_resource_group.ws.name
54+
enable_local_debugging = var.enable_local_debugging
55+
services_subnet_id = module.network.services_subnet_id
56+
short_workspace_id = local.short_workspace_id
57+
airlock_processor_subnet_id = module.network.airlock_processor_subnet_id
58+
arm_environment = var.arm_environment
59+
enable_cmk_encryption = var.enable_cmk_encryption
60+
encryption_key_versionless_id = var.enable_cmk_encryption ? azurerm_key_vault_key.encryption_key[0].versionless_id : null
61+
encryption_identity_id = var.enable_cmk_encryption ? azurerm_user_assigned_identity.encryption_identity[0].id : null
62+
enable_airlock_malware_scanning = var.enable_airlock_malware_scanning
63+
airlock_malware_scan_result_topic_name = var.enable_airlock_malware_scanning ? var.airlock_malware_scan_result_topic_name : null
6264
depends_on = [
6365
module.network,
6466
]

0 commit comments

Comments
 (0)