ailloli_ui_terminal_core/
security.rs

1//! Explicit allow/deny policy for terminal-originated side effects.
2
3use serde::{Deserialize, Serialize};
4
5/// Security gates applied by terminal parser/state integrations.
6///
7/// `true` permits the named capability; `false` requires the sequence/action to
8/// be blocked or ignored by the consumer. This data type does not enforce the
9/// policy itself. The default allows presentation-only title/hyperlink changes
10/// and denies clipboard, query, and shell-integration capabilities.
11///
12/// # Examples
13///
14/// ```
15/// use ailloli_ui_terminal_core::TerminalSecurityPolicy;
16/// let policy = TerminalSecurityPolicy::default();
17/// assert!(policy.allow_title_change && policy.allow_hyperlinks);
18/// assert!(!policy.allow_clipboard_write && !policy.allow_shell_integration);
19/// ```
20#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
21pub struct TerminalSecurityPolicy {
22    /// Permit terminal escape sequences to replace the window/tab title.
23    pub allow_title_change: bool,
24    /// Permit OSC 8 hyperlink definitions and cell links.
25    pub allow_hyperlinks: bool,
26    /// Permit terminal-originated writes to the host clipboard.
27    pub allow_clipboard_write: bool,
28    /// Permit terminal-originated reads from the host clipboard.
29    pub allow_clipboard_read: bool,
30    /// Permit terminal queries that require a host response.
31    pub allow_terminal_queries: bool,
32    /// Permit private shell-integration control sequences.
33    pub allow_shell_integration: bool,
34}
35
36impl Default for TerminalSecurityPolicy {
37    fn default() -> Self {
38        Self {
39            allow_title_change: true,
40            allow_hyperlinks: true,
41            allow_clipboard_write: false,
42            allow_clipboard_read: false,
43            allow_terminal_queries: false,
44            allow_shell_integration: false,
45        }
46    }
47}