Skip to main content

par_term_config/config/config_struct/
security_config.rs

1//! Configuration security policy.
2//!
3//! Extracted from the top-level [`super::Config`] struct via `#[serde(flatten)]`.
4//! All fields serialise at the top level of the YAML config file -- existing
5//! config files remain 100% compatible.
6
7use serde::{Deserialize, Serialize};
8
9/// Environment variable substitution allowlist and plain-HTTP profile fetching.
10#[derive(Debug, Clone, Serialize, Deserialize)]
11pub struct SecurityConfig {
12    /// Allow all environment variables in config `${VAR}` substitution.
13    ///
14    /// When `false` (default), only a safe allowlist of environment variables
15    /// (HOME, USER, SHELL, XDG_*, PAR_TERM_*, LC_*, etc.) can be substituted.
16    /// This prevents shared or downloaded config files from exfiltrating
17    /// sensitive environment variables such as API keys or tokens.
18    ///
19    /// Set to `true` to restore the unrestricted pre-0.24 behaviour.
20    #[serde(default = "crate::defaults::bool_false")]
21    pub allow_all_env_vars: bool,
22
23    /// Allow dynamic profile sources to be fetched over plain HTTP (not HTTPS).
24    ///
25    /// When `false` (the default), any `dynamic_profile_sources` entry whose URL
26    /// uses the `http://` scheme will be refused with an error at fetch time.
27    /// This prevents a network-level attacker from injecting malicious profiles
28    /// via a man-in-the-middle attack on an untrusted network.
29    ///
30    /// Set to `true` only if you must fetch profiles from a server that does not
31    /// support HTTPS (e.g., an internal dev server without TLS). A warning will
32    /// still be logged in that case.
33    #[serde(default = "crate::defaults::bool_false")]
34    pub allow_http_profiles: bool,
35}
36
37impl Default for SecurityConfig {
38    fn default() -> Self {
39        Self {
40            allow_all_env_vars: crate::defaults::bool_false(),
41            allow_http_profiles: crate::defaults::bool_false(),
42        }
43    }
44}