SSF Tools - Configuration Service Architecture¶
Overview¶
The Configuration Service provides a unified, protocol-based approach to configuration management across all SSF Tools commands. This architecture enables consistent configuration handling while maintaining loose coupling through dependency injection patterns and supporting multiple configuration sources with proper precedence handling.
Architectural Principles¶
1. Protocol-Based Design¶
All configuration services implement well-defined protocols, enabling: - Dependency injection: Services receive configuration interfaces, not concrete implementations - Testability: Easy mocking and stubbing for unit tests - Flexibility: Swappable implementations (file-based, remote, in-memory) - Type safety: MyPy-compliant interfaces with generic type parameters
2. Registry Pattern¶
The configuration manager uses a registry pattern to avoid circular dependencies:
- Core never imports commands: Commands register themselves with the core
- Runtime registration: Services register when modules load
- Unified interface: Single config CLI for all commands
- Extensibility: New commands integrate seamlessly
3. Multi-Source Configuration¶
Configuration values are merged from multiple sources with clear precedence:
- CLI arguments (highest priority)
- Project configuration (./ssf-tools-config.yaml)
- User configuration (platform-specific user directory)
- Default values (Pydantic model defaults, lowest priority)
Architecture Overview¶
Configuration Precedence¶
Configuration values follow a clear hierarchy, with higher priority sources overriding lower ones:
Platform-Specific User Configuration¶
The configuration system uses platformdirs for cross-platform user configuration directories:
- Windows:
%APPDATA%\kirkpatrickprice\ssf-tools\ssf-tools-config.yaml - macOS:
~/Library/Application Support/ssf-tools/ssf-tools-config.yaml - Linux:
~/.config/ssf-tools/ssf-tools-config.yaml
Configuration Service Protocols¶
The configuration architecture is built around two main protocols that define the contracts for configuration management.
ConfigurationServiceProtocol¶
This protocol defines the interface for managing configuration of a specific command type:
kp_ssf_tools.core.services.config.interfaces.ConfigurationServiceProtocol
¶
Bases: Protocol[ConfigT]
Protocol for configuration management - dependency injection compatible.
Source code in src\kp_ssf_tools\core\services\config\interfaces.py
ConfigurationManagerProtocol¶
This protocol defines the interface for the registry that manages multiple configuration services:
kp_ssf_tools.core.services.config.interfaces.ConfigurationManagerProtocol
¶
Bases: Protocol
Protocol for managing multiple configuration types.
Source code in src\kp_ssf_tools\core\services\config\interfaces.py
Functions¶
extract_cli_overrides(param_mapping)
¶
Extract CLI parameter overrides using a mapping table.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
param_mapping
|
dict[str, tuple[str, str]]
|
Dict mapping CLI param names to (config_section, config_key) tuples |
required |
Returns:
| Type | Description |
|---|---|
ConfigDict
|
ConfigDict suitable for passing to get_effective_config as cli_overrides |
Source code in src\kp_ssf_tools\core\services\config\interfaces.py
get_effective_config(command, user_config_path=None, project_config_path=None, cli_overrides=None)
¶
Get effective configuration merged from all sources as dict.
Source code in src\kp_ssf_tools\core\services\config\interfaces.py
get_service(command)
¶
is_command_supported(command)
¶
list_available_commands()
¶
register_command(command, service)
¶
Register a configuration service for a command.
validate_command_config(command, config_data)
¶
Validate configuration for a specific command without importing models.
Configuration Models¶
The system uses Pydantic models for type-safe configuration with validation and serialization:
Base Configuration Model¶
kp_ssf_tools.core.services.config.models.BaseConfiguration
¶
Bases: SSFToolsBaseModel
Base configuration model with common fields.
Source code in src\kp_ssf_tools\core\services\config\models.py
Global Configuration Model¶
kp_ssf_tools.core.services.config.models.GlobalConfiguration
¶
Bases: BaseConfiguration
Global SSF Tools configuration.
Source code in src\kp_ssf_tools\core\services\config\models.py
Configuration Support Models¶
kp_ssf_tools.core.services.config.models.ValidationResult
¶
Bases: SSFToolsBaseModel
Configuration validation results.
Source code in src\kp_ssf_tools\core\services\config\models.py
kp_ssf_tools.core.services.config.models.ConfigurationSource
¶
Bases: SSFToolsBaseModel
Configuration source metadata.
Source code in src\kp_ssf_tools\core\services\config\models.py
Per-Command Configuration Models¶
kp_ssf_tools.<command>.models.configuration.py
Entropy Configuration Model¶
kp_ssf_tools.analyze.models.configuration
¶
Entropy-specific configuration models.
Classes¶
AnalysisConfig
¶
Bases: SSFToolsBaseModel
Analysis-specific configuration.
Source code in src\kp_ssf_tools\analyze\models\configuration.py
ContentAwareConfig
¶
Bases: SSFToolsBaseModel
Content-aware analysis configuration for PCI SSF 2.3 compliance.
Source code in src\kp_ssf_tools\analyze\models\configuration.py
DetectionConfig
¶
Bases: SSFToolsBaseModel
Detection feature configuration.
Source code in src\kp_ssf_tools\analyze\models\configuration.py
CredentialConfig
¶
Bases: SSFToolsBaseModel
Credential detection configuration.
Source code in src\kp_ssf_tools\analyze\models\configuration.py
StatisticalConfig
¶
Bases: SSFToolsBaseModel
Statistical analysis configuration.
Source code in src\kp_ssf_tools\analyze\models\configuration.py
ComplianceConfig
¶
Bases: SSFToolsBaseModel
Compliance-specific configuration.
Source code in src\kp_ssf_tools\analyze\models\configuration.py
ReportingConfig
¶
Bases: SSFToolsBaseModel
Reporting configuration for compliance.
Source code in src\kp_ssf_tools\analyze\models\configuration.py
AnalysisConfiguration
¶
Bases: BaseConfiguration
Complete security analysis configuration.
Inherits common output and network settings from BaseConfiguration. Contains analysis-specific configuration options for entropy analysis, wordlist detection, and cryptographic structure detection.
Source code in src\kp_ssf_tools\analyze\models\configuration.py
CLI Integration¶
The unified config command provides consistent configuration management across all SSF Tools commands. These are documented in the Configuration Management User Guide:
Key Architecture Benefits¶
🔄 No Circular Dependencies¶
- Core configuration services never import command-specific models
- Commands register themselves with the configuration manager at runtime
- Clean separation between core infrastructure and command implementations
📋 Registry Pattern¶
- Central registry manages all configuration services
- Commands can be added without modifying core code
- Unified CLI interface automatically supports new commands
🔍 Type Safety¶
- Protocol-based design enables full MyPy compliance
- Generic type parameters ensure configuration type safety
- Pydantic validation provides runtime type checking
⚙️ Multi-Source Merging¶
- Intelligent merging from user, project, and CLI sources
- Clear precedence rules prevent configuration conflicts
- Field-level merging allows granular overrides
🔌 Extensibility¶
- New commands integrate with zero changes to core systems
- Configuration services are pluggable and swappable
- Support for future configuration sources (remote, database, etc.)
Implementation Guide¶
Adding Configuration to a New Command¶
-
Define the configuration model:
-
Register with the container:
-
Register with the manager:
In the kp_ssf_tools.containers.application container initiationalize, add the new command's service with the Configuration Manager.
kp_ssf_tools.containers.application._configure_config_manager(manager, global_service, entropy_service)
¶
Configure the configuration manager with all available services.
Source code in src\kp_ssf_tools\containers\application.py
The CLI automatically supports the new command:
ssf-tools config init mycommand --user
ssf-tools config validate mycommand-config.yaml
ssf-tools config show mycommand
Using Configuration in Commands¶
Commands receive configuration through dependency injection:
@click.command()
@inject
def my_command(
config_service: ConfigurationServiceProtocol[MyCommandConfiguration] = Provide[...],
):
# Load effective configuration (user + project + CLI overrides)
config = config_service.load_config(
command_overrides={"my_setting": "cli_override"}
)
# Use type-safe configuration
print(f"Setting: {config.my_setting}")
print(f"Number: {config.my_number}")
This architecture ensures consistent, type-safe, and extensible configuration management across all SSF Tools commands while maintaining clean separation of concerns and excellent testability.
Configuration File Examples¶
The system supports unified configuration files that contain settings for multiple commands:
# ssf-tools-config.yaml
global:
output:
format: json
verbose: true
network:
timeout_seconds: 30
entropy:
analysis:
chunk_size: 8192
memory_limit_mb: 1024
detection:
credentials: true
crypto_structures: true
# Future commands automatically supported
volatility:
memory_analysis:
profile: WinXPSP2x86
This unified approach reduces configuration file proliferation while maintaining command-specific settings organization.