extension_host: Add npm:install
capability (#35144)
This PR adds a new `npm:install` capability for installing npm packges in extensions. Currently all npm packages are allowed. Release Notes: - N/A
This commit is contained in:
parent
2a0170dc3c
commit
89e88c245e
5 changed files with 69 additions and 2 deletions
|
@ -63,6 +63,24 @@ impl CapabilityGranter {
|
|||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn grant_npm_install_package(&self, package_name: &str) -> Result<()> {
|
||||
let is_allowed = self
|
||||
.granted_capabilities
|
||||
.iter()
|
||||
.any(|capability| match capability {
|
||||
ExtensionCapability::NpmInstallPackage(capability) => {
|
||||
capability.allows(package_name)
|
||||
}
|
||||
_ => false,
|
||||
});
|
||||
|
||||
if !is_allowed {
|
||||
bail!("capability for npm:install {package_name} is not granted by the extension host",);
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue