Skip to content

feat(query): implements "Beta - VM Without Managed Disk"#7856

Merged
cx-artur-ribeiro merged 15 commits into
masterfrom
AST-120685_61_ensure_virtua_machines_are_utilizing_managed_disks
Dec 15, 2025
Merged

feat(query): implements "Beta - VM Without Managed Disk"#7856
cx-artur-ribeiro merged 15 commits into
masterfrom
AST-120685_61_ensure_virtua_machines_are_utilizing_managed_disks

Conversation

@cx-andre-pereira

@cx-andre-pereira cx-andre-pereira commented Nov 17, 2025

Copy link
Copy Markdown
Contributor

Reason for Proposed Changes

  • Currently there is no query to ensure that resources of type "azurerm_virtual_machine", "azurerm_linux_virtual_machine", "azurerm_windows_virtual_machine" and "azurerm_virtual_machine_scale_set" are utilizing Managed Disks.

  • Quoting CIS_Microsoft_Azure_Compute_Services_Benchmark_v2.0.0 page 307: "Managed disks are by default encrypted on the underlying hardware, so no additional encryption is required for basic protection. It is available if additional encryption is required. Managed disks are by design more resilient that storage accounts. For ARM-deployed Virtual Machines, Azure Adviser will at some point recommend moving VHDs to managed disks both from a security and cost management perspective.".

Proposed Changes

  • Implemented the missing query.

  • The query will flag legacy "azurerm_virtual_machine" resources if :

  • For "azurerm_linux_virtual_machine" and "azurerm_windows_virtual_machine" resources it is simply checked that "os_managed_disk_id" field is undefined.

  • Finally for the "azurerm_virtual_machine_scale_set" resource type, it is checked that the storage_profile_os_disk.managed_disk_type field is set. The existence of this field should imply that "vhd_containers" and/or "image" are not set.

  • Note - The query "VM Not Attached To Network" only checks for "azurerm_virtual_machine" resources when it should likely check for all 3 VM resources.

I submit this contribution under the Apache-2.0 license.

@github-actions github-actions Bot added feature New feature query New query feature labels Nov 17, 2025
@github-actions

github-actions Bot commented Nov 17, 2025

Copy link
Copy Markdown
Contributor

kics-logo

KICS version: v2.1.17

Category Results
CRITICAL CRITICAL 0
HIGH HIGH 0
MEDIUM MEDIUM 0
LOW LOW 0
INFO INFO 0
TRACE TRACE 0
TOTAL TOTAL 0
Metric Values
Files scanned placeholder 1
Files parsed placeholder 1
Files failed to scan placeholder 0
Total executed queries placeholder 47
Queries failed to execute placeholder 0
Execution time placeholder 0

@cx-andre-pereira cx-andre-pereira marked this pull request as ready for review November 17, 2025 13:50
@cx-andre-pereira cx-andre-pereira requested a review from a team as a code owner November 17, 2025 13:50
@cx-andre-pereira cx-andre-pereira changed the title feat(query): implements "Beta - Virtual Machine Without Managed Disk" feat(query): implements "Beta - VM Without Managed Disk" Nov 17, 2025
@github-actions github-actions Bot added arm Azure Resource Manager query terraform Terraform query azure PR related with Azure Cloud labels Nov 17, 2025

@cx-eduardo-semanas cx-eduardo-semanas left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@cx-eduardo-semanas cx-eduardo-semanas left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@cx-bruno-silva cx-bruno-silva left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@cx-artur-ribeiro cx-artur-ribeiro merged commit 11964e1 into master Dec 15, 2025
29 checks passed
@cx-artur-ribeiro cx-artur-ribeiro deleted the AST-120685_61_ensure_virtua_machines_are_utilizing_managed_disks branch December 15, 2025 10:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

arm Azure Resource Manager query azure PR related with Azure Cloud feature New feature query New query feature terraform Terraform query

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants