mirror of
https://github.com/aquasecurity/trivy.git
synced 2025-12-22 07:10:41 -08:00
feat(misconf): log causes of HCL file parsing errors (#7634)
Signed-off-by: nikpivkin <nikita.pivkin@smartforce.io> Co-authored-by: Simar <simar@linux.com> Co-authored-by: simar7 <1254783+simar7@users.noreply.github.com>
This commit is contained in:
@@ -2010,6 +2010,27 @@ variable "baz" {}
|
||||
assert.Contains(t, buf.String(), "variables=\"foo\"")
|
||||
}
|
||||
|
||||
func TestLogParseErrors(t *testing.T) {
|
||||
var buf bytes.Buffer
|
||||
slog.SetDefault(slog.New(log.NewHandler(&buf, nil)))
|
||||
|
||||
src := `resource "aws-s3-bucket" "name" {
|
||||
bucket = <
|
||||
}`
|
||||
|
||||
fsys := fstest.MapFS{
|
||||
"main.tf": &fstest.MapFile{
|
||||
Data: []byte(src),
|
||||
},
|
||||
}
|
||||
|
||||
parser := New(fsys, "")
|
||||
err := parser.ParseFS(context.TODO(), ".")
|
||||
require.NoError(t, err)
|
||||
|
||||
assert.Contains(t, buf.String(), `cause=" bucket = <"`)
|
||||
}
|
||||
|
||||
func Test_PassingNullToChildModule_DoesNotEraseType(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
|
||||
Reference in New Issue
Block a user