Skip to content

Commit

Permalink
fallback to embedded in case of any error
Browse files Browse the repository at this point in the history
  • Loading branch information
nikpivkin committed Apr 18, 2024
1 parent e247ad2 commit 3d700fe
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
4 changes: 0 additions & 4 deletions pkg/iac/rego/load.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,6 @@ func (s *Scanner) fallbackChecks(compiler *ast.Compiler) {
var excludedFiles []string

for _, e := range compiler.Errors {
if _, ok := e.Details.(*ast.RefErrInvalidDetail); !ok {
continue
}

loc := e.Location.File

if lo.Contains(excludedFiles, loc) {
Expand Down
16 changes: 16 additions & 0 deletions pkg/iac/rego/load_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,22 @@ deny {
},
expectedErr: "testdata/embedded/bad-check.rego:8: rego_type_error: undefined ref",
},
{
name: "with non existent function",
files: map[string]*fstest.MapFile{
"policies/my-check2.rego": {
Data: []byte(`# METADATA
# schemas:
# - input: schema["fooschema"]
package builtin.test
deny {
input.foo == fn.is_foo("foo")
}`,
),
},
},
},
}

for _, tt := range tests {
Expand Down

0 comments on commit 3d700fe

Please sign in to comment.