From 567519f95f3f93fc1d8bd9c887f0040d775aed20 Mon Sep 17 00:00:00 2001 From: Andre Pereira <219305055+cx-andre-pereira@users.noreply.github.com> Date: Tue, 19 Aug 2025 15:40:55 +0100 Subject: [PATCH 1/2] better testing for query --- .../test/negative.tf | 12 ------ .../test/negative1.tf | 41 +++++++++++++++++++ .../test/negative2.tf | 19 +++++++++ .../test/{positive.tf => positive1.tf} | 14 +++---- .../test/positive_expected_result.json | 3 +- 5 files changed, 69 insertions(+), 20 deletions(-) delete mode 100644 assets/queries/terraform/azure/storage_share_allows_all_acl_permissions/test/negative.tf create mode 100644 assets/queries/terraform/azure/storage_share_allows_all_acl_permissions/test/negative1.tf create mode 100644 assets/queries/terraform/azure/storage_share_allows_all_acl_permissions/test/negative2.tf rename assets/queries/terraform/azure/storage_share_allows_all_acl_permissions/test/{positive.tf => positive1.tf} (71%) diff --git a/assets/queries/terraform/azure/storage_share_allows_all_acl_permissions/test/negative.tf b/assets/queries/terraform/azure/storage_share_allows_all_acl_permissions/test/negative.tf deleted file mode 100644 index 57ee6f2b13e..00000000000 --- a/assets/queries/terraform/azure/storage_share_allows_all_acl_permissions/test/negative.tf +++ /dev/null @@ -1,12 +0,0 @@ -resource "azurerm_storage_table" "table_resource2" { - name = "my_table_name" - storage_account_name = "mystoragexxx" - acl { - id = "someid-1XXXXXXXXX" - access_policy { - expiry = "2022-10-03T05:05:00.0000000Z" - permissions = "r" - start = "2021-05-28T04:05:00.0000000Z" - } - } -} diff --git a/assets/queries/terraform/azure/storage_share_allows_all_acl_permissions/test/negative1.tf b/assets/queries/terraform/azure/storage_share_allows_all_acl_permissions/test/negative1.tf new file mode 100644 index 00000000000..1fe3e7bae40 --- /dev/null +++ b/assets/queries/terraform/azure/storage_share_allows_all_acl_permissions/test/negative1.tf @@ -0,0 +1,41 @@ +resource "azurerm_storage_share_file" "example" { + name = "my-awesome-content.zip" + storage_share_id = azurerm_storage_share.negative1.id + source = "some-local-file.zip" +} + +resource "azurerm_storage_share" "negative1" { + name = "neg1" + storage_account_name = azurerm_storage_account.example.name + quota = 50 + + acl { + id = "MTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTI" + + access_policy { + permissions = "r" + start = "2022-07-02T09:38:21.0000000Z" + expiry = "2021-07-02T10:38:21.0000000Z" + } + } +} + +resource "azurerm_storage_share" "negative2" { + name = "neg2" + storage_account_name = azurerm_storage_account.invalid_resource.name + quota = 50 + + acl { + id = "MTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTI" + + access_policy { + permissions = "rwdl" + start = "2022-07-02T09:38:21.0000000Z" + expiry = "2021-07-02T10:38:21.0000000Z" + } + } +} + + + + diff --git a/assets/queries/terraform/azure/storage_share_allows_all_acl_permissions/test/negative2.tf b/assets/queries/terraform/azure/storage_share_allows_all_acl_permissions/test/negative2.tf new file mode 100644 index 00000000000..a48c77b4570 --- /dev/null +++ b/assets/queries/terraform/azure/storage_share_allows_all_acl_permissions/test/negative2.tf @@ -0,0 +1,19 @@ +resource "azurerm_storage_share" "negative2" { + name = "neg2" + storage_account_name = azurerm_storage_account.invalid_resource.name + quota = 50 + + acl { + id = "MTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTI" + + access_policy { + permissions = "rwdl" + start = "2022-07-02T09:38:21.0000000Z" + expiry = "2021-07-02T10:38:21.0000000Z" + } + } +} + + + + diff --git a/assets/queries/terraform/azure/storage_share_allows_all_acl_permissions/test/positive.tf b/assets/queries/terraform/azure/storage_share_allows_all_acl_permissions/test/positive1.tf similarity index 71% rename from assets/queries/terraform/azure/storage_share_allows_all_acl_permissions/test/positive.tf rename to assets/queries/terraform/azure/storage_share_allows_all_acl_permissions/test/positive1.tf index 4e00c2c3bd1..8175c67c37c 100644 --- a/assets/queries/terraform/azure/storage_share_allows_all_acl_permissions/test/positive.tf +++ b/assets/queries/terraform/azure/storage_share_allows_all_acl_permissions/test/positive1.tf @@ -1,4 +1,10 @@ -resource "azurerm_storage_share" "example" { +resource "azurerm_storage_share_file" "positive1" { + name = "my-awesome-content.zip" + storage_share_id = azurerm_storage_share.default_storage_share.id + source = "some-local-file.zip" +} + +resource "azurerm_storage_share" "default_storage_share" { name = "sharename" storage_account_name = azurerm_storage_account.example.name quota = 50 @@ -13,9 +19,3 @@ resource "azurerm_storage_share" "example" { } } } - -resource "azurerm_storage_share_file" "example" { - name = "my-awesome-content.zip" - storage_share_id = azurerm_storage_share.example.id - source = "some-local-file.zip" -} diff --git a/assets/queries/terraform/azure/storage_share_allows_all_acl_permissions/test/positive_expected_result.json b/assets/queries/terraform/azure/storage_share_allows_all_acl_permissions/test/positive_expected_result.json index dab953426b5..61688033065 100644 --- a/assets/queries/terraform/azure/storage_share_allows_all_acl_permissions/test/positive_expected_result.json +++ b/assets/queries/terraform/azure/storage_share_allows_all_acl_permissions/test/positive_expected_result.json @@ -2,6 +2,7 @@ { "queryName": "Storage Share Allows All ACL Permissions", "severity": "MEDIUM", - "line": 10 + "line": 16, + "filename": "positive1.tf" } ] From 9efbcb5d3f37abca40bfe3ca1d1cc9823e94211e Mon Sep 17 00:00:00 2001 From: Andre Pereira <219305055+cx-andre-pereira@users.noreply.github.com> Date: Tue, 19 Aug 2025 15:50:53 +0100 Subject: [PATCH 2/2] fix --- .../test/negative1.tf | 22 +------------------ 1 file changed, 1 insertion(+), 21 deletions(-) diff --git a/assets/queries/terraform/azure/storage_share_allows_all_acl_permissions/test/negative1.tf b/assets/queries/terraform/azure/storage_share_allows_all_acl_permissions/test/negative1.tf index 1fe3e7bae40..209181e6639 100644 --- a/assets/queries/terraform/azure/storage_share_allows_all_acl_permissions/test/negative1.tf +++ b/assets/queries/terraform/azure/storage_share_allows_all_acl_permissions/test/negative1.tf @@ -18,24 +18,4 @@ resource "azurerm_storage_share" "negative1" { expiry = "2021-07-02T10:38:21.0000000Z" } } -} - -resource "azurerm_storage_share" "negative2" { - name = "neg2" - storage_account_name = azurerm_storage_account.invalid_resource.name - quota = 50 - - acl { - id = "MTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTI" - - access_policy { - permissions = "rwdl" - start = "2022-07-02T09:38:21.0000000Z" - expiry = "2021-07-02T10:38:21.0000000Z" - } - } -} - - - - +} \ No newline at end of file