diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 610ebcb61a..2ddfde537d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -48,7 +48,7 @@ jobs: - name: Install rust uses: hecrj/setup-rust-action@v1 with: - rust-version: "1.41.0" + rust-version: "1.42.0" - name: Install clippy and rustfmt if: matrix.kind == 'lint' diff --git a/cli/ops/permissions.rs b/cli/ops/permissions.rs index 6d109e0a81..55358b760c 100644 --- a/cli/ops/permissions.rs +++ b/cli/ops/permissions.rs @@ -43,11 +43,11 @@ pub fn op_query_permission( ) -> Result { let args: PermissionArgs = serde_json::from_value(args)?; let state = state.borrow(); - let resolved_path = args.path.as_ref().map(String::as_str).map(resolve_path); + let resolved_path = args.path.as_deref().map(resolve_path); let perm = state.permissions.get_permission_state( &args.name, - &args.url.as_ref().map(String::as_str), - &resolved_path.as_ref().map(String::as_str).map(Path::new), + &args.url.as_deref(), + &resolved_path.as_deref().map(Path::new), )?; Ok(JsonOp::Sync(json!({ "state": perm.to_string() }))) } @@ -70,11 +70,11 @@ pub fn op_revoke_permission( "hrtime" => permissions.allow_hrtime.revoke(), _ => {} }; - let resolved_path = args.path.as_ref().map(String::as_str).map(resolve_path); + let resolved_path = args.path.as_deref().map(resolve_path); let perm = permissions.get_permission_state( &args.name, - &args.url.as_ref().map(String::as_str), - &resolved_path.as_ref().map(String::as_str).map(Path::new), + &args.url.as_deref(), + &resolved_path.as_deref().map(Path::new), )?; Ok(JsonOp::Sync(json!({ "state": perm.to_string() }))) } @@ -87,16 +87,16 @@ pub fn op_request_permission( let args: PermissionArgs = serde_json::from_value(args)?; let mut state = state.borrow_mut(); let permissions = &mut state.permissions; - let resolved_path = args.path.as_ref().map(String::as_str).map(resolve_path); + let resolved_path = args.path.as_deref().map(resolve_path); let perm = match args.name.as_ref() { "run" => Ok(permissions.request_run()), - "read" => Ok(permissions.request_read( - &resolved_path.as_ref().map(String::as_str).map(Path::new), - )), - "write" => Ok(permissions.request_write( - &resolved_path.as_ref().map(String::as_str).map(Path::new), - )), - "net" => permissions.request_net(&args.url.as_ref().map(String::as_str)), + "read" => { + Ok(permissions.request_read(&resolved_path.as_deref().map(Path::new))) + } + "write" => { + Ok(permissions.request_write(&resolved_path.as_deref().map(Path::new))) + } + "net" => permissions.request_net(&args.url.as_deref()), "env" => Ok(permissions.request_env()), "plugin" => Ok(permissions.request_plugin()), "hrtime" => Ok(permissions.request_hrtime()),