From a0c5dea1fc44f55307b6623ee1d0bda0c88af829 Mon Sep 17 00:00:00 2001 From: Liudmila Molkova Date: Mon, 19 Aug 2024 14:12:58 -0700 Subject: [PATCH] fix namespaces --- policies/attribute_name_collisions.rego | 2 +- policies/attribute_name_collisions_test.rego | 8 +++----- policies/yaml_schema.rego | 2 +- policies/yaml_schema_test.rego | 17 ++++++++--------- 4 files changed, 13 insertions(+), 16 deletions(-) diff --git a/policies/attribute_name_collisions.rego b/policies/attribute_name_collisions.rego index b600fee665..69d8300b68 100644 --- a/policies/attribute_name_collisions.rego +++ b/policies/attribute_name_collisions.rego @@ -1,4 +1,4 @@ -package attribute_name_collisions +package after_resolution # check that attribute constant names do not collide deny[attr_registry_collision(description, name)] { diff --git a/policies/attribute_name_collisions_test.rego b/policies/attribute_name_collisions_test.rego index 970c2b4749..b86e79fece 100644 --- a/policies/attribute_name_collisions_test.rego +++ b/policies/attribute_name_collisions_test.rego @@ -1,6 +1,4 @@ -package attribute_name_collisions_test - -import data.attribute_name_collisions +package after_resolution import future.keywords test_fails_on_const_name_collision if { @@ -9,7 +7,7 @@ test_fails_on_const_name_collision if { {"id": "test2", "attributes": [{"name": "foo.bar_baz"}]} ]} # each attribute counts as a collision, so there are 2 collisions - count(attribute_name_collisions.deny) == 2 with input as collision + count(deny) == 2 with input as collision } test_fails_on_namespace_collision if { @@ -17,5 +15,5 @@ test_fails_on_namespace_collision if { {"id": "test1", "attributes": [{"name": "foo.bar.baz"}]}, {"id": "test2", "attributes": [{"name": "foo.bar"}]} ]} - count(attribute_name_collisions.deny) == 1 with input as collision + count(deny) == 1 with input as collision } diff --git a/policies/yaml_schema.rego b/policies/yaml_schema.rego index 3d3e8e98f3..2dfe53d593 100644 --- a/policies/yaml_schema.rego +++ b/policies/yaml_schema.rego @@ -1,4 +1,4 @@ -package yaml_schema +package before_resolution # checks attribute name format deny[yaml_schema_violation(description, group.id, name)] { diff --git a/policies/yaml_schema_test.rego b/policies/yaml_schema_test.rego index 23a9dacc6d..ebcd86f036 100644 --- a/policies/yaml_schema_test.rego +++ b/policies/yaml_schema_test.rego @@ -1,36 +1,35 @@ -package yaml_schema_test +package before_resolution -import data.yaml_schema import future.keywords test_fails_on_invalid_attribute_name if { every name in invalid_names { - count(yaml_schema.deny) == 1 with input as {"groups": create_attribute_group(name)} + count(deny) == 1 with input as {"groups": create_attribute_group(name)} } } test_fails_on_invalid_metric_name if { every name in invalid_names { - count(yaml_schema.deny) == 1 with input as {"groups": create_metric(name)} + count(deny) == 1 with input as {"groups": create_metric(name)} } } test_fails_on_invalid_event_name if { every name in invalid_names { - count(yaml_schema.deny) == 1 with input as {"groups": create_event(name)} + count(deny) == 1 with input as {"groups": create_event(name)} } } test_passes_on_valid_names if { every name in valid_names { - count(yaml_schema.deny) == 0 with input as {"groups": create_attribute_group(name)} - count(yaml_schema.deny) == 0 with input as {"groups": create_metric(name)} - count(yaml_schema.deny) == 0 with input as {"groups": create_event(name)} + count(deny) == 0 with input as {"groups": create_attribute_group(name)} + count(deny) == 0 with input as {"groups": create_metric(name)} + count(deny) == 0 with input as {"groups": create_event(name)} } } test_fails_if_prefix_is_present if { - count(yaml_schema.deny) == 1 with input as {"groups": [{"id": "test", "prefix": "foo"}]} + count(deny) == 1 with input as {"groups": [{"id": "test", "prefix": "foo"}]} } create_attribute_group(attr) = json {