File tree 2 files changed +17
-2
lines changed
2 files changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -197,13 +197,13 @@ func (s *Scanner) findMatchedEmbeddedCheck(badPolicy *ast.Module) *ast.Module {
197
197
}
198
198
199
199
badPolicyMeta , err := MetadataFromAnnotations (badPolicy )
200
- if err != nil {
200
+ if err != nil || badPolicyMeta == nil {
201
201
return nil
202
202
}
203
203
204
204
for _ , embeddedCheck := range s .embeddedChecks {
205
205
meta , err := MetadataFromAnnotations (embeddedCheck )
206
- if err != nil {
206
+ if err != nil || meta == nil {
207
207
continue
208
208
}
209
209
if badPolicyMeta .AVDID != "" && badPolicyMeta .AVDID == meta .AVDID {
Original file line number Diff line number Diff line change @@ -253,3 +253,18 @@ deny {
253
253
err := scanner .LoadPolicies (fsys )
254
254
require .Error (t , err )
255
255
}
256
+
257
+ func TestFallback_CheckWithoutAnnotation (t * testing.T ) {
258
+ fsys := fstest.MapFS {
259
+ "check.rego" : & fstest.MapFile {Data : []byte (`package builtin.test
260
+ import data.func
261
+ deny := func(input)
262
+ ` )},
263
+ }
264
+ scanner := rego .NewScanner (
265
+ rego .WithPolicyDirs ("." ),
266
+ rego .WithEmbeddedLibraries (false ),
267
+ )
268
+ err := scanner .LoadPolicies (fsys )
269
+ require .NoError (t , err )
270
+ }
You can’t perform that action at this time.
0 commit comments