use crate::diagnostic::Severity;
use serde::Deserialize;
#[derive(Debug, Clone, Deserialize, Default)]
pub struct PolicyConfig {
#[serde(default)]
pub diagnostics: DiagnosticsConfig,
#[serde(default)]
pub cache: CacheConfig,
#[serde(default)]
pub freshness: FreshnessConfig,
#[serde(default)]
pub supply_chain: SupplyChainConfig,
#[serde(default)]
pub registries: RegistriesConfig,
#[serde(default)]
pub network: NetworkConfig,
#[serde(default)]
pub license_policy: LicensePolicyConfig,
#[serde(default)]
pub typosquat: TyposquatConfig,
#[serde(default)]
pub gossip: GossipConfig,
}
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)]
pub struct PolicyConfigDiff {
pub workspace_registries_changed: SettingChange,
pub nuget_user_profile_sources_changed: SettingChange,
pub swift_keychain_credentials_changed: SettingChange,
pub gitlab_instance_host_changed: SettingChange,
}
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)]
pub enum SettingChange {
#[default]
Unchanged,
Changed,
}
impl SettingChange {
#[must_use]
pub fn of<T: PartialEq>(old: &T, new: &T) -> Self {
if old == new {
Self::Unchanged
} else {
Self::Changed
}
}
#[must_use]
pub const fn is_changed(self) -> bool {
matches!(self, Self::Changed)
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum CheckState {
Active,
Inactive,
}
mod sealed {
pub trait Sealed {}
pub trait ToggleRepr: Sized {
fn from_repr(on: bool) -> Self;
fn to_repr(self) -> bool;
}
}
use sealed::ToggleRepr;
pub trait NetworkCheck: sealed::Sealed {
fn enabled(policy: &PolicyConfig) -> bool;
}
#[derive(Debug, Clone, Copy)]
pub enum Osv {}
#[derive(Debug, Clone, Copy)]
pub enum Typosquat {}
#[derive(Debug, Clone, Copy)]
pub enum Gossip {}
impl sealed::Sealed for Osv {}
impl sealed::Sealed for Typosquat {}
impl sealed::Sealed for Gossip {}
impl NetworkCheck for Osv {
fn enabled(policy: &PolicyConfig) -> bool {
policy.diagnostics.vulnerabilities_enabled
}
}
impl NetworkCheck for Typosquat {
fn enabled(policy: &PolicyConfig) -> bool {
policy.typosquat.enabled
}
}
impl NetworkCheck for Gossip {
fn enabled(policy: &PolicyConfig) -> bool {
policy.gossip.enabled
}
}
pub struct Checks<F: NetworkCheck>(CheckState, std::marker::PhantomData<fn() -> F>);
pub type OsvChecks = Checks<Osv>;
pub type TyposquatChecks = Checks<Typosquat>;
pub type GossipChecks = Checks<Gossip>;
impl<F: NetworkCheck> Clone for Checks<F> {
fn clone(&self) -> Self {
*self
}
}
impl<F: NetworkCheck> Copy for Checks<F> {}
impl<F: NetworkCheck> PartialEq for Checks<F> {
fn eq(&self, other: &Self) -> bool {
self.0 == other.0
}
}
impl<F: NetworkCheck> Eq for Checks<F> {}
impl<F: NetworkCheck> std::fmt::Debug for Checks<F> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_tuple("Checks").field(&self.0).finish()
}
}
impl<F: NetworkCheck> Checks<F> {
const fn from_active(active: bool) -> Self {
Self(
if active {
CheckState::Active
} else {
CheckState::Inactive
},
std::marker::PhantomData,
)
}
#[must_use]
pub const fn state(self) -> CheckState {
self.0
}
#[must_use]
pub const fn is_active(self) -> bool {
match self.0 {
CheckState::Active => true,
CheckState::Inactive => false,
}
}
#[must_use]
pub const fn activated_since(self, previous: Self) -> bool {
matches!(
(self.0, previous.0),
(CheckState::Active, CheckState::Inactive)
)
}
}
impl Checks<Osv> {
#[must_use]
pub const fn resolve(vulnerabilities_enabled: bool, network: crate::NetworkMode) -> Self {
Self::from_active(vulnerabilities_enabled && network.is_online())
}
}
impl<F: NetworkCheck> ToggleRepr for Checks<F> {
fn from_repr(on: bool) -> Self {
Self::from_active(on)
}
fn to_repr(self) -> bool {
self.is_active()
}
}
pub trait ToggleValue: ToggleRepr + Copy {}
impl<F: NetworkCheck> ToggleValue for Checks<F> {}
pub struct AtomicToggle<T: ToggleValue>(
std::sync::atomic::AtomicBool,
std::marker::PhantomData<fn() -> T>,
);
impl<T: ToggleValue> std::fmt::Debug for AtomicToggle<T> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_tuple("AtomicToggle")
.field(&self.0.load(std::sync::atomic::Ordering::Relaxed))
.finish()
}
}
impl<T: ToggleValue + Default> Default for AtomicToggle<T> {
fn default() -> Self {
Self::new(T::default())
}
}
impl<T: ToggleValue> AtomicToggle<T> {
#[must_use]
pub fn new(value: T) -> Self {
Self(
std::sync::atomic::AtomicBool::new(value.to_repr()),
std::marker::PhantomData,
)
}
#[must_use]
pub fn get(&self) -> T {
T::from_repr(self.0.load(std::sync::atomic::Ordering::Relaxed))
}
pub fn set(&self, value: T) {
self.0
.store(value.to_repr(), std::sync::atomic::Ordering::Relaxed);
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
pub enum UserProfileSources {
#[default]
Disabled,
Enabled,
}
impl UserProfileSources {
#[must_use]
pub const fn from_enabled_flag(enabled: bool) -> Self {
if enabled {
Self::Enabled
} else {
Self::Disabled
}
}
}
impl<'de> Deserialize<'de> for UserProfileSources {
fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
bool::deserialize(deserializer).map(Self::from_enabled_flag)
}
}
impl ToggleRepr for UserProfileSources {
fn from_repr(on: bool) -> Self {
Self::from_enabled_flag(on)
}
fn to_repr(self) -> bool {
match self {
Self::Disabled => false,
Self::Enabled => true,
}
}
}
impl ToggleValue for UserProfileSources {}
impl PolicyConfig {
#[must_use]
pub fn checks<F: NetworkCheck>(&self) -> Checks<F> {
Checks::from_active(F::enabled(self) && self.network.mode().is_online())
}
#[must_use]
pub fn osv_checks(&self) -> OsvChecks {
self.checks()
}
#[must_use]
pub fn typosquat_checks(&self) -> TyposquatChecks {
self.checks()
}
#[must_use]
pub fn gossip_checks(&self) -> GossipChecks {
self.checks()
}
#[must_use]
pub fn diff(old: &Self, new: &Self) -> PolicyConfigDiff {
let Self {
diagnostics: new_diagnostics,
cache: new_cache,
freshness: new_freshness,
supply_chain: new_supply_chain,
registries: new_registries,
network: new_network,
license_policy: new_license_policy,
typosquat: new_typosquat,
gossip: new_gossip,
} = new;
let DiagnosticsConfig {
outdated_severity: _,
unknown_severity: _,
yanked_severity: _,
unsatisfiable_severity: _,
deprecated_severity: _,
mutable_ref_pin_severity: _,
mutable_ref_pin_enabled: _,
sha_comment_mismatch_severity: _,
unknown_ref_severity: _,
vulnerabilities_enabled: _,
} = new_diagnostics;
let CacheConfig {
enabled: _,
fetch_timeout: _,
max_concurrent_fetches: _,
} = new_cache;
let FreshnessConfig {
enabled: _,
cooldown_secs: _,
} = new_freshness;
let SupplyChainConfig { enabled: _ } = new_supply_chain;
let NetworkConfig { offline: _ } = new_network;
let LicensePolicyConfig { allow: _, deny: _ } = new_license_policy;
let TyposquatConfig { enabled: _ } = new_typosquat;
let GossipConfig { enabled: _ } = new_gossip;
let RegistriesConfig {
workspace_registries: new_workspace_registries,
nuget_user_profile_sources: new_nuget_user_profile_sources,
swift_keychain_credentials: new_swift_keychain_credentials,
gitlab_instance_host: new_gitlab_instance_host,
} = new_registries;
let RegistriesConfig {
workspace_registries: old_workspace_registries,
nuget_user_profile_sources: old_nuget_user_profile_sources,
swift_keychain_credentials: old_swift_keychain_credentials,
gitlab_instance_host: old_gitlab_instance_host,
} = &old.registries;
PolicyConfigDiff {
workspace_registries_changed: SettingChange::of(
old_workspace_registries,
new_workspace_registries,
),
nuget_user_profile_sources_changed: SettingChange::of(
old_nuget_user_profile_sources,
new_nuget_user_profile_sources,
),
swift_keychain_credentials_changed: SettingChange::of(
old_swift_keychain_credentials,
new_swift_keychain_credentials,
),
gitlab_instance_host_changed: SettingChange::of(
old_gitlab_instance_host,
new_gitlab_instance_host,
),
}
}
}
#[non_exhaustive]
#[derive(Debug, Clone, Deserialize)]
pub struct DiagnosticsConfig {
#[serde(default = "default_outdated_severity")]
pub outdated_severity: Severity,
#[serde(default = "default_unknown_severity")]
pub unknown_severity: Severity,
#[serde(default = "default_yanked_severity")]
pub yanked_severity: Severity,
#[serde(default = "default_unsatisfiable_severity")]
pub unsatisfiable_severity: Severity,
#[serde(default = "default_deprecated_severity")]
pub deprecated_severity: Severity,
#[serde(default = "default_mutable_ref_pin_severity")]
pub mutable_ref_pin_severity: Severity,
#[serde(default = "default_true")]
pub mutable_ref_pin_enabled: bool,
#[serde(default = "default_sha_comment_mismatch_severity")]
pub sha_comment_mismatch_severity: Severity,
#[serde(default = "default_unknown_ref_severity")]
pub unknown_ref_severity: Severity,
#[serde(default = "default_true")]
pub vulnerabilities_enabled: bool,
}
impl Default for DiagnosticsConfig {
fn default() -> Self {
Self::new()
}
}
impl DiagnosticsConfig {
#[must_use]
pub const fn new() -> Self {
Self {
outdated_severity: default_outdated_severity(),
unknown_severity: default_unknown_severity(),
yanked_severity: default_yanked_severity(),
unsatisfiable_severity: default_unsatisfiable_severity(),
deprecated_severity: default_deprecated_severity(),
mutable_ref_pin_severity: default_mutable_ref_pin_severity(),
mutable_ref_pin_enabled: true,
sha_comment_mismatch_severity: default_sha_comment_mismatch_severity(),
unknown_ref_severity: default_unknown_ref_severity(),
vulnerabilities_enabled: true,
}
}
#[must_use]
pub const fn with_outdated_severity(mut self, outdated_severity: Severity) -> Self {
self.outdated_severity = outdated_severity;
self
}
#[must_use]
pub const fn with_unknown_severity(mut self, unknown_severity: Severity) -> Self {
self.unknown_severity = unknown_severity;
self
}
#[must_use]
pub const fn with_yanked_severity(mut self, yanked_severity: Severity) -> Self {
self.yanked_severity = yanked_severity;
self
}
#[must_use]
pub const fn with_unsatisfiable_severity(mut self, unsatisfiable_severity: Severity) -> Self {
self.unsatisfiable_severity = unsatisfiable_severity;
self
}
#[must_use]
pub const fn with_deprecated_severity(mut self, deprecated_severity: Severity) -> Self {
self.deprecated_severity = deprecated_severity;
self
}
#[must_use]
pub const fn with_mutable_ref_pin_severity(
mut self,
mutable_ref_pin_severity: Severity,
) -> Self {
self.mutable_ref_pin_severity = mutable_ref_pin_severity;
self
}
#[must_use]
pub const fn with_mutable_ref_pin_enabled(mut self, mutable_ref_pin_enabled: bool) -> Self {
self.mutable_ref_pin_enabled = mutable_ref_pin_enabled;
self
}
#[must_use]
pub const fn with_sha_comment_mismatch_severity(
mut self,
sha_comment_mismatch_severity: Severity,
) -> Self {
self.sha_comment_mismatch_severity = sha_comment_mismatch_severity;
self
}
#[must_use]
pub const fn with_unknown_ref_severity(mut self, unknown_ref_severity: Severity) -> Self {
self.unknown_ref_severity = unknown_ref_severity;
self
}
#[must_use]
pub const fn with_vulnerabilities_enabled(mut self, vulnerabilities_enabled: bool) -> Self {
self.vulnerabilities_enabled = vulnerabilities_enabled;
self
}
#[must_use]
pub const fn to_severities(&self) -> crate::DiagnosticSeverities {
crate::DiagnosticSeverities::new()
.with_outdated(self.outdated_severity)
.with_unknown(self.unknown_severity)
.with_yanked(self.yanked_severity)
.with_unsatisfiable(self.unsatisfiable_severity)
.with_deprecated(self.deprecated_severity)
.with_mutable_ref_pin(self.mutable_ref_pin_severity)
.with_mutable_ref_pin_enabled(self.mutable_ref_pin_enabled)
.with_sha_comment_mismatch(self.sha_comment_mismatch_severity)
.with_unknown_ref(self.unknown_ref_severity)
.with_vulnerabilities_enabled(self.vulnerabilities_enabled)
}
}
#[non_exhaustive]
#[derive(Debug, Clone, Deserialize)]
pub struct CacheConfig {
#[serde(default = "default_true")]
pub enabled: bool,
#[serde(
rename = "fetch_timeout_secs",
default = "FetchTimeout::default",
deserialize_with = "deserialize_fetch_timeout"
)]
pub fetch_timeout: FetchTimeout,
#[serde(
default = "FetchConcurrency::default",
deserialize_with = "deserialize_max_concurrent"
)]
pub max_concurrent_fetches: FetchConcurrency,
}
impl Default for CacheConfig {
fn default() -> Self {
Self::new()
}
}
impl CacheConfig {
#[must_use]
pub const fn new() -> Self {
Self {
enabled: true,
fetch_timeout: FetchTimeout::DEFAULT,
max_concurrent_fetches: FetchConcurrency::DEFAULT,
}
}
#[must_use]
pub const fn with_enabled(mut self, enabled: bool) -> Self {
self.enabled = enabled;
self
}
#[must_use]
pub const fn with_fetch_timeout(mut self, fetch_timeout: FetchTimeout) -> Self {
self.fetch_timeout = fetch_timeout;
self
}
#[must_use]
pub const fn with_max_concurrent_fetches(
mut self,
max_concurrent_fetches: FetchConcurrency,
) -> Self {
self.max_concurrent_fetches = max_concurrent_fetches;
self
}
}
const fn default_true() -> bool {
true
}
const fn default_outdated_severity() -> Severity {
Severity::Hint
}
const fn default_unknown_severity() -> Severity {
Severity::Warning
}
const fn default_yanked_severity() -> Severity {
Severity::Warning
}
const fn default_unsatisfiable_severity() -> Severity {
Severity::Warning
}
const fn default_deprecated_severity() -> Severity {
Severity::Warning
}
const fn default_mutable_ref_pin_severity() -> Severity {
Severity::Hint
}
const fn default_sha_comment_mismatch_severity() -> Severity {
Severity::Warning
}
const fn default_unknown_ref_severity() -> Severity {
Severity::Warning
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, thiserror::Error)]
pub enum FetchLimitError {
#[error("fetch timeout of {secs}s is outside {min}..={max} seconds", min = FetchTimeout::MIN.as_secs(), max = FetchTimeout::MAX.as_secs())]
TimeoutOutOfRange {
secs: u64,
},
#[error("fetch concurrency of {count} is outside {min}..={max}", min = FetchConcurrency::MIN.get(), max = FetchConcurrency::MAX.get())]
ConcurrencyOutOfRange {
count: usize,
},
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct FetchTimeout(std::num::NonZeroU64);
impl FetchTimeout {
pub const MIN: Self = Self(std::num::NonZeroU64::MIN);
pub const MAX: Self = Self::constant::<300>();
pub const DEFAULT: Self = Self::constant::<5>();
#[must_use]
pub const fn constant<const SECS: u64>() -> Self {
const {
let in_range = matches!(SECS, 1..=300);
assert!(in_range, "fetch timeout must be 1..=300 seconds");
};
Self::fixed(SECS)
}
const fn fixed(secs: u64) -> Self {
match std::num::NonZeroU64::new(secs) {
Some(secs) => Self(secs),
None => Self::MIN,
}
}
pub fn try_from_secs(secs: u64) -> Result<Self, FetchLimitError> {
match std::num::NonZeroU64::new(secs) {
Some(nonzero) if secs <= Self::MAX.as_secs() => Ok(Self(nonzero)),
Some(_) | None => Err(FetchLimitError::TimeoutOutOfRange { secs }),
}
}
#[must_use]
pub const fn as_secs(self) -> u64 {
self.0.get()
}
#[must_use]
pub const fn as_duration(self) -> std::time::Duration {
std::time::Duration::from_secs(self.0.get())
}
fn clamped(secs: u64) -> Self {
Self::fixed(secs.clamp(Self::MIN.as_secs(), Self::MAX.as_secs()))
}
}
impl Default for FetchTimeout {
fn default() -> Self {
Self::DEFAULT
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct FetchConcurrency(std::num::NonZeroUsize);
impl FetchConcurrency {
pub const MIN: Self = Self(std::num::NonZeroUsize::MIN);
pub const MAX: Self = Self::constant::<100>();
pub const DEFAULT: Self = Self::constant::<20>();
#[must_use]
pub const fn constant<const COUNT: usize>() -> Self {
const {
let in_range = matches!(COUNT, 1..=100);
assert!(in_range, "fetch concurrency must be 1..=100");
};
Self::fixed(COUNT)
}
const fn fixed(count: usize) -> Self {
match std::num::NonZeroUsize::new(count) {
Some(count) => Self(count),
None => Self::MIN,
}
}
pub fn try_new(count: usize) -> Result<Self, FetchLimitError> {
match std::num::NonZeroUsize::new(count) {
Some(nonzero) if count <= Self::MAX.get() => Ok(Self(nonzero)),
Some(_) | None => Err(FetchLimitError::ConcurrencyOutOfRange { count }),
}
}
#[must_use]
pub const fn get(self) -> usize {
self.0.get()
}
fn clamped(count: usize) -> Self {
Self::fixed(count.clamp(Self::MIN.get(), Self::MAX.get()))
}
}
impl Default for FetchConcurrency {
fn default() -> Self {
Self::DEFAULT
}
}
fn deserialize_fetch_timeout<'de, D>(deserializer: D) -> Result<FetchTimeout, D::Error>
where
D: serde::Deserializer<'de>,
{
let secs = u64::deserialize(deserializer)?;
let timeout = FetchTimeout::clamped(secs);
if timeout.as_secs() != secs {
tracing::warn!(
"fetch_timeout_secs {} clamped to {} (valid range: {}-{})",
secs,
timeout.as_secs(),
FetchTimeout::MIN.as_secs(),
FetchTimeout::MAX.as_secs()
);
}
Ok(timeout)
}
fn deserialize_max_concurrent<'de, D>(deserializer: D) -> Result<FetchConcurrency, D::Error>
where
D: serde::Deserializer<'de>,
{
let count = usize::deserialize(deserializer)?;
let concurrency = FetchConcurrency::clamped(count);
if concurrency.get() != count {
tracing::warn!(
"max_concurrent_fetches {} clamped to {} (valid range: {}-{})",
count,
concurrency.get(),
FetchConcurrency::MIN.get(),
FetchConcurrency::MAX.get()
);
}
Ok(concurrency)
}
#[non_exhaustive]
#[derive(Debug, Clone, Deserialize)]
pub struct FreshnessConfig {
#[serde(default = "default_true")]
pub enabled: bool,
#[serde(
default = "default_cooldown_secs",
deserialize_with = "deserialize_cooldown_secs"
)]
pub cooldown_secs: u64,
}
impl Default for FreshnessConfig {
fn default() -> Self {
Self::new()
}
}
impl FreshnessConfig {
#[must_use]
pub const fn new() -> Self {
Self {
enabled: true,
cooldown_secs: default_cooldown_secs(),
}
}
#[must_use]
pub const fn with_enabled(mut self, enabled: bool) -> Self {
self.enabled = enabled;
self
}
#[must_use]
pub const fn with_cooldown_secs(mut self, cooldown_secs: u64) -> Self {
self.cooldown_secs = cooldown_secs;
self
}
#[must_use]
pub const fn to_freshness(&self) -> crate::FreshnessSettings {
if self.enabled {
crate::FreshnessSettings::Enabled {
cooldown: crate::CooldownWindow::from_secs(self.cooldown_secs),
}
} else {
crate::FreshnessSettings::Disabled
}
}
}
const fn default_cooldown_secs() -> u64 {
crate::DEFAULT_COOLDOWN_SECS
}
#[non_exhaustive]
#[derive(Debug, Clone, Deserialize)]
pub struct SupplyChainConfig {
#[serde(default = "default_true")]
pub enabled: bool,
}
impl Default for SupplyChainConfig {
fn default() -> Self {
Self::new()
}
}
impl SupplyChainConfig {
#[must_use]
pub const fn new() -> Self {
Self { enabled: true }
}
#[must_use]
pub const fn with_enabled(mut self, enabled: bool) -> Self {
self.enabled = enabled;
self
}
}
const MIN_COOLDOWN_SECS: u64 = 0;
const MAX_COOLDOWN_SECS: u64 = 30 * 24 * 60 * 60;
fn deserialize_cooldown_secs<'de, D>(deserializer: D) -> Result<u64, D::Error>
where
D: serde::Deserializer<'de>,
{
let secs = u64::deserialize(deserializer)?;
let clamped = secs.clamp(MIN_COOLDOWN_SECS, MAX_COOLDOWN_SECS);
if clamped != secs {
tracing::warn!(
"freshness.cooldown_secs {} clamped to {} (valid range: {}-{})",
secs,
clamped,
MIN_COOLDOWN_SECS,
MAX_COOLDOWN_SECS
);
}
Ok(clamped)
}
#[derive(Debug, Clone, Copy, Deserialize, Default, PartialEq, Eq)]
#[serde(rename_all = "snake_case")]
pub enum KeychainCredentials {
#[default]
Disabled,
Enabled,
}
#[non_exhaustive]
#[derive(Clone, Deserialize, crate::redact_debug::RedactingDebug)]
pub struct RegistriesConfig {
#[serde(default)]
#[raw]
pub workspace_registries: WorkspaceRegistriesSetting,
#[serde(default)]
#[raw]
pub nuget_user_profile_sources: UserProfileSources,
#[serde(default)]
#[raw]
pub swift_keychain_credentials: KeychainCredentials,
#[serde(default)]
#[redact(url)]
pub gitlab_instance_host: String,
}
impl Default for RegistriesConfig {
fn default() -> Self {
Self::new()
}
}
impl RegistriesConfig {
#[must_use]
pub fn new() -> Self {
Self {
workspace_registries: WorkspaceRegistriesSetting::PublicOnly,
nuget_user_profile_sources: UserProfileSources::Disabled,
swift_keychain_credentials: KeychainCredentials::Disabled,
gitlab_instance_host: String::new(),
}
}
#[must_use]
pub const fn with_workspace_registries(
mut self,
workspace_registries: WorkspaceRegistriesSetting,
) -> Self {
self.workspace_registries = workspace_registries;
self
}
#[must_use]
pub const fn with_nuget_user_profile_sources(
mut self,
nuget_user_profile_sources: UserProfileSources,
) -> Self {
self.nuget_user_profile_sources = nuget_user_profile_sources;
self
}
#[must_use]
pub const fn with_swift_keychain_credentials(
mut self,
swift_keychain_credentials: KeychainCredentials,
) -> Self {
self.swift_keychain_credentials = swift_keychain_credentials;
self
}
#[must_use]
pub fn with_gitlab_instance_host(mut self, gitlab_instance_host: impl Into<String>) -> Self {
self.gitlab_instance_host = gitlab_instance_host.into();
self
}
}
#[derive(Clone, PartialEq, Eq)]
pub struct RegistryRuntimeSettings {
pub workspace_registries: crate::net_policy::WorkspaceRegistryAccess,
pub workspace_registries_effect: WorkspaceRegistriesEffect,
pub nuget_user_profile_sources: UserProfileSources,
pub swift_keychain_credentials: KeychainCredentials,
pub gitlab_instance_host: Option<String>,
}
impl std::fmt::Debug for RegistryRuntimeSettings {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("RegistryRuntimeSettings")
.field("workspace_registries", &self.workspace_registries)
.field(
"workspace_registries_effect",
&self.workspace_registries_effect,
)
.field(
"nuget_user_profile_sources",
&self.nuget_user_profile_sources,
)
.field(
"swift_keychain_credentials",
&self.swift_keychain_credentials,
)
.field(
"gitlab_instance_host",
&self
.gitlab_instance_host
.as_deref()
.map(crate::redact::RedactedUrl::new),
)
.finish()
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
pub enum WorkspaceRegistriesEffect {
#[default]
AsConfigured,
AllWithoutAllowlist,
AllWithInvalidAllowlist,
}
impl WorkspaceRegistriesEffect {
#[must_use]
pub const fn user_message(self) -> Option<&'static str> {
match self {
Self::AsConfigured => None,
Self::AllWithoutAllowlist => Some(
"registries.workspace_registries = \"all\" has no effect on private hosts: \
DEPS_LSP_PRIVATE_REGISTRY_HOSTS is not set, so it behaves like \"public_only\". \
The setting is repository-controllable; the environment variable is the \
effective control. Once exported, any repository you open can send \
unauthenticated GET requests to the listed hosts on any port, so list \
registry hosts or narrow CIDRs only.",
),
Self::AllWithInvalidAllowlist => Some(concat!(
"registries.workspace_registries = \"all\" has no effect on private hosts: ",
"DEPS_LSP_PRIVATE_REGISTRY_HOSTS is set but invalid (entries must be bare ",
"CIDR ranges, IPs or lowercase host names without ports, paths or ",
"wildcards, and prefixes of at least /",
crate::net_policy::min_v4_prefix!(),
" for IPv4 or /",
crate::net_policy::min_v6_prefix!(),
" for IPv6), so it behaves like \"public_only\"."
)),
}
}
#[must_use]
pub fn of(
setting: WorkspaceRegistriesSetting,
allowlist: &crate::net_policy::AllowlistOutcome,
) -> Self {
use crate::net_policy::AllowlistOutcome;
use WorkspaceRegistriesSetting::{All, Off, PublicOnly};
match (setting, allowlist) {
(Off | PublicOnly, _) | (All, AllowlistOutcome::Parsed(_)) => Self::AsConfigured,
(All, AllowlistOutcome::Unset) => Self::AllWithoutAllowlist,
(All, AllowlistOutcome::Invalid(_)) => Self::AllWithInvalidAllowlist,
}
}
}
impl RegistriesConfig {
#[must_use]
pub fn resolve(
&self,
allowlist: &crate::net_policy::AllowlistOutcome,
) -> RegistryRuntimeSettings {
RegistryRuntimeSettings {
workspace_registries: self.workspace_registries.to_policy(),
workspace_registries_effect: WorkspaceRegistriesEffect::of(
self.workspace_registries,
allowlist,
),
nuget_user_profile_sources: self.nuget_user_profile_sources,
swift_keychain_credentials: self.swift_keychain_credentials,
gitlab_instance_host: (!self.gitlab_instance_host.is_empty())
.then(|| self.gitlab_instance_host.clone()),
}
}
}
#[non_exhaustive]
#[derive(Debug, Clone, Copy, Deserialize, Default, PartialEq, Eq)]
#[serde(rename_all = "snake_case")]
pub enum WorkspaceRegistriesSetting {
Off,
#[default]
PublicOnly,
All,
}
impl WorkspaceRegistriesSetting {
#[must_use]
pub const fn to_policy(self) -> crate::net_policy::WorkspaceRegistryAccess {
match self {
Self::Off => crate::net_policy::WorkspaceRegistryAccess::Off,
Self::PublicOnly => crate::net_policy::WorkspaceRegistryAccess::PublicOnly,
Self::All => crate::net_policy::WorkspaceRegistryAccess::All,
}
}
}
#[non_exhaustive]
#[derive(Debug, Clone, Deserialize)]
pub struct NetworkConfig {
#[serde(default)]
pub offline: bool,
}
impl Default for NetworkConfig {
fn default() -> Self {
Self::new()
}
}
impl NetworkConfig {
#[must_use]
pub const fn new() -> Self {
Self { offline: false }
}
#[must_use]
pub const fn with_offline(mut self, offline: bool) -> Self {
self.offline = offline;
self
}
#[must_use]
pub fn mode(&self) -> crate::NetworkMode {
crate::NetworkMode::from_offline_flag(self.offline)
}
}
#[non_exhaustive]
#[derive(Debug, Clone, Deserialize, Default)]
pub struct LicensePolicyConfig {
#[serde(default, deserialize_with = "deserialize_spdx_list")]
pub allow: Vec<String>,
#[serde(default, deserialize_with = "deserialize_spdx_list")]
pub deny: Vec<String>,
}
impl LicensePolicyConfig {
#[must_use]
pub const fn new() -> Self {
Self {
allow: Vec::new(),
deny: Vec::new(),
}
}
#[must_use]
pub fn with_allow(mut self, allow: Vec<String>) -> Self {
self.allow = allow;
self
}
#[must_use]
pub fn with_deny(mut self, deny: Vec<String>) -> Self {
self.deny = deny;
self
}
#[must_use]
pub fn to_policy(&self) -> crate::LicensePolicy {
crate::LicensePolicy::new(self.allow.clone(), self.deny.clone())
}
}
#[non_exhaustive]
#[derive(Debug, Clone, Deserialize, Default)]
pub struct TyposquatConfig {
#[serde(default)]
pub enabled: bool,
}
impl TyposquatConfig {
#[must_use]
pub const fn new() -> Self {
Self { enabled: false }
}
#[must_use]
pub const fn with_enabled(mut self, enabled: bool) -> Self {
self.enabled = enabled;
self
}
}
#[non_exhaustive]
#[derive(Debug, Clone, Deserialize, Default)]
pub struct GossipConfig {
#[serde(default)]
pub enabled: bool,
}
impl GossipConfig {
#[must_use]
pub const fn new() -> Self {
Self { enabled: false }
}
#[must_use]
pub const fn with_enabled(mut self, enabled: bool) -> Self {
self.enabled = enabled;
self
}
}
fn deserialize_spdx_list<'de, D>(deserializer: D) -> Result<Vec<String>, D::Error>
where
D: serde::Deserializer<'de>,
{
let raw = Vec::<String>::deserialize(deserializer)?;
Ok(crate::licenses::filter_valid_spdx_ids(raw))
}
#[cfg(test)]
mod tests {
use super::*;
use crate::net_policy::AllowlistOutcome;
#[test]
fn test_checks_gate_requires_feature_enabled_and_online() {
let mut policy = PolicyConfig::default();
assert!(policy.osv_checks().is_active());
assert!(!policy.typosquat_checks().is_active());
assert!(!policy.gossip_checks().is_active());
policy.typosquat.enabled = true;
policy.gossip.enabled = true;
assert!(policy.typosquat_checks().is_active());
assert!(policy.gossip_checks().is_active());
policy.network.offline = true;
assert!(!policy.osv_checks().is_active());
assert!(!policy.typosquat_checks().is_active());
assert!(!policy.gossip_checks().is_active());
}
#[test]
fn test_checks_activated_since_detects_offline_to_online_edge() {
let mut policy = PolicyConfig::default();
policy.typosquat.enabled = true;
policy.network.offline = true;
let offline = policy.typosquat_checks();
policy.network.offline = false;
let online = policy.typosquat_checks();
assert!(online.activated_since(offline));
assert!(!offline.activated_since(online));
assert!(!online.activated_since(online));
assert_eq!(online.state(), CheckState::Active);
}
#[test]
fn test_atomic_toggle_round_trips_typed_values() {
let toggle = AtomicToggle::new(UserProfileSources::Disabled);
assert_eq!(toggle.get(), UserProfileSources::Disabled);
toggle.set(UserProfileSources::Enabled);
assert_eq!(toggle.get(), UserProfileSources::Enabled);
let gate = AtomicToggle::new(PolicyConfig::default().gossip_checks());
assert!(!gate.get().is_active());
let mut policy = PolicyConfig::default();
policy.gossip.enabled = true;
gate.set(policy.gossip_checks());
assert!(gate.get().is_active());
}
#[test]
fn test_user_profile_sources_deserializes_from_bool() {
let registries: RegistriesConfig =
serde_json::from_str(r#"{"nuget_user_profile_sources": true}"#).unwrap();
assert_eq!(
registries.nuget_user_profile_sources,
UserProfileSources::Enabled
);
let registries: RegistriesConfig = serde_json::from_str("{}").unwrap();
assert_eq!(
registries.nuget_user_profile_sources,
UserProfileSources::Disabled
);
assert!(serde_json::from_str::<UserProfileSources>(r#""enabled""#).is_err());
}
#[test]
fn test_policy_config_defaults() {
let policy = PolicyConfig::default();
assert!(policy.diagnostics.vulnerabilities_enabled);
assert!(!policy.network.offline);
assert_eq!(
policy.registries.workspace_registries,
WorkspaceRegistriesSetting::PublicOnly
);
}
#[test]
fn test_workspace_registries_setting_deserializes_all_variants() {
assert_eq!(
serde_json::from_str::<WorkspaceRegistriesSetting>("\"off\"").unwrap(),
WorkspaceRegistriesSetting::Off
);
assert_eq!(
serde_json::from_str::<WorkspaceRegistriesSetting>("\"public_only\"").unwrap(),
WorkspaceRegistriesSetting::PublicOnly
);
assert_eq!(
serde_json::from_str::<WorkspaceRegistriesSetting>("\"all\"").unwrap(),
WorkspaceRegistriesSetting::All
);
}
#[test]
fn test_registries_config_debug_redacts_gitlab_instance_host_credential() {
let config = RegistriesConfig {
gitlab_instance_host: "user:hunter2@gitlab.corp".to_string(),
..RegistriesConfig::default()
};
let section_debug = format!("{config:?}");
assert!(!section_debug.contains("hunter2"), "{section_debug}");
assert!(section_debug.contains("gitlab.corp"), "{section_debug}");
}
#[test]
fn test_workspace_registries_setting_to_policy() {
use crate::net_policy::WorkspaceRegistryAccess;
assert_eq!(
WorkspaceRegistriesSetting::Off.to_policy(),
WorkspaceRegistryAccess::Off
);
assert_eq!(
WorkspaceRegistriesSetting::PublicOnly.to_policy(),
WorkspaceRegistryAccess::PublicOnly
);
assert_eq!(
WorkspaceRegistriesSetting::All.to_policy(),
WorkspaceRegistryAccess::All
);
}
#[test]
fn test_workspace_registry_access_default_matches_workspace_registries_setting_default() {
assert_eq!(
crate::net_policy::WorkspaceRegistryAccess::default(),
WorkspaceRegistriesSetting::default().to_policy()
);
}
#[test]
fn test_registries_config_resolve_normalizes_empty_gitlab_instance_host_to_none() {
let resolved = RegistriesConfig::default().resolve(&AllowlistOutcome::Unset);
assert_eq!(resolved.gitlab_instance_host, None);
assert_eq!(
resolved.nuget_user_profile_sources,
UserProfileSources::Disabled
);
}
#[test]
fn test_workspace_registries_effect_matrix() {
use WorkspaceRegistriesSetting::{All, Off, PublicOnly};
let unset = AllowlistOutcome::Unset;
let parsed = AllowlistOutcome::for_test(&["10.0.0.0/8"]);
let invalid = AllowlistOutcome::invalid_for_test();
for setting in [Off, PublicOnly] {
for outcome in [&unset, &parsed, &invalid] {
assert_eq!(
WorkspaceRegistriesEffect::of(setting, outcome),
WorkspaceRegistriesEffect::AsConfigured
);
}
}
assert_eq!(
WorkspaceRegistriesEffect::of(All, &unset),
WorkspaceRegistriesEffect::AllWithoutAllowlist
);
assert_eq!(
WorkspaceRegistriesEffect::of(All, &parsed),
WorkspaceRegistriesEffect::AsConfigured
);
assert_eq!(
WorkspaceRegistriesEffect::of(All, &invalid),
WorkspaceRegistriesEffect::AllWithInvalidAllowlist
);
}
#[test]
fn test_registries_config_resolve_carries_non_default_settings() {
use crate::net_policy::WorkspaceRegistryAccess;
let config = RegistriesConfig {
workspace_registries: WorkspaceRegistriesSetting::All,
nuget_user_profile_sources: UserProfileSources::Enabled,
swift_keychain_credentials: KeychainCredentials::Enabled,
gitlab_instance_host: "gitlab.corp".to_string(),
};
let resolved = config.resolve(&AllowlistOutcome::for_test(&["10.0.0.0/8"]));
assert_eq!(resolved.workspace_registries, WorkspaceRegistryAccess::All);
assert_eq!(
resolved.workspace_registries_effect,
WorkspaceRegistriesEffect::AsConfigured
);
assert_eq!(
resolved.nuget_user_profile_sources,
UserProfileSources::Enabled
);
assert_eq!(
resolved.swift_keychain_credentials,
KeychainCredentials::Enabled
);
assert_eq!(
resolved.gitlab_instance_host.as_deref(),
Some("gitlab.corp")
);
}
#[test]
fn test_diagnostics_config_sha_comment_mismatch_severity_default_and_override() {
let default: DiagnosticsConfig = serde_json::from_str("{}").unwrap();
assert_eq!(default.sha_comment_mismatch_severity, Severity::Warning);
assert_eq!(
default.to_severities().sha_comment_mismatch,
Severity::Warning
);
let config: DiagnosticsConfig =
serde_json::from_str(r#"{ "sha_comment_mismatch_severity": 1 }"#).unwrap();
assert_eq!(config.sha_comment_mismatch_severity, Severity::Error);
assert_eq!(config.to_severities().sha_comment_mismatch, Severity::Error);
}
#[test]
fn test_diagnostics_config_unknown_ref_severity_default_and_override() {
let default: DiagnosticsConfig = serde_json::from_str("{}").unwrap();
assert_eq!(default.unknown_ref_severity, Severity::Warning);
assert_eq!(default.to_severities().unknown_ref, Severity::Warning);
let config: DiagnosticsConfig =
serde_json::from_str(r#"{ "unknown_ref_severity": 4 }"#).unwrap();
assert_eq!(config.unknown_ref_severity, Severity::Hint);
assert_eq!(config.to_severities().unknown_ref, Severity::Hint);
}
#[test]
fn test_diagnostics_config_deserialization() {
let json = r#"{
"outdated_severity": 1,
"unknown_severity": 2,
"yanked_severity": 2,
"unsatisfiable_severity": 1,
"deprecated_severity": 1
}"#;
let config: DiagnosticsConfig = serde_json::from_str(json).unwrap();
assert_eq!(config.outdated_severity, Severity::Error);
assert_eq!(config.unknown_severity, Severity::Warning);
assert_eq!(config.yanked_severity, Severity::Warning);
assert_eq!(config.unsatisfiable_severity, Severity::Error);
assert_eq!(config.deprecated_severity, Severity::Error);
}
#[test]
fn test_diagnostics_config_mutable_ref_pin_enabled_can_be_disabled() {
let json = r#"{ "mutable_ref_pin_enabled": false }"#;
let config: DiagnosticsConfig = serde_json::from_str(json).unwrap();
assert!(!config.mutable_ref_pin_enabled);
}
#[test]
fn test_diagnostics_config_vulnerabilities_enabled_can_be_disabled() {
let json = r#"{ "vulnerabilities_enabled": false }"#;
let config: DiagnosticsConfig = serde_json::from_str(json).unwrap();
assert!(!config.vulnerabilities_enabled);
}
#[test]
fn test_cache_config_deserialization() {
let json = r#"{
"enabled": false
}"#;
let config: CacheConfig = serde_json::from_str(json).unwrap();
assert!(!config.enabled);
}
#[test]
fn test_cache_config_with_enabled() {
let config = CacheConfig::new().with_enabled(false);
assert!(!config.enabled);
}
#[test]
fn test_cache_config_defaults() {
let config = CacheConfig::default();
assert!(config.enabled);
assert_eq!(config.fetch_timeout, FetchTimeout::DEFAULT);
assert_eq!(config.fetch_timeout.as_secs(), 5);
assert_eq!(config.max_concurrent_fetches, FetchConcurrency::DEFAULT);
assert_eq!(config.max_concurrent_fetches.get(), 20);
}
#[test]
fn test_cache_config_fetch_timeout_clamped() {
for (raw, expected) in [(0, 1), (1, 1), (300, 300), (301, 300), (10_000, 300)] {
let json = format!(r#"{{ "fetch_timeout_secs": {raw} }}"#);
let config: CacheConfig = serde_json::from_str(&json).unwrap();
assert_eq!(config.fetch_timeout.as_secs(), expected, "{raw}");
}
}
#[test]
fn test_cache_config_max_concurrent_fetches_clamped() {
for (raw, expected) in [(0, 1), (1, 1), (100, 100), (101, 100), (100_000, 100)] {
let json = format!(r#"{{ "max_concurrent_fetches": {raw} }}"#);
let config: CacheConfig = serde_json::from_str(&json).unwrap();
assert_eq!(config.max_concurrent_fetches.get(), expected, "{raw}");
}
}
#[test]
fn test_fetch_timeout_try_from_secs_boundaries() {
assert_eq!(
FetchTimeout::try_from_secs(0),
Err(FetchLimitError::TimeoutOutOfRange { secs: 0 })
);
assert_eq!(FetchTimeout::try_from_secs(1), Ok(FetchTimeout::MIN));
assert_eq!(FetchTimeout::try_from_secs(300), Ok(FetchTimeout::MAX));
assert_eq!(
FetchTimeout::try_from_secs(301),
Err(FetchLimitError::TimeoutOutOfRange { secs: 301 })
);
assert_eq!(
FetchTimeout::try_from_secs(u64::MAX),
Err(FetchLimitError::TimeoutOutOfRange { secs: u64::MAX })
);
}
#[test]
fn test_fetch_concurrency_try_new_boundaries() {
assert_eq!(
FetchConcurrency::try_new(0),
Err(FetchLimitError::ConcurrencyOutOfRange { count: 0 })
);
assert_eq!(FetchConcurrency::try_new(1), Ok(FetchConcurrency::MIN));
assert_eq!(FetchConcurrency::try_new(100), Ok(FetchConcurrency::MAX));
assert_eq!(
FetchConcurrency::try_new(101),
Err(FetchLimitError::ConcurrencyOutOfRange { count: 101 })
);
assert_eq!(
FetchConcurrency::try_new(usize::MAX),
Err(FetchLimitError::ConcurrencyOutOfRange { count: usize::MAX })
);
}
#[test]
fn test_fetch_limit_defaults_are_inside_their_ranges() {
assert_eq!(
FetchTimeout::try_from_secs(FetchTimeout::DEFAULT.as_secs()),
Ok(FetchTimeout::DEFAULT)
);
assert_eq!(
FetchConcurrency::try_new(FetchConcurrency::DEFAULT.get()),
Ok(FetchConcurrency::DEFAULT)
);
}
#[test]
fn test_freshness_config_defaults() {
let config = FreshnessConfig::default();
assert!(config.enabled);
assert_eq!(config.cooldown_secs, crate::DEFAULT_COOLDOWN_SECS);
}
#[test]
fn test_freshness_config_cooldown_clamped() {
let json = r#"{ "cooldown_secs": 99999999 }"#;
let config: FreshnessConfig = serde_json::from_str(json).unwrap();
assert_eq!(config.cooldown_secs, MAX_COOLDOWN_SECS);
}
#[test]
fn test_supply_chain_config_defaults() {
assert!(SupplyChainConfig::default().enabled);
}
#[test]
fn test_supply_chain_config_with_enabled() {
assert!(!SupplyChainConfig::new().with_enabled(false).enabled);
}
#[test]
fn test_network_config_defaults() {
assert!(!NetworkConfig::default().offline);
}
#[test]
fn test_network_config_with_offline() {
assert!(NetworkConfig::new().with_offline(true).offline);
}
#[test]
fn test_gossip_config_defaults() {
assert!(!GossipConfig::default().enabled);
}
#[test]
fn test_gossip_config_with_enabled() {
assert!(GossipConfig::new().with_enabled(true).enabled);
}
#[test]
fn test_gossip_config_partial_object_parses() {
let config: PolicyConfig = serde_json::from_str(r#"{"gossip": {}}"#).unwrap();
assert!(!config.gossip.enabled);
}
#[test]
fn test_policy_config_diff_no_change_returns_all_false() {
let old = PolicyConfig::default();
let new = PolicyConfig::default();
assert_eq!(PolicyConfig::diff(&old, &new), PolicyConfigDiff::default());
}
#[test]
fn test_policy_config_diff_workspace_registries_change() {
let old = PolicyConfig::default();
let mut new = PolicyConfig::default();
new.registries.workspace_registries = WorkspaceRegistriesSetting::Off;
let diff = PolicyConfig::diff(&old, &new);
assert!(diff.workspace_registries_changed.is_changed());
assert!(!diff.nuget_user_profile_sources_changed.is_changed());
assert!(!diff.gitlab_instance_host_changed.is_changed());
}
#[test]
fn test_policy_config_diff_nuget_user_profile_sources_change() {
let old = PolicyConfig::default();
let mut new = PolicyConfig::default();
new.registries.nuget_user_profile_sources = UserProfileSources::Enabled;
let diff = PolicyConfig::diff(&old, &new);
assert!(!diff.workspace_registries_changed.is_changed());
assert!(diff.nuget_user_profile_sources_changed.is_changed());
assert!(!diff.gitlab_instance_host_changed.is_changed());
}
#[test]
fn test_policy_config_diff_swift_keychain_credentials_change() {
let old = PolicyConfig::default();
let mut new = PolicyConfig::default();
new.registries.swift_keychain_credentials = KeychainCredentials::Enabled;
let diff = PolicyConfig::diff(&old, &new);
assert!(diff.swift_keychain_credentials_changed.is_changed());
assert!(!diff.nuget_user_profile_sources_changed.is_changed());
assert!(!diff.workspace_registries_changed.is_changed());
assert!(!diff.gitlab_instance_host_changed.is_changed());
assert!(
!PolicyConfig::diff(&new, &new)
.swift_keychain_credentials_changed
.is_changed()
);
}
#[test]
fn test_registries_config_parses_keychain_setting_and_rejects_unknown_value() {
let config: RegistriesConfig =
serde_json::from_str(r#"{"swift_keychain_credentials": "enabled"}"#).unwrap();
assert_eq!(
config.swift_keychain_credentials,
KeychainCredentials::Enabled
);
assert_eq!(
RegistriesConfig::default().swift_keychain_credentials,
KeychainCredentials::Disabled
);
assert!(
serde_json::from_str::<RegistriesConfig>(r#"{"swift_keychain_credentials": "yes"}"#)
.is_err()
);
}
#[test]
fn test_policy_config_diff_gitlab_instance_host_change() {
let old = PolicyConfig::default();
let mut new = PolicyConfig::default();
new.registries.gitlab_instance_host = "gitlab.corp".to_string();
let diff = PolicyConfig::diff(&old, &new);
assert!(!diff.workspace_registries_changed.is_changed());
assert!(!diff.nuget_user_profile_sources_changed.is_changed());
assert!(diff.gitlab_instance_host_changed.is_changed());
}
#[test]
fn test_policy_config_diff_non_registries_change_returns_all_false() {
let old = PolicyConfig::default();
let mut new = PolicyConfig::default();
new.network.offline = true;
new.freshness.cooldown_secs = 60;
assert_eq!(PolicyConfig::diff(&old, &new), PolicyConfigDiff::default());
}
#[test]
fn test_license_policy_config_invalid_spdx_dropped() {
let json = r#"{ "allow": ["MIT", "not a valid spdx id!!"] }"#;
let config: LicensePolicyConfig = serde_json::from_str(json).unwrap();
assert_eq!(config.allow, vec!["MIT".to_string()]);
}
crate::debug_redaction_conformance!(
test_registry_runtime_settings_debug_redacts_credentials,
1,
RegistryRuntimeSettings {
workspace_registries: crate::net_policy::WorkspaceRegistryAccess::PublicOnly,
workspace_registries_effect: WorkspaceRegistriesEffect::AsConfigured,
nuget_user_profile_sources: UserProfileSources::Disabled,
swift_keychain_credentials: KeychainCredentials::Disabled,
gitlab_instance_host: Some(crate::conformance::CREDENTIAL_PROBE_URL.to_string()),
},
);
}