From 6ae7080747bb235b55b07d8315fb810f76d8565a Mon Sep 17 00:00:00 2001 From: John Kastner Date: Tue, 17 Dec 2024 15:54:20 +0000 Subject: [PATCH 1/4] Fix common types target for reserved type names Signed-off-by: John Kastner --- .../fuzz_targets/common-type-resolution.rs | 18 +++++++++++++----- cedar-policy-generators/src/schema.rs | 7 ++++--- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/cedar-drt/fuzz/fuzz_targets/common-type-resolution.rs b/cedar-drt/fuzz/fuzz_targets/common-type-resolution.rs index 7a2b89157..10419b866 100644 --- a/cedar-drt/fuzz/fuzz_targets/common-type-resolution.rs +++ b/cedar-drt/fuzz/fuzz_targets/common-type-resolution.rs @@ -21,6 +21,7 @@ use cedar_policy_validator::SchemaFragment; use libfuzzer_sys::arbitrary::{self, Arbitrary, Unstructured}; use log::info; use serde::Serialize; +use similar_asserts::SimpleDiff; use std::collections::HashMap; #[derive(Debug, Clone, Serialize)] @@ -81,14 +82,21 @@ fuzz_target!(|i: Input| { (Ok(s1), Ok(s2)) => { assert!( validator_schema_attr_types_equivalent(&s1, &s2), - "reduced to different validator schemas: {:?}\n{:?}\n", - s1, - s2 + "{}", + SimpleDiff::from_str( + &format!("{s1:?}"), + &format!("{s2:?}"), + "original", + "with common types" + ) ); } (Err(_), Err(_)) => {} - (Ok(s), Err(_)) | (Err(_), Ok(s)) => { - panic!("reduction results differ, got validator schema: {:?}\n", s); + (Ok(s), Err(e)) => { + panic!("Constructed schema without common types but failed to build schema with common types.\nconstructed schema:\n{s:#?}\nerror: {e:?}") + } + (Err(e), Ok(s)) => { + panic!("Constructed schema with common types but failed to build schema without common types.\nconstructed schema:\n{s:#?}\nerror: {e:?}") } } }); diff --git a/cedar-policy-generators/src/schema.rs b/cedar-policy-generators/src/schema.rs index ae68f5044..7ed9f6a1c 100644 --- a/cedar-policy-generators/src/schema.rs +++ b/cedar-policy-generators/src/schema.rs @@ -32,8 +32,8 @@ use arbitrary::{self, Arbitrary, Unstructured}; use cedar_policy_core::ast::{self, Effect, Id, Name, PolicyID}; use cedar_policy_core::extensions::Extensions; use cedar_policy_validator::{ - ActionType, ApplySpec, AttributesOrContext, EntityType, SchemaError, SchemaFragment, - SchemaType, SchemaTypeVariant, TypeOfAttribute, ValidatorSchema, + is_builtin_type_name, ActionType, ApplySpec, AttributesOrContext, EntityType, SchemaError, + SchemaFragment, SchemaType, SchemaTypeVariant, TypeOfAttribute, ValidatorSchema, }; use smol_str::{SmolStr, ToSmolStr}; use std::collections::BTreeMap; @@ -456,8 +456,9 @@ impl Bindings { fn add_binding(&mut self, binding: (SchemaType, Id)) { let (ty, id) = binding; // create a new id when the provided id has been used - let new_id = if self.ids.contains(id.as_ref()) { + let new_id = if is_builtin_type_name(id.as_ref()) || self.ids.contains(id.as_ref()) { let mut new_id = id.to_string(); + new_id.push('_'); while self.ids.contains(new_id.as_str()) { new_id.push('_'); } From ff51ee0ef827433116d9c6c3860e2927192a854b Mon Sep 17 00:00:00 2001 From: John Kastner Date: Tue, 17 Dec 2024 20:00:13 +0000 Subject: [PATCH 2/4] fix deprecated functions Signed-off-by: John Kastner --- cedar-drt/src/lean_impl.rs | 1 + cedar-policy-generators/src/expr.rs | 28 +++++++++++++++------------ cedar-policy-generators/src/schema.rs | 26 ++++++++++++++----------- 3 files changed, 32 insertions(+), 23 deletions(-) diff --git a/cedar-drt/src/lean_impl.rs b/cedar-drt/src/lean_impl.rs index c7ab4172b..2a101e514 100644 --- a/cedar-drt/src/lean_impl.rs +++ b/cedar-drt/src/lean_impl.rs @@ -183,6 +183,7 @@ impl LeanDefinitionalEngine { }) .collect(); TestResult::Success(TestResponse { + #[allow(deprecated)] response: InterfaceResponse::new(decision, reason, errors), timing_info: HashMap::from([("authorize".into(), Micros(auth_time))]), }) diff --git a/cedar-policy-generators/src/expr.rs b/cedar-policy-generators/src/expr.rs index f359fc7ca..7b4ae93a4 100644 --- a/cedar-policy-generators/src/expr.rs +++ b/cedar-policy-generators/src/expr.rs @@ -10,7 +10,7 @@ use crate::schema::{ use crate::settings::ABACSettings; use crate::size_hint_utils::{size_hint_for_choose, size_hint_for_range, size_hint_for_ratio}; use crate::{accum, gen, gen_inner, uniform}; -use arbitrary::{Arbitrary, Unstructured}; +use arbitrary::{Arbitrary, MaxRecursionReached, Unstructured}; use cedar_policy_core::ast::{self, Id}; use smol_str::SmolStr; use std::collections::BTreeMap; @@ -1663,9 +1663,11 @@ impl<'a> ExprGenerator<'a> { /// size hint for arbitrary_attr_value_for_type() #[allow(dead_code)] - pub fn generate_attr_value_for_type_size_hint(depth: usize) -> (usize, Option) { - arbitrary::size_hint::recursion_guard(depth, |depth| { - arbitrary::size_hint::and( + pub fn generate_attr_value_for_type_size_hint( + depth: usize, + ) -> std::result::Result<(usize, Option), MaxRecursionReached> { + arbitrary::size_hint::try_recursion_guard(depth, |depth| { + Ok(arbitrary::size_hint::and( size_hint_for_range(0, 7), arbitrary::size_hint::or_all(&[ ::size_hint(depth), @@ -1678,13 +1680,13 @@ impl<'a> ExprGenerator<'a> { ), size_hint_for_ratio(9, 10), size_hint_for_range(0, 4), - Self::generate_attr_value_for_type_size_hint(depth), + Self::generate_attr_value_for_type_size_hint(depth)?, ]), (1, None), // not sure how to hint for arbitrary_loop() (1, None), // not sure how to hint for arbitrary_loop() (1, None), // not sure how to hint for arbitrary_loop() ]), - ) + )) }) } @@ -1816,14 +1818,16 @@ impl<'a> ExprGenerator<'a> { /// size hint for generate_attr_value_for_schematype() #[allow(dead_code)] - pub fn generate_attr_value_for_schematype_size_hint(depth: usize) -> (usize, Option) { - arbitrary::size_hint::recursion_guard(depth, |depth| { - arbitrary::size_hint::or_all(&[ - Self::generate_attr_value_for_type_size_hint(depth), + pub fn generate_attr_value_for_schematype_size_hint( + depth: usize, + ) -> std::result::Result<(usize, Option), MaxRecursionReached> { + arbitrary::size_hint::try_recursion_guard(depth, |depth| { + Ok(arbitrary::size_hint::or_all(&[ + Self::generate_attr_value_for_type_size_hint(depth)?, (1, None), // not sure how to hint for arbitrary_loop() Self::arbitrary_uid_with_type_size_hint(depth), - Self::generate_attr_value_for_type_size_hint(depth), - ]) + Self::generate_attr_value_for_type_size_hint(depth)?, + ])) }) } diff --git a/cedar-policy-generators/src/schema.rs b/cedar-policy-generators/src/schema.rs index 7ed9f6a1c..e8e1bd3f8 100644 --- a/cedar-policy-generators/src/schema.rs +++ b/cedar-policy-generators/src/schema.rs @@ -28,7 +28,7 @@ use crate::request::Request; use crate::settings::ABACSettings; use crate::size_hint_utils::{size_hint_for_choose, size_hint_for_range, size_hint_for_ratio}; use crate::{accum, gen, gen_inner, uniform}; -use arbitrary::{self, Arbitrary, Unstructured}; +use arbitrary::{self, Arbitrary, MaxRecursionReached, Unstructured}; use cedar_policy_core::ast::{self, Effect, Id, Name, PolicyID}; use cedar_policy_core::extensions::Extensions; use cedar_policy_validator::{ @@ -118,13 +118,15 @@ fn arbitrary_attrspec( ))) } /// size hint for arbitrary_attrspec -fn arbitrary_attrspec_size_hint(depth: usize) -> (usize, Option) { - arbitrary::size_hint::recursion_guard(depth, |depth| { - arbitrary::size_hint::and_all(&[ +fn arbitrary_attrspec_size_hint( + depth: usize, +) -> std::result::Result<(usize, Option), MaxRecursionReached> { + arbitrary::size_hint::try_recursion_guard(depth, |depth| { + Ok(arbitrary::size_hint::and_all(&[ as Arbitrary>::size_hint(depth), arbitrary_typeofattribute_size_hint(depth), ::size_hint(depth), - ]) + ])) }) } @@ -965,19 +967,21 @@ impl Schema { }) } /// size hint for arbitrary() - pub fn arbitrary_size_hint(depth: usize) -> (usize, Option) { - arbitrary::size_hint::and_all(&[ + pub fn arbitrary_size_hint( + depth: usize, + ) -> std::result::Result<(usize, Option), MaxRecursionReached> { + Ok(arbitrary::size_hint::and_all(&[ as Arbitrary>::size_hint(depth), - arbitrary_attrspec_size_hint(depth), // actually we do one of these per Name that was generated - size_hint_for_ratio(1, 2), // actually many of these calls + arbitrary_attrspec_size_hint(depth)?, // actually we do one of these per Name that was generated + size_hint_for_ratio(1, 2), // actually many of these calls as Arbitrary>::size_hint(depth), size_hint_for_ratio(1, 8), // actually many of these calls size_hint_for_ratio(1, 4), // zero to many of these calls size_hint_for_ratio(1, 2), // zero to many of these calls - arbitrary_attrspec_size_hint(depth), + arbitrary_attrspec_size_hint(depth)?, size_hint_for_ratio(1, 2), // actually many of these calls ::size_hint(depth), - ]) + ])) } /// Get an arbitrary Hierarchy conforming to the schema. From de22c3e0cdcbbd2356c497b642f450c6d4f80870 Mon Sep 17 00:00:00 2001 From: John Kastner Date: Tue, 17 Dec 2024 21:41:39 +0000 Subject: [PATCH 3/4] update submodule Signed-off-by: John Kastner --- cedar | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cedar b/cedar index 97f7939d0..88d79937c 160000 --- a/cedar +++ b/cedar @@ -1 +1 @@ -Subproject commit 97f7939d0c8977ed342a312ab9d8ef03b28284e9 +Subproject commit 88d79937cd4fd5e91304f1aff855a92c77bda3c1 From 4d5ea9dc62081e3cfece282150c6d17eb5352b1a Mon Sep 17 00:00:00 2001 From: John Kastner Date: Wed, 18 Dec 2024 15:06:40 +0000 Subject: [PATCH 4/4] fix deprecated functions Signed-off-by: John Kastner --- cedar-drt/fuzz/fuzz_targets/abac-type-directed.rs | 12 +++++++----- cedar-drt/fuzz/fuzz_targets/abac.rs | 12 +++++++----- .../fuzz/fuzz_targets/common-type-resolution.rs | 6 ++++-- cedar-drt/fuzz/fuzz_targets/eval-type-directed.rs | 12 +++++++----- cedar-drt/fuzz/fuzz_targets/formatter.rs | 12 +++++++----- cedar-drt/fuzz/fuzz_targets/json-schema-roundtrip.rs | 6 ++++-- cedar-drt/fuzz/fuzz_targets/partial-eval.rs | 11 +++++++---- cedar-drt/fuzz/fuzz_targets/roundtrip.rs | 12 +++++++----- cedar-drt/fuzz/fuzz_targets/schema-roundtrip.rs | 6 ++++-- .../fuzz_targets/validation-drt-type-directed.rs | 12 +++++++----- cedar-drt/fuzz/fuzz_targets/validation-drt.rs | 12 +++++++----- .../fuzz_targets/validation-pbt-type-directed.rs | 12 +++++++----- cedar-drt/fuzz/fuzz_targets/validation-pbt.rs | 12 +++++++----- cedar-drt/fuzz/src/lib.rs | 3 +++ 14 files changed, 85 insertions(+), 55 deletions(-) diff --git a/cedar-drt/fuzz/fuzz_targets/abac-type-directed.rs b/cedar-drt/fuzz/fuzz_targets/abac-type-directed.rs index 2e6e1c7c6..1309e290b 100644 --- a/cedar-drt/fuzz/fuzz_targets/abac-type-directed.rs +++ b/cedar-drt/fuzz/fuzz_targets/abac-type-directed.rs @@ -27,7 +27,7 @@ use cedar_policy_generators::{ schema::Schema, settings::ABACSettings, }; -use libfuzzer_sys::arbitrary::{self, Arbitrary, Unstructured}; +use libfuzzer_sys::arbitrary::{self, Arbitrary, MaxRecursionReached, Unstructured}; use log::{debug, info}; use serde::Serialize; use std::convert::TryFrom; @@ -91,9 +91,11 @@ impl<'a> Arbitrary<'a> for FuzzTargetInput { }) } - fn size_hint(depth: usize) -> (usize, Option) { - arbitrary::size_hint::and_all(&[ - Schema::arbitrary_size_hint(depth), + fn try_size_hint( + depth: usize, + ) -> std::result::Result<(usize, Option), MaxRecursionReached> { + Ok(arbitrary::size_hint::and_all(&[ + Schema::arbitrary_size_hint(depth)?, HierarchyGenerator::size_hint(depth), Schema::arbitrary_policy_size_hint(&SETTINGS, depth), Schema::arbitrary_request_size_hint(depth), @@ -104,7 +106,7 @@ impl<'a> Arbitrary<'a> for FuzzTargetInput { Schema::arbitrary_request_size_hint(depth), Schema::arbitrary_request_size_hint(depth), Schema::arbitrary_request_size_hint(depth), - ]) + ])) } } diff --git a/cedar-drt/fuzz/fuzz_targets/abac.rs b/cedar-drt/fuzz/fuzz_targets/abac.rs index 5cdc38312..5c3fea5c5 100644 --- a/cedar-drt/fuzz/fuzz_targets/abac.rs +++ b/cedar-drt/fuzz/fuzz_targets/abac.rs @@ -26,7 +26,7 @@ use cedar_policy_generators::{ schema::Schema, settings::ABACSettings, }; -use libfuzzer_sys::arbitrary::{self, Arbitrary, Unstructured}; +use libfuzzer_sys::arbitrary::{self, Arbitrary, MaxRecursionReached, Unstructured}; use log::{debug, info}; use serde::Serialize; use std::convert::TryFrom; @@ -90,9 +90,11 @@ impl<'a> Arbitrary<'a> for FuzzTargetInput { }) } - fn size_hint(depth: usize) -> (usize, Option) { - arbitrary::size_hint::and_all(&[ - Schema::arbitrary_size_hint(depth), + fn try_size_hint( + depth: usize, + ) -> std::result::Result<(usize, Option), MaxRecursionReached> { + Ok(arbitrary::size_hint::and_all(&[ + Schema::arbitrary_size_hint(depth)?, HierarchyGenerator::size_hint(depth), Schema::arbitrary_policy_size_hint(&SETTINGS, depth), Schema::arbitrary_request_size_hint(depth), @@ -103,7 +105,7 @@ impl<'a> Arbitrary<'a> for FuzzTargetInput { Schema::arbitrary_request_size_hint(depth), Schema::arbitrary_request_size_hint(depth), Schema::arbitrary_request_size_hint(depth), - ]) + ])) } } diff --git a/cedar-drt/fuzz/fuzz_targets/common-type-resolution.rs b/cedar-drt/fuzz/fuzz_targets/common-type-resolution.rs index 10419b866..109bf7c1a 100644 --- a/cedar-drt/fuzz/fuzz_targets/common-type-resolution.rs +++ b/cedar-drt/fuzz/fuzz_targets/common-type-resolution.rs @@ -18,7 +18,7 @@ use cedar_drt_inner::{schemas::validator_schema_attr_types_equivalent, *}; use cedar_policy_generators::{schema::Schema, settings::ABACSettings}; use cedar_policy_validator::SchemaFragment; -use libfuzzer_sys::arbitrary::{self, Arbitrary, Unstructured}; +use libfuzzer_sys::arbitrary::{self, Arbitrary, MaxRecursionReached, Unstructured}; use log::info; use serde::Serialize; use similar_asserts::SimpleDiff; @@ -68,7 +68,9 @@ impl<'a> Arbitrary<'a> for Input { }) } - fn size_hint(depth: usize) -> (usize, Option) { + fn try_size_hint( + depth: usize, + ) -> std::result::Result<(usize, Option), MaxRecursionReached> { Schema::arbitrary_size_hint(depth) } } diff --git a/cedar-drt/fuzz/fuzz_targets/eval-type-directed.rs b/cedar-drt/fuzz/fuzz_targets/eval-type-directed.rs index ad3b41a37..986dfc9d9 100644 --- a/cedar-drt/fuzz/fuzz_targets/eval-type-directed.rs +++ b/cedar-drt/fuzz/fuzz_targets/eval-type-directed.rs @@ -24,7 +24,7 @@ use cedar_policy_generators::err::Error; use cedar_policy_generators::hierarchy::HierarchyGenerator; use cedar_policy_generators::schema::{arbitrary_schematype_with_bounded_depth, Schema}; use cedar_policy_generators::settings::ABACSettings; -use libfuzzer_sys::arbitrary::{self, Arbitrary, Unstructured}; +use libfuzzer_sys::arbitrary::{self, Arbitrary, MaxRecursionReached, Unstructured}; use log::debug; use serde::Serialize; use std::convert::TryFrom; @@ -88,9 +88,11 @@ impl<'a> Arbitrary<'a> for FuzzTargetInput { }) } - fn size_hint(depth: usize) -> (usize, Option) { - arbitrary::size_hint::and_all(&[ - Schema::arbitrary_size_hint(depth), + fn try_size_hint( + depth: usize, + ) -> std::result::Result<(usize, Option), MaxRecursionReached> { + Ok(arbitrary::size_hint::and_all(&[ + Schema::arbitrary_size_hint(depth)?, HierarchyGenerator::size_hint(depth), Schema::arbitrary_policy_size_hint(&SETTINGS, depth), Schema::arbitrary_request_size_hint(depth), @@ -101,7 +103,7 @@ impl<'a> Arbitrary<'a> for FuzzTargetInput { Schema::arbitrary_request_size_hint(depth), Schema::arbitrary_request_size_hint(depth), Schema::arbitrary_request_size_hint(depth), - ]) + ])) } } diff --git a/cedar-drt/fuzz/fuzz_targets/formatter.rs b/cedar-drt/fuzz/fuzz_targets/formatter.rs index 36c83894d..3cae61fdb 100644 --- a/cedar-drt/fuzz/fuzz_targets/formatter.rs +++ b/cedar-drt/fuzz/fuzz_targets/formatter.rs @@ -24,7 +24,7 @@ use cedar_policy_formatter::{lexer, policies_str_to_pretty, Config}; use cedar_policy_generators::{ abac::ABACPolicy, hierarchy::HierarchyGenerator, schema::Schema, settings::ABACSettings, }; -use libfuzzer_sys::arbitrary::{self, Arbitrary, Unstructured}; +use libfuzzer_sys::arbitrary::{self, Arbitrary, MaxRecursionReached, Unstructured}; use log::debug; use serde::Serialize; use similar_asserts::SimpleDiff; @@ -63,12 +63,14 @@ impl<'a> Arbitrary<'a> for FuzzTargetInput { Ok(Self { policy }) } - fn size_hint(depth: usize) -> (usize, Option) { - arbitrary::size_hint::and_all(&[ - Schema::arbitrary_size_hint(depth), + fn try_size_hint( + depth: usize, + ) -> std::result::Result<(usize, Option), MaxRecursionReached> { + Ok(arbitrary::size_hint::and_all(&[ + Schema::arbitrary_size_hint(depth)?, HierarchyGenerator::size_hint(depth), Schema::arbitrary_policy_size_hint(&SETTINGS, depth), - ]) + ])) } } diff --git a/cedar-drt/fuzz/fuzz_targets/json-schema-roundtrip.rs b/cedar-drt/fuzz/fuzz_targets/json-schema-roundtrip.rs index a4c1d1055..da4eedab0 100644 --- a/cedar-drt/fuzz/fuzz_targets/json-schema-roundtrip.rs +++ b/cedar-drt/fuzz/fuzz_targets/json-schema-roundtrip.rs @@ -19,7 +19,7 @@ use cedar_drt_inner::schemas::equivalence_check; use cedar_drt_inner::*; use cedar_policy_generators::{schema::Schema, settings::ABACSettings}; use cedar_policy_validator::SchemaFragment; -use libfuzzer_sys::arbitrary::{self, Arbitrary, Unstructured}; +use libfuzzer_sys::arbitrary::{self, Arbitrary, MaxRecursionReached, Unstructured}; use serde::Serialize; use std::collections::HashMap; @@ -57,7 +57,9 @@ impl<'a> Arbitrary<'a> for Input { Ok(Self { schema }) } - fn size_hint(depth: usize) -> (usize, Option) { + fn try_size_hint( + depth: usize, + ) -> std::result::Result<(usize, Option), MaxRecursionReached> { Schema::arbitrary_size_hint(depth) } } diff --git a/cedar-drt/fuzz/fuzz_targets/partial-eval.rs b/cedar-drt/fuzz/fuzz_targets/partial-eval.rs index 9c67b44a8..e4dc1e504 100644 --- a/cedar-drt/fuzz/fuzz_targets/partial-eval.rs +++ b/cedar-drt/fuzz/fuzz_targets/partial-eval.rs @@ -32,6 +32,7 @@ use cedar_policy_generators::{ schema::Schema, settings::ABACSettings, }; +use libfuzzer_sys::arbitrary::MaxRecursionReached; use libfuzzer_sys::arbitrary::{self, Arbitrary, Unstructured}; use log::debug; use serde::Serialize; @@ -100,9 +101,11 @@ impl<'a> Arbitrary<'a> for FuzzTargetInput { }) } - fn size_hint(depth: usize) -> (usize, Option) { - arbitrary::size_hint::and_all(&[ - Schema::arbitrary_size_hint(depth), + fn try_size_hint( + depth: usize, + ) -> std::result::Result<(usize, Option), MaxRecursionReached> { + Ok(arbitrary::size_hint::and_all(&[ + Schema::arbitrary_size_hint(depth)?, HierarchyGenerator::size_hint(depth), Schema::arbitrary_policy_size_hint(&SETTINGS, depth), Schema::arbitrary_request_size_hint(depth), @@ -113,7 +116,7 @@ impl<'a> Arbitrary<'a> for FuzzTargetInput { Schema::arbitrary_request_size_hint(depth), Schema::arbitrary_request_size_hint(depth), Schema::arbitrary_request_size_hint(depth), - ]) + ])) } } diff --git a/cedar-drt/fuzz/fuzz_targets/roundtrip.rs b/cedar-drt/fuzz/fuzz_targets/roundtrip.rs index 3688b6395..beecacb96 100644 --- a/cedar-drt/fuzz/fuzz_targets/roundtrip.rs +++ b/cedar-drt/fuzz/fuzz_targets/roundtrip.rs @@ -24,7 +24,7 @@ use cedar_policy_core::parser::{self, parse_policy}; use cedar_policy_generators::{ abac::ABACPolicy, hierarchy::HierarchyGenerator, schema::Schema, settings::ABACSettings, }; -use libfuzzer_sys::arbitrary::{self, Arbitrary, Unstructured}; +use libfuzzer_sys::arbitrary::{self, Arbitrary, MaxRecursionReached, Unstructured}; use log::debug; use serde::Serialize; use smol_str::SmolStr; @@ -61,12 +61,14 @@ impl<'a> Arbitrary<'a> for FuzzTargetInput { Ok(Self { policy }) } - fn size_hint(depth: usize) -> (usize, Option) { - arbitrary::size_hint::and_all(&[ - Schema::arbitrary_size_hint(depth), + fn try_size_hint( + depth: usize, + ) -> std::result::Result<(usize, Option), MaxRecursionReached> { + Ok(arbitrary::size_hint::and_all(&[ + Schema::arbitrary_size_hint(depth)?, HierarchyGenerator::size_hint(depth), Schema::arbitrary_policy_size_hint(&SETTINGS, depth), - ]) + ])) } } diff --git a/cedar-drt/fuzz/fuzz_targets/schema-roundtrip.rs b/cedar-drt/fuzz/fuzz_targets/schema-roundtrip.rs index ff47d4509..41d1e7707 100644 --- a/cedar-drt/fuzz/fuzz_targets/schema-roundtrip.rs +++ b/cedar-drt/fuzz/fuzz_targets/schema-roundtrip.rs @@ -19,7 +19,7 @@ use cedar_drt_inner::schemas::equivalence_check; use cedar_drt_inner::*; use cedar_policy_generators::{schema::Schema, settings::ABACSettings}; use cedar_policy_validator::SchemaFragment; -use libfuzzer_sys::arbitrary::{self, Arbitrary, Unstructured}; +use libfuzzer_sys::arbitrary::{self, Arbitrary, MaxRecursionReached, Unstructured}; use serde::Serialize; use std::collections::HashMap; @@ -57,7 +57,9 @@ impl<'a> Arbitrary<'a> for Input { Ok(Self { schema }) } - fn size_hint(depth: usize) -> (usize, Option) { + fn try_size_hint( + depth: usize, + ) -> std::result::Result<(usize, Option), MaxRecursionReached> { Schema::arbitrary_size_hint(depth) } } diff --git a/cedar-drt/fuzz/fuzz_targets/validation-drt-type-directed.rs b/cedar-drt/fuzz/fuzz_targets/validation-drt-type-directed.rs index bfd11e314..fca273b03 100644 --- a/cedar-drt/fuzz/fuzz_targets/validation-drt-type-directed.rs +++ b/cedar-drt/fuzz/fuzz_targets/validation-drt-type-directed.rs @@ -19,7 +19,7 @@ use cedar_drt::*; use cedar_drt_inner::*; use cedar_policy_core::ast; use cedar_policy_generators::{abac::ABACPolicy, schema::Schema, settings::ABACSettings}; -use libfuzzer_sys::arbitrary::{self, Arbitrary, Unstructured}; +use libfuzzer_sys::arbitrary::{self, Arbitrary, MaxRecursionReached, Unstructured}; use log::{debug, info}; use serde::Serialize; @@ -56,11 +56,13 @@ impl<'a> Arbitrary<'a> for FuzzTargetInput { Ok(Self { schema, policy }) } - fn size_hint(depth: usize) -> (usize, Option) { - arbitrary::size_hint::and_all(&[ - Schema::arbitrary_size_hint(depth), + fn try_size_hint( + depth: usize, + ) -> std::result::Result<(usize, Option), MaxRecursionReached> { + Ok(arbitrary::size_hint::and_all(&[ + Schema::arbitrary_size_hint(depth)?, Schema::arbitrary_policy_size_hint(&SETTINGS, depth), - ]) + ])) } } diff --git a/cedar-drt/fuzz/fuzz_targets/validation-drt.rs b/cedar-drt/fuzz/fuzz_targets/validation-drt.rs index 4a04ab03e..49c57db42 100644 --- a/cedar-drt/fuzz/fuzz_targets/validation-drt.rs +++ b/cedar-drt/fuzz/fuzz_targets/validation-drt.rs @@ -19,7 +19,7 @@ use cedar_drt::*; use cedar_drt_inner::*; use cedar_policy_core::ast; use cedar_policy_generators::{abac::ABACPolicy, schema::Schema, settings::ABACSettings}; -use libfuzzer_sys::arbitrary::{self, Arbitrary, Unstructured}; +use libfuzzer_sys::arbitrary::{self, Arbitrary, MaxRecursionReached, Unstructured}; use log::{debug, info}; use serde::Serialize; @@ -56,11 +56,13 @@ impl<'a> Arbitrary<'a> for FuzzTargetInput { Ok(Self { schema, policy }) } - fn size_hint(depth: usize) -> (usize, Option) { - arbitrary::size_hint::and_all(&[ - Schema::arbitrary_size_hint(depth), + fn try_size_hint( + depth: usize, + ) -> std::result::Result<(usize, Option), MaxRecursionReached> { + Ok(arbitrary::size_hint::and_all(&[ + Schema::arbitrary_size_hint(depth)?, Schema::arbitrary_policy_size_hint(&SETTINGS, depth), - ]) + ])) } } diff --git a/cedar-drt/fuzz/fuzz_targets/validation-pbt-type-directed.rs b/cedar-drt/fuzz/fuzz_targets/validation-pbt-type-directed.rs index 96929b0af..72f65624c 100644 --- a/cedar-drt/fuzz/fuzz_targets/validation-pbt-type-directed.rs +++ b/cedar-drt/fuzz/fuzz_targets/validation-pbt-type-directed.rs @@ -28,7 +28,7 @@ use cedar_policy_generators::{ settings::ABACSettings, }; use cedar_policy_validator::{ValidationMode, Validator, ValidatorSchema}; -use libfuzzer_sys::arbitrary::{self, Arbitrary, Unstructured}; +use libfuzzer_sys::arbitrary::{self, Arbitrary, MaxRecursionReached, Unstructured}; use log::debug; use serde::Serialize; use std::convert::TryFrom; @@ -89,9 +89,11 @@ impl<'a> Arbitrary<'a> for FuzzTargetInput { }) } - fn size_hint(depth: usize) -> (usize, Option) { - arbitrary::size_hint::and_all(&[ - Schema::arbitrary_size_hint(depth), + fn try_size_hint( + depth: usize, + ) -> std::result::Result<(usize, Option), MaxRecursionReached> { + Ok(arbitrary::size_hint::and_all(&[ + Schema::arbitrary_size_hint(depth)?, HierarchyGenerator::size_hint(depth), Schema::arbitrary_policy_size_hint(&SETTINGS, depth), Schema::arbitrary_request_size_hint(depth), @@ -102,7 +104,7 @@ impl<'a> Arbitrary<'a> for FuzzTargetInput { Schema::arbitrary_request_size_hint(depth), Schema::arbitrary_request_size_hint(depth), Schema::arbitrary_request_size_hint(depth), - ]) + ])) } } diff --git a/cedar-drt/fuzz/fuzz_targets/validation-pbt.rs b/cedar-drt/fuzz/fuzz_targets/validation-pbt.rs index d2ef8ef19..558c5b54e 100644 --- a/cedar-drt/fuzz/fuzz_targets/validation-pbt.rs +++ b/cedar-drt/fuzz/fuzz_targets/validation-pbt.rs @@ -31,7 +31,7 @@ use cedar_policy_generators::{ use cedar_policy_validator::{ ApplySpec, NamespaceDefinition, ValidationMode, Validator, ValidatorSchema, }; -use libfuzzer_sys::arbitrary::{self, Arbitrary, Unstructured}; +use libfuzzer_sys::arbitrary::{self, Arbitrary, MaxRecursionReached, Unstructured}; use log::debug; use serde::Serialize; use std::convert::TryFrom; @@ -298,9 +298,11 @@ impl<'a> Arbitrary<'a> for FuzzTargetInput { }) } - fn size_hint(depth: usize) -> (usize, Option) { - arbitrary::size_hint::and_all(&[ - Schema::arbitrary_size_hint(depth), + fn try_size_hint( + depth: usize, + ) -> std::result::Result<(usize, Option), MaxRecursionReached> { + Ok(arbitrary::size_hint::and_all(&[ + Schema::arbitrary_size_hint(depth)?, HierarchyGenerator::size_hint(depth), Schema::arbitrary_policy_size_hint(&SETTINGS, depth), Schema::arbitrary_request_size_hint(depth), @@ -311,7 +313,7 @@ impl<'a> Arbitrary<'a> for FuzzTargetInput { Schema::arbitrary_request_size_hint(depth), Schema::arbitrary_request_size_hint(depth), Schema::arbitrary_request_size_hint(depth), - ]) + ])) } } diff --git a/cedar-drt/fuzz/src/lib.rs b/cedar-drt/fuzz/src/lib.rs index 7306b8330..26cb9d3a0 100644 --- a/cedar-drt/fuzz/src/lib.rs +++ b/cedar-drt/fuzz/src/lib.rs @@ -21,6 +21,7 @@ pub use dump::*; pub use prt::*; pub mod schemas; +#[allow(deprecated)] use cedar_policy::frontend::is_authorized::InterfaceResponse; use cedar_policy::PolicyId; use cedar_policy_core::ast; @@ -123,6 +124,7 @@ pub fn run_auth_test( } } TestResult::Success(definitional_res) => { + #[allow(deprecated)] let rust_res_for_comparison: InterfaceResponse = { let errors = match custom_impl.error_comparison_mode() { ErrorComparisonMode::Ignore => HashSet::new(), @@ -143,6 +145,7 @@ pub fn run_auth_test( .map(ToString::to_string) .collect(), }; + #[allow(deprecated)] InterfaceResponse::new( rust_res.decision, rust_res