Skip to content

feat(engine): fixed parsing for tfplan files and update for "Encryption On Managed Disk Disabled" query#7866

Merged
cx-artur-ribeiro merged 9 commits into
masterfrom
AST-121572_FN_encryption_on_managed_disk_disabled
Dec 31, 2025
Merged

feat(engine): fixed parsing for tfplan files and update for "Encryption On Managed Disk Disabled" query#7866
cx-artur-ribeiro merged 9 commits into
masterfrom
AST-121572_FN_encryption_on_managed_disk_disabled

Conversation

@cx-andre-pereira

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

Copy link
Copy Markdown
Contributor

Closes #7516, closes #7307, closes #7265

Reason for Proposed Changes

  • Currently support for terraform "tfplan" files has some issues. The main problem was that, during parsing, resources of the same "type" and same "name" would overlap during the assignment process making it so only the last instance of any given type/name pair would be included in the resulting payload.

  • This can and did lead to many false negatives as a large part of the tfplan's "planned values" (the block that is supported by KICS), could go missing. In the sample used to raise this issue for example the payload ended up being 1/4 the expected size since all resources for each specific type had the same generic name associated with them.

  • As for the "Encryption On Managed Disk Disabled" query, it was very outdated since it was based on a deprecated field from the target encryption_settings block on the azurerm_managed_disk resource. The legacy encryption_settings block had a required "enabled" field which the current query's logic is based off of.

  • Since the enabled field no longer exists it is possible to have empty encryption_settings blocks declared and, in that instance, the query will not flag because it assumes the "enabled" field must be explicitly set to false for encryption to be disabled.

Proposed Changes

  • To solve the issue on the "tfplan" parsing logic of the "readModule" function was altered to use the "address" field when creating the objects for each resource instance. The "address" field is the key field used to index each individual resource instances as per the documentation. It should always have been the key for the resulting payload's resources as well.

  • Fixed the target query's logic to handle not only the case of the encryption_settings block being undefined or enabled set to false, but also the case of encryption_settings being an empty block.

I submit this contribution under the Apache-2.0 license.

@cx-andre-pereira cx-andre-pereira changed the title feat(engine/query): fixed parsing for tfplan files and updated "Encryption On Managed Disk Disabled" query feat(engine/query): fixed parsing for tfplan files and update for "Encryption On Managed Disk Disabled" query Nov 19, 2025
@github-actions github-actions Bot added feature New feature query New query feature labels Nov 19, 2025
@github-actions

github-actions Bot commented Nov 19, 2025

Copy link
Copy Markdown
Contributor

kics-logo

KICS version: v2.1.18

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 changed the title feat(engine/query): fixed parsing for tfplan files and update for "Encryption On Managed Disk Disabled" query feat(engine): fixed parsing for tfplan files and update for "Encryption On Managed Disk Disabled" query Nov 19, 2025
@github-actions github-actions Bot added the terraform Terraform query label Nov 19, 2025
@github-actions github-actions Bot added the azure PR related with Azure Cloud label Nov 19, 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

@github-actions github-actions Bot added community Community contribution feature request Community: new feature request labels Dec 31, 2025
@cx-artur-ribeiro cx-artur-ribeiro merged commit dcf7740 into master Dec 31, 2025
29 checks passed
@cx-artur-ribeiro cx-artur-ribeiro deleted the AST-121572_FN_encryption_on_managed_disk_disabled branch December 31, 2025 16:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

azure PR related with Azure Cloud community Community contribution feature request Community: new feature request feature New feature query New query feature terraform Terraform query

Projects

None yet

3 participants