Config

Struct Config 

Source
pub struct Config {
Show 15 fields pub server: ServerConfig, pub scanner: ScannerConfig, pub shield: ShieldConfig, pub auth: AuthConfig, pub signing: SigningConfig, pub rate_limit: RateLimitConfig, pub event_processor: EventProcessorConfig, pub telemetry: TelemetryConfig, pub storage: StorageConfig, pub plugins: PluginConfig, pub audit: AuditConfig, pub transport: TransportConfig, pub resilience: ResilienceConfig, pub neutralization: NeutralizationConfig, pub neutralizer: Option<NeutralizationConfig>,
}
Expand description

Main configuration structure for KindlyGuard

§Security Architecture

KindlyGuard’s configuration implements defense-in-depth with multiple security layers that work together:

  1. Authentication (auth) - Identity verification and access control
  2. Rate Limiting (rate_limit) - Abuse and DoS prevention
  3. Scanner (scanner) - Threat detection and analysis
  4. Neutralization (neutralization) - Threat remediation
  5. Audit (audit) - Security event logging and compliance

§Configuration Priority

When multiple security features could conflict:

  1. Authentication failures block everything (highest priority)
  2. Rate limits apply after authentication
  3. Scanner runs on all authenticated requests
  4. Neutralization only acts on detected threats

§Example: Minimum Secure Configuration

[auth]
enabled = true
jwt_secret = "your-base64-encoded-secret"
trusted_issuers = ["https://your-auth-server.com"]

[rate_limit]
enabled = true
default_rpm = 60

[scanner]
unicode_detection = true
injection_detection = true
path_traversal_detection = true
xss_detection = true

[neutralization]
mode = "automatic"
audit_all_actions = true

Fields§

§server: ServerConfig

Server configuration

Controls network exposure and connection handling. Lower limits = more secure but less scalable.

§scanner: ScannerConfig

Security scanning configuration

Primary defense against malicious input. More detections enabled = better security coverage.

§shield: ShieldConfig

Shield display configuration

Visual security status indicator. No direct security impact but aids monitoring.

§auth: AuthConfig

Authentication configuration

Access control and identity verification. MUST be enabled in production environments.

§signing: SigningConfig

Message signing configuration

Cryptographic integrity for requests/responses. Prevents tampering and replay attacks.

§rate_limit: RateLimitConfig

Rate limiting configuration

Prevents abuse and resource exhaustion. Essential for public-facing deployments.

§event_processor: EventProcessorConfig

Enhanced security event processing configuration

Advanced threat correlation and analysis. Provides deeper security insights when enabled.

§telemetry: TelemetryConfig

Telemetry configuration

Security monitoring and metrics. Critical for detecting attacks and anomalies.

§storage: StorageConfig

Storage configuration

Secure storage for backups and audit logs. Encryption and access control are essential.

§plugins: PluginConfig

Plugin system configuration

Extensibility with security boundaries. Only load trusted, signed plugins.

§audit: AuditConfig

Audit logging configuration

Forensic trail of all security events. Required for compliance and incident response.

§transport: TransportConfig

Transport layer configuration

Communication security settings. Use TLS for all network transports.

§resilience: ResilienceConfig

Resilience configuration for circuit breakers and retry

Prevents cascading failures under attack. Maintains availability during security incidents.

§neutralization: NeutralizationConfig

Threat neutralization configuration

Active threat remediation settings. Transforms malicious input into safe content.

§neutralizer: Option<NeutralizationConfig>

Neutralizer configuration (alias for neutralization)

Some tests expect this field name. This is an alias for backwards compatibility.

Implementations§

Source§

impl Config

Source

pub const fn is_event_processor_enabled(&self) -> bool

Check if event processor is enabled

Source

pub fn neutralizer(&self) -> &NeutralizationConfig

Get neutralizer configuration Returns the neutralizer field if set, otherwise returns neutralization

Source

pub fn load() -> Result<Config, Error>

Load configuration from environment and files

§Security Notes
  • Configuration files should have restricted permissions (600 or 640)
  • Never store secrets directly in config files - use environment variables
  • Validate all loaded configurations before use
  • Default configuration is intentionally conservative for security
Source

pub fn load_from_file(path: &str) -> Result<Config, Error>

Load configuration from a specific file

§Security Warning

Ensure the configuration file is from a trusted source and has appropriate file permissions to prevent unauthorized modifications.

Source

pub fn validate_security(&self) -> Result<(), Error>

Validate configuration for security best practices

§Example
let config = Config::load()?;
config.validate_security()?;

Trait Implementations§

Source§

impl Clone for Config

Source§

fn clone(&self) -> Config

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Config

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Default for Config

Source§

fn default() -> Config

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for Config

Source§

fn deserialize<__D>( __deserializer: __D, ) -> Result<Config, <__D as Deserializer<'de>>::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for Config

Source§

fn serialize<__S>( &self, __serializer: __S, ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

§

impl Freeze for Config

§

impl RefUnwindSafe for Config

§

impl Send for Config

§

impl Sync for Config

§

impl Unpin for Config

§

impl UnwindSafe for Config

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,