Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Refactor permissions #7074

Merged
merged 13 commits into from
Aug 18, 2020
Merged

fix: Refactor permissions #7074

merged 13 commits into from
Aug 18, 2020

Conversation

nayeemrmn
Copy link
Collaborator

@nayeemrmn nayeemrmn commented Aug 16, 2020

Fix granular permission requests/revokes. Properly model the "denied" state.

Fixes #7049.

Internal structure before:

pub struct Permissions {
  pub allow_read: PermissionState,
  pub read_allowlist: HashSet<PathBuf>,
  pub allow_write: PermissionState,
  pub write_allowlist: HashSet<PathBuf>,
  pub allow_net: PermissionState,
  pub net_allowlist: HashSet<String>,
  pub allow_env: PermissionState,
  pub allow_run: PermissionState,
  pub allow_plugin: PermissionState,
  pub allow_hrtime: PermissionState,
}

Internal structure after:

pub struct UnaryPermission<T: Eq + Hash> {
  global_state: PermissionState,
  granted_list: HashSet<T>,
  denied_list: HashSet<T>,
}

pub struct Permissions {
  pub read: UnaryPermission<PathBuf>,
  pub write: UnaryPermission<PathBuf>,
  pub net: UnaryPermission<String>,
  pub env: PermissionState,
  pub run: PermissionState,
  pub plugin: PermissionState,
  pub hrtime: PermissionState,
}

See docs/runtime/permission_apis.md for the corrected user-facing semantics.

@ry
Copy link
Member

ry commented Aug 17, 2020

@nayeemrmn Nice. I think this looks ok. I don't see the test case presented in #7049 here - or did I miss it? It would be good to capture that.

@nayeemrmn
Copy link
Collaborator Author

@ry Ready for review 😩

docs/runtime/permission_apis.md Outdated Show resolved Hide resolved
cli/tests/integration_tests.rs Outdated Show resolved Hide resolved
Copy link
Member

@ry ry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - thank you @nayeemrmn very nice refactor

@ry ry merged commit 015fa0b into denoland:master Aug 18, 2020
@nayeemrmn nayeemrmn deleted the permissions-refactor branch August 18, 2020 20:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Request and Revoke Permissions doesn't work properly
2 participants