diff --git a/stdlib/src/notification.rs b/stdlib/src/notification.rs index 07e07b65..60f2e2b7 100644 --- a/stdlib/src/notification.rs +++ b/stdlib/src/notification.rs @@ -1,7 +1,11 @@ use crate::{StdFunction, StdlibModule, StdlibRegistry}; use std::collections::HashMap; use std::rc::Rc; -use techscript_runtime::{error::RuntimeError, value::RuntimeValue}; +use techscript_runtime::{ + context::Capability, + error::{RuntimeError, RuntimeErrorKind}, + value::RuntimeValue, +}; impl StdlibRegistry { pub fn register_notification(&mut self) { @@ -13,7 +17,17 @@ impl StdlibRegistry { Rc::new(StdFunction { name: "show".to_string(), arity: 2, - callback: |_ctx, args| { + callback: |ctx, args| { + if !ctx.config.capabilities.contains(&Capability::Process) { + return Err(RuntimeError::new( + RuntimeErrorKind::InvalidOperation( + "Security policy violation: Process capability is denied" + .to_string(), + ), + None, + None, + )); + } let title = args[0].to_string(); let body = args[1].to_string(); #[cfg(target_os = "windows")] @@ -46,7 +60,17 @@ impl StdlibRegistry { Rc::new(StdFunction { name: "alert".to_string(), arity: 1, - callback: |_ctx, args| { + callback: |ctx, args| { + if !ctx.config.capabilities.contains(&Capability::Process) { + return Err(RuntimeError::new( + RuntimeErrorKind::InvalidOperation( + "Security policy violation: Process capability is denied" + .to_string(), + ), + None, + None, + )); + } let msg = args[0].to_string(); #[cfg(target_os = "windows")] { @@ -69,7 +93,7 @@ impl StdlibRegistry { name: "std.notification".to_string(), version: "1.0.0".to_string(), exports, - required_capabilities: Vec::new(), + required_capabilities: vec![Capability::Process], }, ); }