cloudformation-guard icon indicating copy to clipboard operation
cloudformation-guard copied to clipboard

[BUG] Unknown parse error

Open Yawnek opened this issue 4 years ago • 4 comments

Hi, We have a problem with AWS Guard. There are two main commands to run, one is validate and the other one is test. The validate one works with both JSON and YAML files as you can see :

Capture

But for the test option it doesnt seeem to work. I try different files even empty one, and I still get this error :

“Error processing Parser Error when parsing rules file Unable to process data in file deploy.cf.json, Error invalid type: map, expected a sequence at line 1 column 0,“

I can get different number lines but the message stay the same

The sample code works perfectly, with the yaml format ( only for the sample ), but not our own yaml format code ( even if we believe its correct ).

I'll provide sample code in comments.

Capture

Yawnek avatar Nov 09 '21 03:11 Yawnek

Thanks for reporting. I will check and get back to you.

shreyasdamle avatar Nov 10 '21 02:11 shreyasdamle

@Yawnek I wasn't able to reproduce this issue in cfn-guard v2.0.3. Can you please share the sample rule and test file?

shreyasdamle avatar Nov 10 '21 23:11 shreyasdamle

I used this two files :

example.zip

When I used this command : cfn-guard test -r api_gateway_private_access.guard -t cfn-guard-example.yaml

I got : Error processing Parser Error when parsing rules file Unable to process data in file cfn-guard-example.yaml, Error invalid number at line 1 column 2,

As you can the error is clearly not at line 1, column 2 but rather in line 20, cause its missing a space

check_rest_api_is_private:FAIL

( Sorry for the late answer )

Yawnek avatar Nov 22 '21 15:11 Yawnek

@Yawnek I was able to recreate on v2.0.4

image On Line 19, expect a space before FAIL image

Adding the correct space and then runs as expected.

image image

Will bring this back to the team to discuss.

razcloud avatar May 17 '22 00:05 razcloud

HI @Yawnek,

After looking into this the team has decided that this actually isn't a bug. The issue has to do with incorrect formatting of yaml. Guard will only be able to parse valid yaml/json. As @razcloud posted in his screenshot there is incorrect spacing between the key and value on line 19. I am going to go ahead and close this issue.

Feel free to reopen if you feel necessary

Thanks

joshfried-aws avatar Jun 09 '23 16:06 joshfried-aws