diff --git a/bundle/regal/rules/imports/unresolved_import.rego b/bundle/regal/rules/imports/unresolved_import.rego index 297af966..972978bc 100644 --- a/bundle/regal/rules/imports/unresolved_import.rego +++ b/bundle/regal/rules/imports/unresolved_import.rego @@ -74,7 +74,7 @@ custom_regal_package_and_import(pkg_path, path) if { # the package part will always be included exported refs # but if we have a rule like foo.bar.baz # we'll want to include both foo.bar and foo.bar.baz -to_paths(pkg_path, ref) := [to_path(pkg_path, ref)] if count(ref) < 3 +to_paths(pkg_path, ref) := util.all_paths(to_path(pkg_path, ref)) if count(ref) < 3 to_paths(pkg_path, ref) := paths if { count(ref) > 2 diff --git a/bundle/regal/rules/imports/unresolved_import_test.rego b/bundle/regal/rules/imports/unresolved_import_test.rego index d41b3503..eda9fcf1 100644 --- a/bundle/regal/rules/imports/unresolved_import_test.rego +++ b/bundle/regal/rules/imports/unresolved_import_test.rego @@ -75,6 +75,24 @@ test_success_resolved_import_in_middle_of_explicit_paths if { r == set() } +test_success_map_rule_resolves if { + agg1 := rule.aggregate with input as regal.parse_module("p1.rego", `package foo + import data.bar.x + `) + + agg2 := rule.aggregate with input as regal.parse_module("p2.rego", `package bar + import rego.v1 + + x[y] := z if { + some y in input.ys + z := {"foo": y + 1} + } + `) + + r := rule.aggregate_report with input as {"aggregate": (agg1 | agg2)} + r == set() +} + test_success_map_rule_may_resolve_so_allow if { agg1 := rule.aggregate with input as regal.parse_module("p1.rego", `package foo import data.bar.x.y