Skip to content

fix(terraform): guard against unhashable dict in CKV_AZURE_80#7553

Open
AlexanderSanin wants to merge 1 commit into
bridgecrewio:mainfrom
AlexanderSanin:fix/ckv-azure-80-unhashable-dict
Open

fix(terraform): guard against unhashable dict in CKV_AZURE_80#7553
AlexanderSanin wants to merge 1 commit into
bridgecrewio:mainfrom
AlexanderSanin:fix/ckv-azure-80-unhashable-dict

Conversation

@AlexanderSanin
Copy link
Copy Markdown

Summary

  • CKV_AZURE_80 (AppServiceDotnetFrameworkVersion) crashes with TypeError: unhashable type: 'dict' when the HCL parser produces a list containing a dict (e.g. [{}]) for dotnet_version or dotnet_framework_version — triggered by configurations like dotnet_version = {}.
  • The bug was introduced when the equality check (== "v8.0") was refactored to a set membership test (version in supported_versions): sets require hashable keys, but dicts are not hashable.
  • Added if not isinstance(version, str): return CheckResult.UNKNOWN guards in both the dotnet_framework_version and application_stack.dotnet_version branches, consistent with the check's existing convention for indeterminate configurations.

Test plan

  • Added azurerm_windows_web_app.unknown fixture with dotnet_version = {} to reproduce the crash scenario
  • Existing test suite (test_AppServiceDotnetFrameworkVersion.py) passes without modification — the new fixture resource produces UNKNOWN and does not affect the pass/fail counts
  • Manually verified: scan_resource_conf with dotnet_version = [{}] now returns CheckResult.UNKNOWN instead of raising TypeError
  • Valid versions (v8.0, v9.0, v10.0) still return PASSED; unsupported versions still return FAILED

Closes #7523

When the HCL parser receives a non-string value for dotnet_version or
dotnet_framework_version (e.g. an empty object `{}`), the refactored set
membership test `version in supported_versions` throws
`TypeError: unhashable type: 'dict'`.

Add an explicit isinstance(version, str) guard before each membership
check and return CheckResult.UNKNOWN when the version value is not a
string, matching the check's existing convention for indeterminate
configurations.

Closes bridgecrewio#7523

Signed-off-by: Oleksandr Sanin <alexaaander.sanin@gmail.com>
@AlexanderSanin
Copy link
Copy Markdown
Author

Hey @schosterbarak @nimrodkor @tronxd. Could you, please, have a look at this?

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.

[MainThread ] [ERROR] Failed to run check CKV_AZURE_80 on /webapp.tf:azurerm_windows_web_app.windows_webapp

1 participant