Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hcl2: fix crash on malformed overrides #11881

Merged
merged 1 commit into from
Jul 20, 2022
Merged

hcl2: fix crash on malformed overrides #11881

merged 1 commit into from
Jul 20, 2022

Conversation

lbajolet-hashicorp
Copy link
Contributor

When an override block is either not an object, or if one of its
contents are not an object, Packer would crash trying to forcefully
cast the cty.Value to a cty.Collection.

To avoid this behaviour, we add extra checks that return hcl.Diagnostics
when they fail.

Closes #11876

@lbajolet-hashicorp lbajolet-hashicorp requested a review from a team as a code owner July 15, 2022 20:02
Copy link
Contributor

@JenGoldstrich JenGoldstrich left a comment

Choose a reason for hiding this comment

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

Made a suggested test change but otherwise this LGTM

hcl2template/types.build.provisioners_test.go Outdated Show resolved Hide resolved
When an override block is either not an object, or if one of its
contents are not an object, Packer would crash trying to forcefully
cast the cty.Value to a cty.Collection.

To avoid this behaviour, we add extra checks that return hcl.Diagnostics
when they fail.
Copy link
Contributor

@nywilken nywilken left a comment

Choose a reason for hiding this comment

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

Nice catch. This looks good to me.

@nywilken nywilken merged commit 6ab1656 into main Jul 20, 2022
@nywilken nywilken deleted the fix_override_crashes branch July 20, 2022 18:30
@github-actions
Copy link

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 20, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Packer crash
3 participants