@@ -175,10 +175,12 @@ func (s Scanner) scanCloudFormation(files []types.Config) ([]types.Misconfigurat
175
175
},
176
176
}
177
177
178
- filename := flattened .Location .Filename
179
- filePath , err := filepath .Rel (rootDir , filename )
180
- if err != nil {
181
- return nil , xerrors .Errorf ("filepath rel, root: [%s], result: [%s] %w" , rootDir , filename , err )
178
+ var filePath = "unknown"
179
+ if flattened .Location .Filename == "" {
180
+ filePath , err = filepath .Rel (rootDir , flattened .Location .Filename )
181
+ if err != nil {
182
+ return nil , xerrors .Errorf ("filepath rel, root: [%s], result: [%s] %w" , rootDir , flattened .Location .Filename , err )
183
+ }
182
184
}
183
185
184
186
misconf , ok := misConfs [filePath ]
@@ -244,9 +246,13 @@ func (s Scanner) scanTerraform(files []types.Config) ([]types.Misconfiguration,
244
246
EndLine : flattened .Location .EndLine ,
245
247
},
246
248
}
247
- filePath , err := filepath .Rel (rootDir , flattened .Location .Filename )
248
- if err != nil {
249
- return nil , xerrors .Errorf ("filepath rel: %w" , err )
249
+
250
+ var filePath = "unknown"
251
+ if flattened .Location .Filename != "" {
252
+ filePath , err = filepath .Rel (rootDir , flattened .Location .Filename )
253
+ if err != nil {
254
+ return nil , xerrors .Errorf ("filepath rel, root: [%s], result: [%s] %w" , rootDir , flattened .Location .Filename , err )
255
+ }
250
256
}
251
257
252
258
misconf , ok := misconfs [filePath ]
0 commit comments