Skip to content

Conversation

@unitmatrix
Copy link

This pull request introduces a new feature that filters sensitive manifests based on their group_kind. The changes include:

  • Creating a local map sensitive_manifests by iterating over the data source manifests and including only those whose group_kind is in the sensitive_group_kinds list.
  • Updating the kustomization_resource resources to use the sensitive_manifests map, falling back to the original manifests if not found in the sensitive map.

Additionally, this change ensures compatibility with Terraform version 1.10.0 and above, where all marks are passed through conditional expressions as per the HCL commit.

This enhancement improves the security and management of manifests by appropriately marking and handling sensitive manifests.

@unitmatrix unitmatrix force-pushed the feature/refactor-sensitive-manifests branch from 5bc949c to aaf54bc Compare December 9, 2024 08:08
fix manifest reference in the loop

fix typo
@unitmatrix unitmatrix force-pushed the feature/refactor-sensitive-manifests branch from aaf54bc to 199da7d Compare December 9, 2024 08:09
Copy link
Member

@pst pst left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution. I am not quite sure though what the benefit is. You "fix" having the conditional 3 times, but as a result loop over all manifests one more time. What am I missing?

@unitmatrix
Copy link
Author

Thank you for your feedback. The main reason behind this pull request is to address a compatibility issue introduced in Terraform version 1.10.0 and above concerning how marks are handled in conditional expressions. Specifically, in the current implementation, an expression like false ? sensitive(var.example) : var.example ends up marking var.example as sensitive regardless of the condition's outcome. This is because Terraform evaluates both the true and false branches under the hood, causing unintended sensitive marking.

The proposed change mitigates this by preemptively filtering and appropriately marking the sensitive manifests. This ensures that only the relevant manifests are marked as sensitive, avoiding the overhead of Terraform's conditional handling of marks in later versions. Although this approach introduces an additional iteration over all manifests, it is necessary to ensure correct behavior with newer versions of Terraform and maintain the security posture by handling sensitive data appropriately.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants