Skip to content

Commit

Permalink
remove partial-auth and partial-eval DRT targets (#566)
Browse files Browse the repository at this point in the history
Signed-off-by: Craig Disselkoen <cdiss@amazon.com>
  • Loading branch information
cdisselkoen authored Mar 4, 2025
1 parent 434f09f commit 71e13dc
Show file tree
Hide file tree
Showing 9 changed files with 2 additions and 461 deletions.
12 changes: 0 additions & 12 deletions cedar-drt/fuzz/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -68,18 +68,6 @@ path = "fuzz_targets/abac-type-directed.rs"
test = false
doc = false

[[bin]]
name = "partial-eval"
path = "fuzz_targets/partial-eval.rs"
test = false
doc = false

[[bin]]
name = "partial-auth"
path = "fuzz_targets/partial-auth.rs"
test = false
doc = false

[[bin]]
name = "roundtrip"
path = "fuzz_targets/roundtrip.rs"
Expand Down
128 changes: 0 additions & 128 deletions cedar-drt/fuzz/fuzz_targets/partial-auth.rs

This file was deleted.

133 changes: 0 additions & 133 deletions cedar-drt/fuzz/fuzz_targets/partial-eval.rs

This file was deleted.

4 changes: 1 addition & 3 deletions cedar-drt/fuzz/fuzz_targets/protobuf-roundtrip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

use libfuzzer_sys::arbitrary::{self, MaxRecursionReached};
use prost::Message;
use serde::Serialize;

use crate::arbitrary::Arbitrary;
use crate::arbitrary::Unstructured;
Expand All @@ -34,9 +33,8 @@ use cedar_policy_generators::{
settings::ABACSettings,
};

#[derive(Debug, Clone, Serialize)]
#[derive(Debug, Clone)]
struct FuzzTargetInput {
#[serde(skip)]
request: ABACRequest,
policy: ABACPolicy,
entities: Entities,
Expand Down
3 changes: 1 addition & 2 deletions cedar-drt/fuzz/fuzz_targets/wildcard-matching.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,10 @@ use cedar_drt_inner::fuzz_target;
use cedar_policy_core::ast::{Pattern, PatternElem};
use libfuzzer_sys::arbitrary::{self, Arbitrary, Result, Unstructured};
use regex::{escape, Regex};
use serde::Serialize;

/// Input expected by this fuzz target:
/// A pattern and a string that matches it
#[derive(Debug, Clone, Serialize)]
#[derive(Debug, Clone)]
struct FuzzTargetInput {
/// generated pattern
pub pattern: Vec<PatternElem>,
Expand Down
58 changes: 0 additions & 58 deletions cedar-drt/fuzz/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,64 +46,6 @@ pub const RUST_VALIDATION_MSG: &str = "rust_validation (ns) : ";
pub const RUST_ENT_VALIDATION_MSG: &str = "rust_entity_validation (ns) : ";
pub const RUST_REQ_VALIDATION_MSG: &str = "rust_request_validation (ns) : ";

/// Compare the behavior of the partial evaluator in `cedar-policy` against a custom Cedar
/// implementation. Panics if the two do not agree. `expr` is the expression to
/// evaluate and `request` and `entities` are used to populate the evaluator.
pub fn run_pe_test(
custom_impl: &impl CedarTestImplementation,
request: ast::Request,
expr: &ast::Expr,
entities: &Entities,
enable_extensions: bool,
) {
let exts = if enable_extensions {
Extensions::all_available()
} else {
Extensions::none()
};

let eval = Evaluator::new(request.clone(), entities, exts);
use cedar_policy_core::ast::PartialValue;
use cedar_testing::cedar_test_impl::ExprOrValue;
use log::debug;
let expected = match eval.partial_interpret(expr, &std::collections::HashMap::default()) {
Ok(PartialValue::Value(v)) => Some(ExprOrValue::value(v)),
Ok(PartialValue::Residual(r)) => Some(ExprOrValue::Expr(r)),
Err(_) => None,
};
debug!("Expected: {expected:?}");

let definitional_res = custom_impl.partial_evaluate(
&request,
entities,
expr,
enable_extensions,
expected.clone(),
);
match definitional_res {
TestResult::Failure(err) => {
// TODO(#175): Ignore cases where the definitional code returned an error due to
// an unknown extension function.
if err.contains("unknown extension function") {
return;
}
// No other errors are expected
panic!("Unexpected error for {request}\nExpression: {expr}\nError: {err}");
}
TestResult::Success(response) => {
// The definitional interpreter response should be `true`
assert!(
response,
"Incorrect evaluation result for {request}\nExpression: {expr}\nEntities:\n{entities}\nExpected value:\n{:?}\n",
match expected {
None => "error".to_string(),
Some(e_or_v) => e_or_v.to_string()
}
)
}
}
}

/// Compare the behavior of the evaluator in `cedar-policy` against a custom Cedar
/// implementation. Panics if the two do not agree. `expr` is the expression to
/// evaluate and `request` and `entities` are used to populate the evaluator.
Expand Down
Loading

0 comments on commit 71e13dc

Please sign in to comment.