Skip to content

[BugFix]: cfn-guard no longer errors out when rule files are empty, or contain only comments - #402

Merged
joshfried-aws merged 2 commits into
aws-cloudformation:mainfrom
joshfried-aws:main
Aug 29, 2023
Merged

joshfried-aws merged 2 commits into
aws-cloudformation:mainfrom
joshfried-aws:main

Conversation

@joshfried-aws

Copy link
Copy Markdown
Contributor

Issue #, if available:
#376

Description of changes:
Added a check before parsing for the grammar, that discards all leading comments, or empty space, and made the crate::rules::parser::rules_file function now return Result<Option<RulesFile>, Error> instead of Result<RulesFile, Error> calling functions of this now also return the same Result<Option<RulesFile>, E> struct, and functions such as evaluate_rule now return 0 if it receives Ok(None) functions such as the evaluator in our structured_reporter now just skip the step of appending to the list of rules.

Also updated expected results of some test cases, and added a new test case for when using the validate command with a file that contains only comments


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

Comment thread guard/resources/validate/comments.guard Resolved
@akshayrane
akshayrane self-requested a review August 28, 2023 20:36
@joshfried-aws joshfried-aws changed the title [BugFix}: cfn-guard no longer errors out when rule files are empty, or contain only comments [BugFix]: cfn-guard no longer errors out when rule files are empty, or contain only comments Aug 29, 2023
@joshfried-aws
joshfried-aws merged commit aa3dbdf into aws-cloudformation:main Aug 29, 2023
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.

4 participants