Enable credential masking for remote exec-server commands (#54309)

## What changed

Negotiate executor support for `credential_masking` and enable built-in credential brokerage in executor-local network proxies. Supported non-login Bash commands on Linux and macOS receive credential placeholders, with real credentials injected by the proxy for matching destinations.

Retain credential mappings across process launches within the same executor session, scoped by environment, conversation, and broker configuration. Keep credentials and destination context on the executor.

Fall back to unmasked execution for unsupported shells or shell startup, and for configured credential providers. Emit warnings when masking is unavailable, preserving shell profiles and snapshots.

## Testing

Add coverage for capability negotiation, fallback behavior, mapping reuse and isolation, proxy credential injection, and keeping executor credentials out of model-visible request history. Test warning, removal, and rejection modes for credentials left unmasked during preparation.

GitOrigin-RevId: f64e916a5de8350fa0d289d3440ec29761accd75
This commit is contained in:
viyatb-oai
2026-10-15 14:41:16 +00:00
committed by copyberry
parent 3ee47c1051
commit 7d33d0d93f
22 changed files with 1370 additions and 329 deletions
@@ -45,6 +45,17 @@ pub(crate) const BROKERED_CREDENTIALS_ENV_KEY: &str = "CODEX_NETWORK_PROXY_BROKE
const MIN_EMBEDDED_CREDENTIAL_LENGTH: usize = 16;
const BROKERED_CREDENTIAL_ALIAS_MARKER_PREFIX: &str = "@alias:";
/// How to handle recognized credentials left raw in a prepared command environment.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum CredentialMaskingFailureMode {
/// Warn and keep the unmasked values.
Warn,
/// Remove variables containing unmasked values, including copied aliases.
Deny,
/// Reject the command environment.
Error,
}
#[derive(Clone)]
pub(crate) struct CredentialBroker {
state: Arc<RwLock<CredentialBrokerState>>,
@@ -1120,6 +1131,59 @@ impl CredentialBroker {
matching::virtualize_text(&state, text, env)
}
pub(crate) fn handle_unmasked_credentials(
&self,
env: &mut HashMap<String, String>,
mode: CredentialMaskingFailureMode,
) -> anyhow::Result<()> {
let state = self.read_state();
anyhow::ensure!(
state.enabled,
"credential masking requires an enabled credential broker"
);
let mut unmasked_keys = Vec::new();
for (key, value) in env.iter() {
let value = value.trim();
let known = matching::known_credential_matches(&state, value, env);
let contains_real_credential = known
.iter()
.any(|matched| matched.value == matched.real_value);
let remainder = matching::mask_known_credentials(value, &known);
let mut masked = remainder.clone();
if contains_real_credential
|| !matching::virtualize_text(&state, &mut masked, env)
|| masked != remainder
{
unmasked_keys.push(key.clone());
}
}
drop(state);
if unmasked_keys.is_empty() {
return Ok(());
}
match mode {
CredentialMaskingFailureMode::Warn => {
tracing::warn!(
"Credential masking could not protect some environment credentials; continuing with those values unmasked."
);
}
CredentialMaskingFailureMode::Deny => {
for key in unmasked_keys {
env.remove(&key);
}
tracing::warn!(
"Credential masking could not protect some environment credentials; removed those variables before execution."
);
}
CredentialMaskingFailureMode::Error => {
anyhow::bail!(
"credential masking left an unmasked credential in the command environment"
);
}
}
Ok(())
}
pub(crate) fn restore_text(&self, text: &mut String) -> bool {
let state = self.read_state();
if !state.enabled {
@@ -46,6 +46,62 @@ fn assert_credential_shape(real_value: &str, dummy_value: &str, prefix: &str) {
assert!(same_shape);
}
#[test]
fn unmasked_credentials_follow_the_selected_failure_mode() {
for (enabled, source, base_url, expected) in [
(true, "GH_TOKEN", None, true),
(true, "GH_ENTERPRISE_TOKEN", None, false),
(
true,
"OPENAI_API_KEY",
Some("https://localhost:1234/v1"),
false,
),
(false, "GH_TOKEN", None, false),
] {
let broker = CredentialBroker::new(enabled);
broker.configure(&NetworkProxyConfig {
credential_broker: enabled,
allow_local_binding: Some(true),
..NetworkProxyConfig::default()
});
let mut env = env_map([
(source, "opaque-executor-credential"),
("AUTH_HEADER", "Bearer opaque-executor-credential"),
]);
if let Some(base_url) = base_url {
env.insert("OPENAI_BASE_URL".to_string(), base_url.to_string());
}
broker.virtualize_child_env(&mut env);
for alias_only in [false, true] {
let mut input = env.clone();
if alias_only {
input.remove(source);
}
for mode in [
CredentialMaskingFailureMode::Warn,
CredentialMaskingFailureMode::Deny,
CredentialMaskingFailureMode::Error,
] {
let mut output = input.clone();
assert_eq!(
broker
.handle_unmasked_credentials(&mut output, mode)
.is_ok(),
enabled && (expected || mode != CredentialMaskingFailureMode::Error),
"{source} {mode:?} (alias_only={alias_only})"
);
let mut expected_env = input.clone();
if enabled && !expected && mode == CredentialMaskingFailureMode::Deny {
expected_env.remove(source);
expected_env.remove("AUTH_HEADER");
}
assert_eq!(output, expected_env);
}
}
}
}
#[test]
fn virtualize_child_env_replaces_supported_credentials() {
let broker = CredentialBroker::new(/*enabled*/ true);
+2
View File
@@ -54,6 +54,7 @@ pub use credential_broker::CREDENTIAL_BROKER_ACTIVE_ENV_KEY;
pub use credential_broker::CredentialAuthMethod;
pub use credential_broker::CredentialBrokerContext;
pub use credential_broker::CredentialBrokerEnvironment;
pub use credential_broker::CredentialMaskingFailureMode;
pub use credential_broker::CredentialProviderConfig;
pub use credential_broker::brokered_credential_binding_env_keys;
pub use credential_broker::brokered_credential_dummy_env_keys;
@@ -105,6 +106,7 @@ pub use proxy::has_proxy_url_env_vars;
pub use proxy::is_managed_proxy_env_var;
pub use proxy::proxy_url_env_value;
pub use proxy::strip_managed_proxy_env;
pub use remote_config::RemoteCredentialBrokerCache;
pub use remote_config::RemoteNetworkProxyConfig;
pub use remote_config::RemoteNetworkProxyLaunchConfig;
pub use request_cancellation::NetworkRequestCancellation;
+79 -16
View File
@@ -933,13 +933,27 @@ impl NetworkProxy {
}
/// Captures the static inputs needed to launch a matching executor-local proxy.
/// Credential masking requires an explicit caller opt-in and a capable executor.
pub async fn remote_launch_config(
&self,
local_binding_policy: crate::LocalBindingPolicy,
credential_masking: bool,
) -> Result<crate::RemoteNetworkProxyLaunchConfig> {
let (mut config, brokerage_created_default_allowlist, _) =
self.state.current_cfg_with_brokerage_provenance().await?;
// Proxy enablement and credential brokerage remain controller-owned.
// Configured providers are not transported yet, so these commands run unmasked.
let credential_masking = credential_masking
&& config.enabled
&& config.credential_broker
&& config.credential_providers.is_empty();
anyhow::ensure!(
!credential_masking
|| (!config.dangerously_allow_plaintext_credential_injection
&& config.mitm_hooks.is_empty()
&& config.mitm_ca.is_none()),
"executor credential masking does not support plaintext injection, MITM hooks, or external CAs"
);
// Legacy controller-only brokerage must not enable a remote proxy by itself.
let mut broker_only_config = config::NetworkProxyConfig {
enabled: config.enabled,
allow_local_binding: config.allow_local_binding.filter(|binding| !binding),
@@ -973,7 +987,7 @@ impl NetworkProxy {
.as_ref()
.and_then(|scope| scope.environment_policy.as_ref());
if config.credential_broker {
config.enabled &= !broker_only;
config.enabled &= !broker_only || credential_masking;
config.credential_broker = false;
config.dangerously_allow_plaintext_credential_injection = false;
if config.mitm && config.mitm_hooks.is_empty() && config.mitm_ca.is_none() {
@@ -994,7 +1008,8 @@ impl NetworkProxy {
|| config.allow_local_binding(),
"MXC cannot enforce allow_local_binding=false: native host-loopback access is bidirectional; use true or a different sandbox backend"
);
let proxy = crate::RemoteNetworkProxyConfig::from_effective_config(&config)?;
let mut proxy = crate::RemoteNetworkProxyConfig::from_effective_config(&config)?;
proxy.credential_masking = credential_masking;
tracing::debug!(network_config = ?proxy, "resolved remote execution network configuration");
let (environment_id, execution_id) = self
.execution_scope
@@ -1149,11 +1164,13 @@ impl NetworkProxy {
runtime_settings.allow_local_binding,
runtime_settings.mitm_ca_trust_bundle.as_ref(),
);
let credential_environment_id = environment_id.or_else(|| {
self.execution_scope
.as_ref()
.map(|scope| scope.environment_id.as_str())
});
let credential_environment_id = environment_id
.or_else(|| {
self.execution_scope
.as_ref()
.map(|scope| scope.environment_id.as_str())
})
.or(self.state.environment_id());
self.state
.virtualize_child_credentials_for_environment(&mut env, credential_environment_id);
if let Some(execution_scope) = self.execution_scope.as_ref() {
@@ -1288,6 +1305,15 @@ impl NetworkProxy {
self.state.virtualize_brokered_text(text, env)
}
/// Applies the selected failure mode to recognized credentials left unmasked after preparation.
pub fn handle_unmasked_credentials(
&self,
env: &mut HashMap<String, String>,
mode: crate::CredentialMaskingFailureMode,
) -> anyhow::Result<()> {
self.state.handle_unmasked_credentials(env, mode)
}
/// Returns trusted provider metadata and active bindings for a child environment.
pub fn credential_broker_environment(
&self,
@@ -1918,7 +1944,9 @@ mod tests {
);
assert_eq!(proxy.current_cfg().await?, config);
let remote = proxy.remote_launch_config(DefaultFalse).await?;
let remote = proxy
.remote_launch_config(DefaultFalse, /*credential_masking*/ false)
.await?;
assert_eq!(
(
remote.proxy.unix_sockets,
@@ -2015,7 +2043,7 @@ mod tests {
owner_config.set_denied_domains(vec!["denied.example".to_string()]);
assert_eq!(
scoped
.remote_launch_config(DefaultFalse)
.remote_launch_config(DefaultFalse, /*credential_masking*/ false)
.await?
.proxy
.domains,
@@ -2432,7 +2460,7 @@ mod tests {
"GH_HOST".to_string(),
"local-github.example".to_string(),
)]));
let state = Arc::new(network_proxy_state_for_policy(config));
let state = Arc::new(network_proxy_state_for_policy(config.clone()));
let proxy = match NetworkProxy::builder().state(state).build().await {
Ok(proxy) => proxy,
Err(err) => {
@@ -2453,7 +2481,9 @@ mod tests {
/*environment_policy*/ None,
/*fallback_policy_decider*/ None,
)?;
let launch = scoped.remote_launch_config(RequireTrue).await?;
let launch = scoped
.remote_launch_config(RequireTrue, /*credential_masking*/ false)
.await?;
let prepared = scoped.prepare_for_optional_environment(
HashMap::from([(
PROXY_ATTRIBUTION_TOKEN_ENV_KEY.to_string(),
@@ -2465,6 +2495,34 @@ mod tests {
assert_eq!(launch.environment_id.as_deref(), Some("remote-env"));
assert_eq!(launch.execution_id.as_deref(), Some("execution-1"));
assert!(!launch.proxy.enabled);
assert!(
scoped
.remote_launch_config(DefaultFalse, /*credential_masking*/ true)
.await
.is_err()
);
config.credential_providers.insert(
"vendor".to_string(),
crate::CredentialProviderConfig {
env: vec!["VENDOR_TOKEN".to_string()],
patterns: vec!["vendor_[a-z]{8}".to_string()],
url_prefixes: vec!["https://api.vendor.example".to_string()],
auth: vec![crate::CredentialAuthMethod::Bearer],
..crate::CredentialProviderConfig::default()
},
);
let custom_provider_proxy = NetworkProxy::builder()
.state(Arc::new(network_proxy_state_for_policy(config)))
.build()
.await?;
assert_eq!(
custom_provider_proxy
.remote_launch_config(DefaultFalse, /*credential_masking*/ true)
.await?
.proxy,
launch.proxy
);
let mut owner_config = NetworkProxyConfig::default();
owner_config.set_allowed_domains(vec!["owner.example".to_string()]);
@@ -2480,7 +2538,7 @@ mod tests {
)?;
assert!(
owner_scoped
.remote_launch_config(DefaultFalse)
.remote_launch_config(DefaultFalse, /*credential_masking*/ false)
.await
.is_err()
);
@@ -2512,9 +2570,14 @@ mod tests {
.state(Arc::new(network_proxy_state_for_policy(config)))
.build()
.await?;
let launch = proxy.remote_launch_config(DefaultFalse).await?;
assert!(launch.proxy.enabled);
assert_eq!(launch.proxy.mode, mode);
for credential_masking in [false, true] {
let launch = proxy
.remote_launch_config(DefaultFalse, credential_masking)
.await?;
assert!(launch.proxy.enabled);
assert_eq!(launch.proxy.mode, mode);
assert_eq!(launch.proxy.credential_masking, credential_masking);
}
}
assert_eq!(
prepared
+69 -4
View File
@@ -2,12 +2,72 @@ use anyhow::Result;
use anyhow::ensure;
use serde::Deserialize;
use serde::Serialize;
use std::sync::Mutex;
use crate::NetworkDomainPermissions;
use crate::NetworkMode;
use crate::NetworkProxyAuditMetadata;
use crate::NetworkProxyConfig;
use crate::NetworkUnixSocketPermissions;
use crate::credential_broker::CredentialBroker;
/// Credential mappings retained by one executor session across process launches.
/// Only mappings are shared; proxy listeners, network policy, and approvals remain per command.
#[derive(Default)]
pub struct RemoteCredentialBrokerCache {
brokers: Mutex<Vec<CachedCredentialBroker>>,
}
struct CachedCredentialBroker {
environment_id: Option<String>,
conversation_id: Option<String>,
config: NetworkProxyConfig,
broker: CredentialBroker,
}
impl RemoteCredentialBrokerCache {
pub(crate) fn broker_if_enabled(
&self,
environment_id: Option<&str>,
conversation_id: Option<&str>,
config: &NetworkProxyConfig,
) -> Option<CredentialBroker> {
if !config.credential_broker {
return None;
}
// Retain broker configuration and the command's destination context so ordinary
// network-policy changes preserve placeholders, while destination changes cannot
// invalidate another command's mappings.
let config = NetworkProxyConfig {
credential_broker: config.credential_broker,
allow_local_binding: Some(config.allow_local_binding()),
credential_broker_openai_host: config.credential_broker_openai_host.clone(),
credential_broker_context: config.credential_broker_context.clone(),
credential_providers: config.credential_providers.clone(),
..NetworkProxyConfig::default()
};
let mut brokers = self
.brokers
.lock()
.unwrap_or_else(std::sync::PoisonError::into_inner);
if let Some(cached) = brokers.iter().find(|cached| {
cached.environment_id.as_deref() == environment_id
&& cached.conversation_id.as_deref() == conversation_id
&& cached.config == config
}) {
return Some(cached.broker.clone());
}
let broker = CredentialBroker::new(config.credential_broker);
broker.configure(&config);
brokers.push(CachedCredentialBroker {
environment_id: environment_id.map(str::to_owned),
conversation_id: conversation_id.map(str::to_owned),
config,
broker: broker.clone(),
});
Some(broker)
}
}
/// Executor-local proxy launch inputs transported with one process start.
///
@@ -55,13 +115,15 @@ impl RemoteNetworkProxyLaunchConfig {
/// Effective network proxy settings that are safe to send to a remote executor.
///
/// Listener addresses are deliberately omitted because the executor chooses its own loopback
/// ports. MITM, credential injection, and hooks are not represented so their configuration cannot
/// cross the exec-server boundary accidentally.
/// ports. Masking carries only built-in broker activation; credentials, destination context, custom
/// providers, CA configuration, and MITM hooks stay on their execution host.
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
#[serde(rename_all = "camelCase")]
#[non_exhaustive]
pub struct RemoteNetworkProxyConfig {
pub enabled: bool,
#[serde(default, skip_serializing_if = "std::ops::Not::not")]
pub credential_masking: bool,
pub enable_socks5: bool,
pub enable_socks5_udp: bool,
pub allow_upstream_proxy: bool,
@@ -85,6 +147,7 @@ impl RemoteNetworkProxyConfig {
);
Ok(Self {
enabled: config.enabled,
credential_masking: false,
enable_socks5: config.enable_socks5,
enable_socks5_udp: config.enable_socks5_udp,
allow_upstream_proxy: config.allow_upstream_proxy,
@@ -99,7 +162,7 @@ impl RemoteNetworkProxyConfig {
}
pub(crate) fn into_network_proxy_config(self) -> NetworkProxyConfig {
NetworkProxyConfig {
let mut config = NetworkProxyConfig {
enabled: self.enabled,
enable_socks5: self.enable_socks5,
enable_socks5_udp: self.enable_socks5_udp,
@@ -110,7 +173,9 @@ impl RemoteNetworkProxyConfig {
unix_sockets: self.unix_sockets,
allow_local_binding: Some(self.allow_local_binding),
..NetworkProxyConfig::default()
}
};
config.set_credential_broker_enabled(self.credential_masking);
config
}
}
@@ -47,11 +47,13 @@ fn optional_socket_policy_preserves_input_and_resolves_at_remote_boundary() {
#[tokio::test]
async fn round_trip_preserves_supported_effective_settings() {
for (executor_os, socket) in [
(Platform::Linux, "/var/run/example.sock"),
(Platform::Macos, "/var/run/example.sock"),
(Platform::Windows, r"C:\example.sock"),
(Platform::Unknown, r"C:\example.sock"),
for (executor_os, socket, credential_masking) in [
(Platform::Linux, "/var/run/example.sock", false),
(Platform::Linux, "/var/run/example.sock", true),
(Platform::Macos, "/var/run/example.sock", false),
(Platform::Macos, "/var/run/example.sock", true),
(Platform::Windows, r"C:\example.sock", false),
(Platform::Unknown, r"C:\example.sock", false),
] {
let mut config = NetworkProxyConfig {
enabled: true,
@@ -67,8 +69,10 @@ async fn round_trip_preserves_supported_effective_settings() {
config.set_denied_domains(vec!["blocked.example.com".into()]);
config.set_allow_unix_sockets(vec![socket.into()]);
let remote = RemoteNetworkProxyConfig::from_effective_config(&config)
let mut remote = RemoteNetworkProxyConfig::from_effective_config(&config)
.expect("supported remote config");
remote.credential_masking = credential_masking;
config.set_credential_broker_enabled(credential_masking);
let round_trip = remote.clone().into_network_proxy_config();
assert_eq!(round_trip, config);
@@ -77,6 +81,8 @@ async fn round_trip_preserves_supported_effective_settings() {
NetworkProxyState::from_remote_launch_config(
RemoteNetworkProxyLaunchConfig::new(remote),
executor_os,
&crate::RemoteCredentialBrokerCache::default(),
&std::collections::HashMap::new(),
)
.unwrap(),
);
@@ -96,7 +102,7 @@ async fn round_trip_preserves_supported_effective_settings() {
);
assert_eq!(
proxy
.remote_launch_config(DefaultFalse)
.remote_launch_config(DefaultFalse, credential_masking)
.await
.unwrap()
.proxy
@@ -210,6 +216,8 @@ fn launch_config_materializes_audit_and_execution_attribution() {
policy_decision_timeout_ms: None,
},
Platform::native(),
&crate::RemoteCredentialBrokerCache::default(),
&std::collections::HashMap::new(),
)
.expect("remote launch state");
@@ -218,6 +226,104 @@ fn launch_config_materializes_audit_and_execution_attribution() {
assert_eq!(state.execution_id().as_deref(), Some("execution-1"));
}
#[test]
fn remote_credential_mappings_follow_the_environment_and_broker_config() {
const TOKEN: &str = "ghp_abcdefghijklmnopqrstuvwxyz0123456789";
let brokers = crate::RemoteCredentialBrokerCache::default();
let launch = |environment_id: &str,
conversation_id: &str,
mode,
allow_local_binding,
env: &std::collections::HashMap<String, String>| {
let mut proxy = RemoteNetworkProxyConfig::from_effective_config(&NetworkProxyConfig {
enabled: true,
allow_local_binding: Some(allow_local_binding),
mode,
..NetworkProxyConfig::default()
})
.unwrap();
proxy.credential_masking = true;
NetworkProxyState::from_remote_launch_config(
RemoteNetworkProxyLaunchConfig::new(proxy)
.for_execution(environment_id.to_string(), "execution".to_string())
.with_audit_metadata(NetworkProxyAuditMetadata {
conversation_id: Some(conversation_id.to_string()),
..NetworkProxyAuditMetadata::default()
}),
Platform::Linux,
&brokers,
env,
)
.unwrap()
};
let mut env = std::collections::HashMap::from([
("GH_ENTERPRISE_TOKEN".to_string(), TOKEN.to_string()),
(
"GH_HOST".to_string(),
"github.enterprise.example".to_string(),
),
]);
let first = launch(
"remote",
"thread",
NetworkMode::Full,
/*allow_local_binding*/ false,
&env,
);
first.virtualize_child_credentials(&mut env);
let placeholder = env["GH_ENTERPRISE_TOKEN"].clone();
assert_ne!(placeholder, TOKEN);
let mut next_env = std::collections::HashMap::from([
("GH_ENTERPRISE_TOKEN".to_string(), TOKEN.to_string()),
("GH_HOST".to_string(), String::new()),
]);
let next = launch(
"remote",
"thread",
NetworkMode::Full,
/*allow_local_binding*/ false,
&next_env,
);
next.virtualize_child_credentials(&mut next_env);
let mut headers = rama_http::HeaderMap::from_iter([(
rama_http::header::AUTHORIZATION,
rama_http::HeaderValue::from_str(&format!("Bearer {placeholder}")).unwrap(),
)]);
first.inject_request_credentials("github.enterprise.example", &mut headers);
assert_eq!(
headers[rama_http::header::AUTHORIZATION].to_str().unwrap(),
format!("Bearer {TOKEN}")
);
drop(first);
for (environment_id, conversation_id, allow_local_binding, expected) in [
("remote", "thread", false, TOKEN),
("other", "thread", false, placeholder.as_str()),
("remote", "other", false, placeholder.as_str()),
("remote", "thread", true, placeholder.as_str()),
] {
// A different network mode must not discard mappings for the same scope.
let state = launch(
environment_id,
conversation_id,
NetworkMode::Limited,
allow_local_binding,
&env,
);
let mut headers = rama_http::HeaderMap::new();
headers.insert(
rama_http::header::AUTHORIZATION,
rama_http::HeaderValue::from_str(&format!("Bearer {placeholder}")).unwrap(),
);
state.inject_request_credentials("github.enterprise.example", &mut headers);
assert_eq!(
headers[rama_http::header::AUTHORIZATION].to_str().unwrap(),
format!("Bearer {expected}")
);
}
}
#[test]
fn policy_decision_callback_timeout_round_trips() {
let config = RemoteNetworkProxyConfig::from_effective_config(&NetworkProxyConfig::default())
@@ -258,7 +364,7 @@ async fn local_binding_is_resolved_for_each_executor() -> anyhow::Result<()> {
.await?;
assert_eq!(
proxy
.remote_launch_config(policy)
.remote_launch_config(policy, /*credential_masking*/ false)
.await
.ok()
.map(|launch| launch.proxy.allow_local_binding),
+24 -3
View File
@@ -334,6 +334,8 @@ impl NetworkProxyState {
pub fn from_remote_launch_config(
launch: crate::RemoteNetworkProxyLaunchConfig,
executor_os: crate::Platform,
credential_brokers: &crate::RemoteCredentialBrokerCache,
environment: &HashMap<String, String>,
) -> Result<Self> {
let crate::RemoteNetworkProxyLaunchConfig {
proxy,
@@ -346,9 +348,15 @@ impl NetworkProxyState {
proxy.enabled,
"executor-local network proxy launch requires an enabled proxy"
);
let config = proxy.into_network_proxy_config();
let mut config = proxy.into_network_proxy_config();
config.configure_credential_broker_environment(environment);
let state = build_config_state(config, NetworkProxyConstraints::default(), executor_os)?;
Ok(Self {
let cached_broker = credential_brokers.broker_if_enabled(
environment_id.as_deref(),
audit_metadata.conversation_id.as_deref(),
&state.config,
);
let mut proxy_state = Self {
environment_id: environment_id.map(Into::into),
execution_id: execution_id.map(Into::into),
..Self::with_reloader_and_audit_metadata(
@@ -357,7 +365,11 @@ impl NetworkProxyState {
audit_metadata,
LocalBindingPolicy::DefaultFalse,
)
})
};
if let Some(broker) = cached_broker {
proxy_state.credential_broker = broker;
}
Ok(proxy_state)
}
pub fn with_reloader(state: ConfigState, reloader: Arc<dyn ConfigReloader>) -> Self {
@@ -570,6 +582,15 @@ impl NetworkProxyState {
self.credential_broker.virtualize_text(text, env)
}
pub(crate) fn handle_unmasked_credentials(
&self,
env: &mut HashMap<String, String>,
mode: crate::CredentialMaskingFailureMode,
) -> anyhow::Result<()> {
self.credential_broker
.handle_unmasked_credentials(env, mode)
}
pub(crate) fn credential_broker_environment(
&self,
env: &HashMap<String, String>,