Skip to content

Conversation

@cx-andre-pereira
Copy link
Contributor

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

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
Copy link
Contributor

kics-logo

KICS version: v2.1.13

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
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 feature New feature query New query feature terraform Terraform query

Projects

None yet

1 participant