diff --git a/bundle/regal/rules/idiomatic/non_raw_regex_pattern.rego b/bundle/regal/rules/idiomatic/non_raw_regex_pattern.rego index 15f5a33e..2378b2c2 100644 --- a/bundle/regal/rules/idiomatic/non_raw_regex_pattern.rego +++ b/bundle/regal/rules/idiomatic/non_raw_regex_pattern.rego @@ -58,5 +58,5 @@ report contains violation if { chr == `"` - violation := result.fail(rego.metadata.chain(), result.location(value[pos])) + violation := result.fail(rego.metadata.chain(), result.ranged_location_from_text(value[pos])) } diff --git a/bundle/regal/rules/idiomatic/non_raw_regex_pattern_test.rego b/bundle/regal/rules/idiomatic/non_raw_regex_pattern_test.rego index 5b5d949c..bd076d52 100644 --- a/bundle/regal/rules/idiomatic/non_raw_regex_pattern_test.rego +++ b/bundle/regal/rules/idiomatic/non_raw_regex_pattern_test.rego @@ -15,7 +15,13 @@ test_fail_non_raw_rule_head if { "category": "idiomatic", "description": "Use raw strings for regex patterns", "level": "error", - "location": {"col": 18, "file": "policy.rego", "row": 3, "text": "x := regex.match(\"[0-9]+\", \"1\")"}, + "location": { + "col": 18, + "file": "policy.rego", + "row": 3, + "text": "x := regex.match(\"[0-9]+\", \"1\")", + "end": {"col": 26, "row": 3}, + }, "related_resources": [{ "description": "documentation", "ref": config.docs.resolve_url("$baseUrl/$category/non-raw-regex-pattern", "idiomatic"), @@ -33,7 +39,13 @@ test_fail_non_raw_rule_body if { "category": "idiomatic", "description": "Use raw strings for regex patterns", "level": "error", - "location": {"col": 18, "file": "policy.rego", "row": 4, "text": "\t\tregex.is_valid(\"[0-9]+\")"}, + "location": { + "col": 18, + "file": "policy.rego", + "row": 4, + "text": "\t\tregex.is_valid(\"[0-9]+\")", + "end": {"col": 26, "row": 4}, + }, "related_resources": [{ "description": "documentation", "ref": config.docs.resolve_url("$baseUrl/$category/non-raw-regex-pattern", "idiomatic"), @@ -49,7 +61,13 @@ test_fail_pattern_in_second_arg if { "category": "idiomatic", "description": "Use raw strings for regex patterns", "level": "error", - "location": {"col": 25, "file": "policy.rego", "row": 3, "text": "r := regex.replace(\"a\", \"[a]\", \"b\")"}, + "location": { + "col": 25, + "file": "policy.rego", + "row": 3, + "text": "r := regex.replace(\"a\", \"[a]\", \"b\")", + "end": {"col": 30, "row": 3}, + }, "related_resources": [{ "description": "documentation", "ref": config.docs.resolve_url("$baseUrl/$category/non-raw-regex-pattern", "idiomatic"),