Closed boonew2 closed 2 weeks ago
Hello! Thanks for the report - we're looking into this.
@boonew2 Can you please provide your Invoke-LMFunction
wrapper function? I'd like to reproduce this exactly as you have it and that's one missing piece here.
In your examples:
# this throws the error
Invoke-CfnGuardLambda -TemplatePath C:\temp\template.yml -RulesetPath C:\temp\rules.ruleset
errorType errorMessage
--------- ------------
&alloc::boxed::Box<dyn core::error::Error + core::marker::Send + core::marker::Sync> trailing characters at line 1 column 19
# this returns the verbose response as expected
Invoke-CfnGuardLambda -Verbose | ConvertTo-Json -Compress
{"message":[{"context":"File(rules=1)","container":"@{FileCheck=}","children":""}]}
Regarding this: Invoke-CfnGuardLambda -Verbose | ConvertTo-Json -Compress
How does that work with the missing parameters? Do you have a default set in your lambda invoker function for rules/files? I'm not sure the verbose
flag is having an impact here as the example commands appear to be doing different things entirely.
Additionally, It doesn't look like template files are getting passed in based on the output FileCheck=
and since you mention that you're on Windows, using pwsh, and commenting paths in and out with success I'd wager it's something to do with paths on windows or just illegal characters from windows when reading the files in using Get-Content
and trying to create valid JSON to pass as a payload.
By default Windows paths aren't valid JSON since they use backslash as a separator and most parsers are going to treat that as an escape. If the filenames are at all included in the payload and you are trying to convert back and forth to JSON using powershell, that may actually be the problem but I'd like to narrow down the exact root cause of your pain.
Can you also send over the template as it's getting logged in CloudWatch? I'd be interested to see how the paths are rendered after being sent through to the lambda.
HI @boonew2, checking in here. Please provide my colleague @dannyvassallo with the information he requested when you have a moment.
Hi, I am going to close this issue out. Feel free to reopen if you feel the need.
Thanks
Describe the bug When invoking the cfnGuard lambda with
"verbose": false
in the payload it seems to break parsing of the template in a hard to pin down way.. Error from the lambda is:To Reproduce Please supply:
Sample ruleset
I'm invoking the lambda through a small powershell wrapper while testing, but i'm pretty sure another language would have the same results:
Logs: cloudwatch logs dump the template that i already pasted, the ruleset, and then the error message returned in the response. I don't want to spam this to much so i'll just include the ruleset/error logs:
NOTE: Please be sure that the templates, rules and logs you provide as part of your bug report do not contain any sensitive information.
Expected behavior Specifying
verbose: false
in the payload doesn't break the lambdaOperating System: Windows
OS Version 11
Additional context The exact thing in the provided template that causes the error is really weird to pin down. If i comment out some of the paths in the api resource it will stop failing with
verbose: false
. If i comment out specific lines it will also start to work as expected, but i can't see anything in those lines that would be remotely problematic. The template is very trimmed down so it has someRef
s to things that aren't provided in it, but i don't think that should matter to Guard (and the full template has the same behavior)