How computedocean/locksmith works
Project type and purpose
• This is an open-source PowerShell module and standalone script (“Locksmith”) designed to scan and optionally remediate misconfigurations in Active Directory Certificate Services (AD CS).
• It ships as both a module (Locksmith.psd1 + Locksmith.psm1) and a monolithic script (Invoke-Locksmith.ps1), with multiple “modes” that control output and remediation behavior.
File structure
• Top-level:
• Public entrypoints: Invoke-Locksmith.ps1, Public/Invoke-Locksmith.ps1
• Module files: Locksmith.psd1, Locksmith.psm1
• Scan implementations: Private/*.ps1
• Build & release scripts: Build/*.ps1, .github/workflows/**
• Documentation: Docs/, mkdocs.yml, en-US/ (help XML)
• Tests: Tests/*.ps1
• Patterns:
• “Private” folder holds individual scan/remediation functions (ESC1, ESC2,… Auditing, etc.).
• “Public” exports only the top-level cmdlet.
• Build/CI pipelines generate docs (MkDocs) and package to PowerShell Gallery.
README for additional insights
• Scans parameter drives selection of Private/*.ps1 modules.
• Requires ActiveDirectory and ServerManager PowerShell modules and domain-joined system.
a. Main components
1. User Interface Layer
– CLI entrypoint (Invoke-Locksmith.ps1 or module cmdlet)
2. Orchestration Layer
– Dispatcher/orchestrator in Locksmith.psm1
3. Scan & Remediation Modules
– Private/*.ps1 (one file per vulnerability type)
4. Output Renderer
– Table/List/CSV formatter, CSV writer, console writer
5. Build & Documentation Pipeline
– Build/*.ps1, mkdocs.yml, GitHub Actions
6. Tests
– Tests/*.ps1 – smoke and scenario tests
7. External Dependencies
– Active Directory Certificate Services (via ActiveDirectory module)
– ServerManager PowerShell module
– File system for CSV, help XML, docs
b. Relationships and interactions
• User invokes CLI → orchestrator loads selected scan modules → each scan module uses AD/ServerManager cmdlets to collect data → results flow to renderer or remediation functions → outputs written to console or CSV (or changes applied back to AD CS).
• Build scripts pull source code + Docs → generate MkDocs site and packaged module/artifact → GitHub Actions automate test, lint, build, and release.
• Tests simulate AD CS objects and validate scan logic against expected results.
c. Architectural patterns & design principles
• Modular scan plugins (separation of concerns per vulnerability scan).
• Single entrypoint with mode-driven behavior (Strategy pattern).
• Infrastructure abstraction: all AD interactions through PowerShell modules.
• CI/CD Pipeline as code (GitHub workflows).
d. Key technologies & frameworks
• PowerShell 5+.
• PowerShell modules: ActiveDirectory, ServerManager.
• MkDocs for documentation.
• GitHub Actions for CI/CD.
• Pester (implicitly for tests).
Detailed coverage
• Mode parameter branching logic in the orchestrator.
• Tests consuming Public/Private code and simulating results.