fix(terraform): guard against unhashable dict in CKV_AZURE_80#7553
Open
AlexanderSanin wants to merge 1 commit into
Open
fix(terraform): guard against unhashable dict in CKV_AZURE_80#7553AlexanderSanin wants to merge 1 commit into
AlexanderSanin wants to merge 1 commit into
Conversation
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>
Author
|
Hey @schosterbarak @nimrodkor @tronxd. Could you, please, have a look at this? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
CKV_AZURE_80(AppServiceDotnetFrameworkVersion) crashes withTypeError: unhashable type: 'dict'when the HCL parser produces a list containing a dict (e.g.[{}]) fordotnet_versionordotnet_framework_version— triggered by configurations likedotnet_version = {}.== "v8.0") was refactored to a set membership test (version in supported_versions): sets require hashable keys, but dicts are not hashable.if not isinstance(version, str): return CheckResult.UNKNOWNguards in both thedotnet_framework_versionandapplication_stack.dotnet_versionbranches, consistent with the check's existing convention for indeterminate configurations.Test plan
azurerm_windows_web_app.unknownfixture withdotnet_version = {}to reproduce the crash scenariotest_AppServiceDotnetFrameworkVersion.py) passes without modification — the new fixture resource producesUNKNOWNand does not affect the pass/fail countsscan_resource_confwithdotnet_version = [{}]now returnsCheckResult.UNKNOWNinstead of raisingTypeErrorv8.0,v9.0,v10.0) still returnPASSED; unsupported versions still returnFAILEDCloses #7523