From 473b5d094faf5d840ca07eea43f9405b28ee4784 Mon Sep 17 00:00:00 2001 From: John Kastner <130772734+john-h-kastner-aws@users.noreply.github.com> Date: Fri, 22 Nov 2024 13:58:42 -0500 Subject: [PATCH] Fix constructor call for patttern (#484) Signed-off-by: John Kastner --- cedar-drt/fuzz/fuzz_targets/wildcard-matching.rs | 2 +- cedar-policy-generators/src/abac.rs | 7 ++----- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/cedar-drt/fuzz/fuzz_targets/wildcard-matching.rs b/cedar-drt/fuzz/fuzz_targets/wildcard-matching.rs index c86228272..b2504b494 100644 --- a/cedar-drt/fuzz/fuzz_targets/wildcard-matching.rs +++ b/cedar-drt/fuzz/fuzz_targets/wildcard-matching.rs @@ -148,7 +148,7 @@ fn wildcard_match_regex<'a>( fuzz_target!(|input: FuzzTargetInput| { // Ensure wildcard matching is equivalent to the regex version let regex_result = wildcard_match_regex(&input.string, &input.pattern); - let rust_result = Pattern::new(input.pattern).wildcard_match(&input.string); + let rust_result = Pattern::from(input.pattern).wildcard_match(&input.string); assert_eq!( regex_result, rust_result, "\nregex result: {};rust result:{}.\n", diff --git a/cedar-policy-generators/src/abac.rs b/cedar-policy-generators/src/abac.rs index 183816b5e..7bf791daa 100644 --- a/cedar-policy-generators/src/abac.rs +++ b/cedar-policy-generators/src/abac.rs @@ -214,10 +214,7 @@ impl ConstantPool { /// Produce a RHS of a like operation /// It's derived from a random string constant in the pool: We perform transformations over it such as adding a char, deleting a char and adding a wildcard star. - pub fn arbitrary_pattern_literal( - &self, - u: &mut Unstructured<'_>, - ) -> Result> { + pub fn arbitrary_pattern_literal(&self, u: &mut Unstructured<'_>) -> Result { let matched_string = self.arbitrary_string_constant_bounded(u, MAX_PATTERN_LEN)?; let mut pattern = Vec::new(); @@ -246,7 +243,7 @@ impl ConstantPool { {} ) } - Ok(pattern) + Ok(ast::Pattern::from(pattern)) } // Generate a valid IPv4 net representation