-
Notifications
You must be signed in to change notification settings - Fork 1.2k
fix(serverless): Enhance yaml parsing, better support for file expansion #7115
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
Open
thentenaar
wants to merge
1
commit into
bridgecrewio:main
Choose a base branch
from
thentenaar:yaml-fix
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
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
…ions - Improve yaml parsing wrt file() expansion - Add tests for file() expansion - Add a '__file__' marker attribute to yaml nodes - Utilize the '__file__' marker when generating reports for serverless - Raise CfnParseError on circular inclusions - Added a ``logger.error`` that logs specifics on pyyaml parse errors - Updated the serverless graph builder to cope with file() expansion Fixes bridgecrewio#7006
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.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
Description
Fixes #7006
Although the issue reported in #7006 doesn't cause a /crash/ per se, checkov was failing to process the file() expansion on the
resources
SequenceNode; thus not scanning the file at all.The serverless parser expands file() expansions by way of
yaml.safe_load
which is fine for scalar values, but for SequenceNodes of resources, this needs to be handled in cfn_yaml otherwise the resources don't get added tothe graph (they lack the marking attributes, and so the graph creation fails.)
This PR also adds a 'file' attribute to the yaml nodes for use in diagnostics, extends the serverless runner to use it, and enriches yaml parse error handling, adding a
logging.error()
tell with specifics. I've also replaced theIOError
exceptions groked byerrno
with thier more descriptive equivalents in the serverless and cfn parsers.Additional tests have been added to test that the
file()
expansion handling works as it should, and that a check passes when run on yaml containing an expansion; and that an CfnParseError gets raised on attempts at circular inclusions.For the yaml provided in #7006, after correcting a syntax error in the yaml itself, I get the following results with these changes applied:
Checklist: