Skip to content

Commit

Permalink
fix(runtime): negate partial condition for deny flags (denoland#22866)
Browse files Browse the repository at this point in the history
  • Loading branch information
nayeemrmn authored Mar 12, 2024
1 parent c10d96c commit 485b4c6
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion runtime/permissions/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ impl<T: Descriptor + Hash> UnaryPermission<T> {
get_display_name: impl Fn() -> Option<String>,
) -> Result<(), AnyError> {
let (result, prompted, is_allow_all) = self
.query_desc(desc, AllowPartial::from(assert_non_partial))
.query_desc(desc, AllowPartial::from(!assert_non_partial))
.check2(
T::flag_name(),
api_name,
Expand Down Expand Up @@ -2858,6 +2858,31 @@ mod tests {
assert_eq!(perms.env.revoke(Some("HomE")), PermissionState::Prompt);
}

#[test]
fn test_check_partial_denied() {
let mut perms = Permissions {
read: Permissions::new_read(
&Some(vec![]),
&Some(vec![PathBuf::from("/foo/bar")]),
false,
)
.unwrap(),
write: Permissions::new_write(
&Some(vec![]),
&Some(vec![PathBuf::from("/foo/bar")]),
false,
)
.unwrap(),
..Default::default()
};

perms.read.check_partial(Path::new("/foo"), None).unwrap();
assert!(perms.read.check(Path::new("/foo"), None).is_err());

perms.write.check_partial(Path::new("/foo"), None).unwrap();
assert!(perms.write.check(Path::new("/foo"), None).is_err());
}

#[test]
fn test_deserialize_child_permissions_arg() {
set_prompter(Box::new(TestPrompter));
Expand Down

0 comments on commit 485b4c6

Please sign in to comment.