Skip to content

Commit ea7c20d

Browse files
committed
permit -> grant
Signed-off-by: Scott Andrews <scott@andrews.me>
1 parent 10db4ee commit ea7c20d

11 files changed

Lines changed: 39 additions & 39 deletions

File tree

Cargo.lock

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Makefile

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,18 +53,18 @@ $(foreach component,$(TEST_COMPONENTS),$(eval $(call TEST_COMPONENT,$(component)
5353
lib/tests/logging-to-stdout.wasm:
5454
wkg oci pull ghcr.io/componentized/logging/to-stdout:v0.2.1 -o "lib/tests/logging-to-stdout.wasm"
5555

56-
lib/tests/permit.wasm: lib/gate.wasm lib/latch-permit-all.wasm
56+
lib/tests/grant.wasm: lib/gate.wasm lib/latch-grant-all.wasm
5757
wac plug lib/gate.wasm \
58-
--plug lib/latch-permit-all.wasm \
59-
-o lib/tests/permit.wasm
58+
--plug lib/latch-grant-all.wasm \
59+
-o lib/tests/grant.wasm
6060

61-
lib/tests/filesystem-cli-permit.wasm: lib/tests/filesystem-cli.wasm lib/tests/permit.wasm lib/tests/logging-to-stdout.wasm
61+
lib/tests/filesystem-cli-grant.wasm: lib/tests/filesystem-cli.wasm lib/tests/grant.wasm lib/tests/logging-to-stdout.wasm
6262
wac plug lib/tests/filesystem-cli.wasm \
6363
--plug <( \
64-
wac plug lib/tests/permit.wasm \
64+
wac plug lib/tests/grant.wasm \
6565
--plug lib/tests/logging-to-stdout.wasm \
6666
) \
67-
-o lib/tests/filesystem-cli-permit.wasm
67+
-o lib/tests/filesystem-cli-grant.wasm
6868

6969
lib/tests/deny.wasm: lib/gate.wasm lib/latch-deny-all.wasm
7070
wac plug lib/gate.wasm \
@@ -79,7 +79,7 @@ lib/tests/filesystem-cli-deny.wasm: lib/tests/filesystem-cli.wasm lib/tests/deny
7979
) \
8080
-o lib/tests/filesystem-cli-deny.wasm
8181

82-
lib/tests/readonly.wasm: lib/gate.wasm lib/latch-n2.wasm lib/latch-readonly.wasm lib/latch-permit-all.wasm
82+
lib/tests/readonly.wasm: lib/gate.wasm lib/latch-n2.wasm lib/latch-readonly.wasm lib/latch-grant-all.wasm
8383
wac plug lib/gate.wasm \
8484
--plug lib/latch-readonly.wasm \
8585
-o lib/tests/readonly.wasm
@@ -93,7 +93,7 @@ lib/tests/filesystem-cli-readonly.wasm: lib/tests/filesystem-cli.wasm lib/tests/
9393
-o lib/tests/filesystem-cli-readonly.wasm
9494

9595
.PHONY: tests
96-
tests: $(foreach component,$(TEST_COMPONENTS),lib/tests/$(component).wasm) lib/tests/filesystem-cli-permit.wasm lib/tests/filesystem-cli-deny.wasm lib/tests/filesystem-cli-readonly.wasm
96+
tests: $(foreach component,$(TEST_COMPONENTS),lib/tests/$(component).wasm) lib/tests/filesystem-cli-grant.wasm lib/tests/filesystem-cli-deny.wasm lib/tests/filesystem-cli-readonly.wasm
9797

9898
.PHONY: wit
9999
wit: wit/deps

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ A collection of utility components that remix wasi:filesystem types and interfac
2020
- [`latch-n3`](./components/latch-n3/)
2121
- [`latch-n4`](./components/latch-n4/)
2222
- [`latch-deny-all`](./components/latch-deny-all/)
23-
- [`latch-permit-all`](./components/latch-permit-all/)
23+
- [`latch-grant-all`](./components/latch-grant-all/)
2424
- [`latch-glob`](./components/latch-glob/)
2525
- [`latch-readonly`](./components/latch-readonly/)
2626
- ~~[`readonly`](./components/readonly/)~~ (deprecated, favor gate with readonly latch)

components/latch-glob/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# `latch-glob`
22

3-
Filesystem latch that uses glob patterns to permit or deny operations on a path.
3+
Filesystem latch that uses glob patterns to grant or deny operations on a path.
44

5-
The patterns are defined in a wasi:config/store. Keys starting with `deny` are parsed as globs with matching path operations being denied. Multiple patterns are allowed by defining unique config keys (e.g. `deny-1`, `deny-2`, etc). Keys starting with `permit` are parsed as globs with matching path operations being permitted.
5+
The patterns are defined in a wasi:config/store. Keys starting with `deny` are parsed as globs with matching path operations being denied. Multiple patterns are allowed by defining unique config keys (e.g. `deny-1`, `deny-2`, etc). Keys starting with `grant` are parsed as globs with matching path operations being granted.
66

77
Operations are evaluated against the pattern with the base path for the operation joined with a relative path, if any. For example, the file descriptor open-at operation will join the descriptor's path with the argument's path, the resulting path is matched to the patterns.
88

components/latch-glob/src/lib.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ struct GlobLatch {}
1717
struct Patterns {
1818
initialized: bool,
1919
denies: Option<Vec<Box<dyn PathMatcher>>>,
20-
permits: Option<Vec<Box<dyn PathMatcher>>>,
20+
grants: Option<Vec<Box<dyn PathMatcher>>>,
2121
deny_reason: Option<ErrorCode>,
2222
}
2323

@@ -28,16 +28,16 @@ impl Patterns {
2828
}
2929

3030
let mut denies: Vec<Box<dyn PathMatcher>> = vec![];
31-
let mut permits: Vec<Box<dyn PathMatcher>> = vec![];
31+
let mut grants: Vec<Box<dyn PathMatcher>> = vec![];
3232
let mut reason = ErrorCode::NotPermitted;
3333

3434
for (key, value) in wasi::config::store::get_all().expect("config must be available") {
3535
if key.starts_with("deny") {
3636
denies.push(Box::new(
3737
glob(&value).expect("config value must parse as a glob"),
3838
));
39-
} else if key.starts_with("permit") {
40-
permits.push(Box::new(
39+
} else if key.starts_with("grant") {
40+
grants.push(Box::new(
4141
glob(&value).expect("config value must parse as a glob"),
4242
));
4343
} else if key == "reason" {
@@ -47,7 +47,7 @@ impl Patterns {
4747

4848
unsafe {
4949
STATE.denies = Some(denies);
50-
STATE.permits = Some(permits);
50+
STATE.grants = Some(grants);
5151
STATE.deny_reason = Some(reason);
5252
STATE.initialized = true;
5353
};
@@ -63,9 +63,9 @@ impl Patterns {
6363
for p in paths {
6464
let path = Path::new(&path).join(p);
6565
match unsafe { STATE.authorize_path(&path) } {
66-
// return denies immediately, buffer permits
66+
// return denies immediately, buffer grants
6767
Some(Decision::Denied(reason)) => return Some(Decision::Denied(reason)),
68-
Some(Decision::Permitted) => decision = Some(Decision::Permitted),
68+
Some(Decision::Granted) => decision = Some(Decision::Granted),
6969
None => {}
7070
}
7171
}
@@ -78,9 +78,9 @@ impl Patterns {
7878
return Some(Decision::Denied(self.deny_reason.unwrap()));
7979
}
8080
}
81-
for permit in self.permits.as_ref().unwrap() {
82-
if permit.matches(path) {
83-
return Some(Decision::Permitted);
81+
for grant in self.grants.as_ref().unwrap() {
82+
if grant.matches(path) {
83+
return Some(Decision::Granted);
8484
}
8585
}
8686
None
@@ -90,7 +90,7 @@ impl Patterns {
9090
static mut STATE: Patterns = Patterns {
9191
initialized: false,
9292
denies: None,
93-
permits: None,
93+
grants: None,
9494
deny_reason: None,
9595
};
9696

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[package]
2-
name = "latch-permit-all"
2+
name = "latch-grant-all"
33
version = "0.1.0"
44
edition = "2021"
55
license = "Apache-2.0"
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# `latch-grant-all`
2+
3+
Filesystem latch that implicitly grants all operations.
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
use crate::exports::componentized::filesystem::latch::{Decision, Guest as Latch, Operation};
44

5-
struct PermitAllLatch {}
5+
struct GrantAllLatch {}
66

7-
impl Latch for PermitAllLatch {
7+
impl Latch for GrantAllLatch {
88
fn authorize(_: Operation) -> Option<Decision> {
9-
Some(Decision::Permitted)
9+
Some(Decision::Granted)
1010
}
1111
}
1212

@@ -16,4 +16,4 @@ wit_bindgen::generate!({
1616
generate_all
1717
});
1818

19-
export!(PermitAllLatch);
19+
export!(GrantAllLatch);

components/latch-permit-all/README.md

Lines changed: 0 additions & 3 deletions
This file was deleted.

crates/latch-n/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ pub fn authorize(
2121
for authorize in authorizers {
2222
match authorize(&operation) {
2323
None => {}
24-
Some(latch::Decision::Permitted) => return Some(Decision::Permitted),
24+
Some(latch::Decision::Granted) => return Some(Decision::Granted),
2525
Some(latch::Decision::Denied(error_code)) => return Some(Decision::Denied(error_code)),
2626
}
2727
}

0 commit comments

Comments
 (0)