Skip to content

Commit d282618

Browse files
author
Aaron Eline
authored
Disallow unknown and bump version to 3.2.2 (#1103)
Signed-off-by: Aaron Eline <aeline+github@amazon.com>
1 parent 26c6b94 commit d282618

File tree

13 files changed

+94
-21
lines changed

13 files changed

+94
-21
lines changed

cedar-policy-cli/Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name = "cedar-policy-cli"
33
edition = "2021"
44
rust-version = "1.76.0" # minimum supported Rust version is currently 1.76.0 because `cedar-policy-core` requirement. Check with `cargo install cargo-msrv && cargo msrv --min 1.75.0`
55

6-
version = "3.2.1"
6+
version = "3.2.2"
77
license = "Apache-2.0"
88
categories = ["compilers", "config"]
99
description = "CLI interface for the Cedar Policy language."
@@ -12,8 +12,8 @@ homepage = "https://cedarpolicy.com"
1212
repository = "https://github.com/cedar-policy/cedar"
1313

1414
[dependencies]
15-
cedar-policy = { version = "=3.2.1", path = "../cedar-policy" }
16-
cedar-policy-formatter = { version = "=3.2.1", path = "../cedar-policy-formatter" }
15+
cedar-policy = { version = "=3.2.2", path = "../cedar-policy" }
16+
cedar-policy-formatter = { version = "=3.2.2", path = "../cedar-policy-formatter" }
1717
clap = { version = "4", features = ["derive", "env"] }
1818
serde = { version = "1.0", features = ["derive"] }
1919
serde_json = "1.0"

cedar-policy-core/Cargo.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ edition = "2021"
44
rust-version = "1.76.0" # minimum supported Rust version is currently 1.76.0 because of use of `Arc::unwrap_or_clone()`. Check with `cargo install cargo-msrv && cargo msrv --min 1.75.0`
55
build = "build.rs"
66

7-
version = "3.2.1"
7+
version = "3.2.2"
88
license = "Apache-2.0"
99
categories = ["compilers", "config"]
1010
description = "Core implemenation of the Cedar Policy language."
@@ -57,3 +57,6 @@ lalrpop = "0.20.0"
5757

5858
[dev-dependencies]
5959
cool_asserts = "2.0"
60+
61+
[lints.rust]
62+
unexpected_cfgs = { level = 'deny', check-cfg = ['cfg(fuzzing)'] }

cedar-policy-core/src/authorizer.rs

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,7 @@ mod test {
272272
.expect("Policy Creation Failed")
273273
}
274274

275+
#[cfg(feature = "partial-eval")]
275276
fn context_pol(id: &str, effect: Effect) -> StaticPolicy {
276277
let pid = PolicyID::from_string(id);
277278
StaticPolicy::new(
@@ -308,6 +309,7 @@ mod test {
308309
}
309310

310311
#[test]
312+
#[cfg(feature = "partial-eval")]
311313
fn authorizer_sanity_check_partial_deny() {
312314
let context = Context::from_expr(
313315
RestrictedExpr::record([(
@@ -392,6 +394,44 @@ mod test {
392394
let mut pset = PolicySet::new();
393395
let es = Entities::new();
394396

397+
let src1 = r#"
398+
permit(principal == test_entity_type::"p",action,resource);
399+
"#;
400+
let src2 = r#"
401+
forbid(principal == test_entity_type::"p",action,resource) when {
402+
false
403+
};
404+
"#;
405+
406+
pset.add_static(
407+
parser::parse_policy(Some(PolicyID::from_string("1").to_string()), src1).unwrap(),
408+
)
409+
.unwrap();
410+
pset.add_static(
411+
parser::parse_policy(Some(PolicyID::from_string("2").to_string()), src2).unwrap(),
412+
)
413+
.unwrap();
414+
415+
let r = a.is_authorized_core(q.clone(), &pset, &es).decision();
416+
assert_eq!(r, Some(Decision::Allow));
417+
}
418+
419+
#[test]
420+
#[cfg(feature = "partial-eval")]
421+
fn satisfied_permit_no_forbids_unknown() {
422+
let q = Request::new(
423+
(EntityUID::with_eid("p"), None),
424+
(EntityUID::with_eid("a"), None),
425+
(EntityUID::with_eid("r"), None),
426+
Context::empty(),
427+
None::<&RequestSchemaAllPass>,
428+
Extensions::none(),
429+
)
430+
.unwrap();
431+
let a = Authorizer::new();
432+
let mut pset = PolicySet::new();
433+
let es = Entities::new();
434+
395435
let src1 = r#"
396436
permit(principal == test_entity_type::"p",action,resource);
397437
"#;
@@ -431,6 +471,7 @@ mod test {
431471
}
432472

433473
#[test]
474+
#[cfg(feature = "partial-eval")]
434475
fn satisfied_permit_residual_forbid() {
435476
let q = Request::new(
436477
(EntityUID::with_eid("p"), None),
@@ -479,6 +520,7 @@ mod test {
479520
}
480521

481522
#[test]
523+
#[cfg(feature = "partial-eval")]
482524
fn no_permits() {
483525
let q = Request::new(
484526
(EntityUID::with_eid("p"), None),
@@ -541,6 +583,7 @@ mod test {
541583
}
542584

543585
#[test]
586+
#[cfg(feature = "partial-eval")]
544587
fn residual_permits() {
545588
let q = Request::new(
546589
(EntityUID::with_eid("p"), None),

cedar-policy-core/src/extensions.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ lazy_static::lazy_static! {
3434
ipaddr::extension(),
3535
#[cfg(feature = "decimal")]
3636
decimal::extension(),
37+
#[cfg(feature = "partial-eval")]
3738
partial_evaluation::extension(),
3839
];
3940
}

cedar-policy-core/src/extensions/partial_evaluation.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16+
#![cfg(feature = "partial-eval")]
1617

1718
//! This module contains the extension for including unknown values
1819
use crate::{

cedar-policy-formatter/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "cedar-policy-formatter"
3-
version = "3.2.1"
3+
version = "3.2.2"
44
edition = "2021"
55
rust-version = "1.76.0" # minimum supported Rust version is currently 1.76.0 because `cedar-policy-core` requirement. Check with `cargo install cargo-msrv && cargo msrv --min 1.75.0`
66
license = "Apache-2.0"
@@ -11,7 +11,7 @@ homepage = "https://cedarpolicy.com"
1111
repository = "https://github.com/cedar-policy/cedar"
1212

1313
[dependencies]
14-
cedar-policy-core = { version = "=3.2.1", path = "../cedar-policy-core" }
14+
cedar-policy-core = { version = "=3.2.2", path = "../cedar-policy-core" }
1515
pretty = "0.12.1"
1616
logos = "0.14.0"
1717
itertools = "0.12"

cedar-policy-validator/Cargo.toml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name = "cedar-policy-validator"
33
edition = "2021"
44
rust-version = "1.76.0" # minimum supported Rust version is currently 1.76.0 because `cedar-policy-core` requirement. Check with `cargo install cargo-msrv && cargo msrv --min 1.75.0`
55

6-
version = "3.2.1"
6+
version = "3.2.2"
77
license = "Apache-2.0"
88
categories = ["compilers", "config"]
99
description = "Validator for the Cedar Policy language."
@@ -12,7 +12,7 @@ homepage = "https://cedarpolicy.com"
1212
repository = "https://github.com/cedar-policy/cedar"
1313

1414
[dependencies]
15-
cedar-policy-core = { version = "=3.2.1", path = "../cedar-policy-core" }
15+
cedar-policy-core = { version = "=3.2.2", path = "../cedar-policy-core" }
1616
serde = { version = "1.0", features = ["derive"] }
1717
serde_json = { version = "1.0", features = ["preserve_order"] }
1818
serde_with = "3.0"
@@ -38,6 +38,7 @@ default = ["ipaddr", "decimal"]
3838
# when enabling a feature, make sure that the Core feature is also enabled
3939
ipaddr = ["cedar-policy-core/ipaddr"]
4040
decimal = ["cedar-policy-core/decimal"]
41+
partial-eval = ["cedar-policy-core/partial-eval"]
4142

4243
# Enables `Arbitrary` implementations for several types in this crate
4344
arbitrary = ["dep:arbitrary"]
@@ -48,7 +49,7 @@ wasm = ["serde-wasm-bindgen", "tsify", "wasm-bindgen"]
4849

4950
[dev-dependencies]
5051
cool_asserts = "2.0"
51-
cedar-policy-core = { version = "=3.2.1", path = "../cedar-policy-core", features = [
52+
cedar-policy-core = { version = "=3.2.2", path = "../cedar-policy-core", features = [
5253
"test-util",
5354
] }
5455

cedar-policy-validator/src/extensions.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ pub fn all_available_extension_schemas() -> Vec<ExtensionSchema> {
3333
ipaddr::extension_schema(),
3434
#[cfg(feature = "decimal")]
3535
decimal::extension_schema(),
36+
#[cfg(feature = "partial-eval")]
3637
partial_evaluation::extension_schema(),
3738
]
3839
}

cedar-policy-validator/src/extensions/partial_evaluation.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
//! out-of-date with the decimal extension definition in CedarCore.
1919
//! This is tested by the `extension_schema_correctness()` test
2020
21+
#![cfg(feature = "partial-eval")]
2122
use crate::extension_schema::{ExtensionFunctionType, ExtensionSchema};
2223
use crate::types::{self, Type};
2324
use cedar_policy_core::extensions::partial_evaluation;

cedar-policy/Cargo.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name = "cedar-policy"
33
edition = "2021"
44
rust-version = "1.76.0" # minimum supported Rust version is currently 1.76.0 because `cedar-policy-core` requirement. Check with `cargo install cargo-msrv && cargo msrv --min 1.75.0`
55

6-
version = "3.2.1"
6+
version = "3.2.2"
77
license = "Apache-2.0"
88
categories = ["compilers", "config"]
99
description = "Cedar is a language for defining permissions as policies, which describe who should have access to what."
@@ -12,8 +12,8 @@ homepage = "https://cedarpolicy.com"
1212
repository = "https://github.com/cedar-policy/cedar"
1313

1414
[dependencies]
15-
cedar-policy-core = { version = "=3.2.1", path = "../cedar-policy-core" }
16-
cedar-policy-validator = { version = "=3.2.1", path = "../cedar-policy-validator" }
15+
cedar-policy-core = { version = "=3.2.2", path = "../cedar-policy-core" }
16+
cedar-policy-validator = { version = "=3.2.2", path = "../cedar-policy-validator" }
1717
ref-cast = "1.0"
1818
serde = { version = "1.0", features = ["derive", "rc"] }
1919
serde_json = "1.0"
@@ -48,7 +48,7 @@ integration_testing = []
4848
# Experimental features.
4949
# Enable all experimental features with `cargo build --features "experimental"`
5050
experimental = ["partial-eval", "permissive-validate", "partial-validate"]
51-
partial-eval = ["cedar-policy-core/partial-eval"]
51+
partial-eval = ["cedar-policy-core/partial-eval", "cedar-policy-validator/partial-eval"]
5252
permissive-validate = []
5353
partial-validate = ["cedar-policy-validator/partial-validate"]
5454
wasm = ["serde-wasm-bindgen", "tsify", "wasm-bindgen"]

0 commit comments

Comments
 (0)