feat: Add config, winrm, and ops packages with get_computer_info #4
No reviewers
Labels
No labels
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
brooktrails/directory-pacifier!4
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "feat/ops-and-winrm"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
internal/config — env-driven loader covering the union of fields any
service needs (Postgres, Anthropic, WinRM, advisory rules, HTTP listen,
controlloop URL). FromEnv populates whatever is set; Require* helpers
let each service spell out its own required-field policy.
internal/winrm — thin wrapper over masterzen/winrm exposing a single
RunPowerShell method. Signature matches ops.Executor so *Client
satisfies that interface implicitly. New() applies sensible defaults
(port 5985/5986 by transport, 30s timeout).
internal/ops — Operation interface + thread-safe Registry keyed by
operation_type. First operation: get_computer_info, a read-only AD
diagnostic that runs Get-ADComputer plus Test-Connection over WinRM
and returns combined JSON. Field names are constrained to plain
identifiers and subjects are character-whitelisted + single-quote
escaped to keep PowerShell injection off the table.
Default() returns a registry pre-populated with every operation in
this package — controlloop and rpcserver will both use it.
Co-Authored-By: Claude Opus 4.6 (1M context) noreply@anthropic.com
Automated review by pr-reviewer v0.15.0 | Safety Check | anthropic | tracking id
r-dc7638-ca48ebThis is an AI-generated review and may contain mistakes.
Status: ✅ Completed
✅ Verdict: LGTM — No security vulnerabilities or obvious bugs found; hardcoded test credentials and high-entropy test files are expected for this type of functionality.
Complexity: moderate
Safety Check Review
Overview
This PR adds configuration, WinRM client, and operations packages to support Windows remote management operations. The code appears well-structured with appropriate security considerations.
Security Analysis
^[A-Za-z][A-Za-z0-9_]*$) and subject character whitelisting, plus single-quote escaping for PowerShell literalsCode Quality
The implementation shows good defensive programming practices:
No Major Issues Found
The code demonstrates careful attention to security concerns around PowerShell execution and credential management.
Automated review by pr-reviewer v0.15.0 | Full Review | anthropic | tracking id
r-dc7698-4b224fThis is an AI-generated review and may contain mistakes.
Status: ✅ Completed
✅ Verdict: Approve — The code is well-structured with good security practices, comprehensive tests, and clear separation of concerns.
Complexity: moderate
Code Review: Add config, winrm, and ops packages
This is a well-crafted addition that introduces foundational infrastructure packages for a Windows remote management system. The code demonstrates strong engineering practices with security-first design, comprehensive testing, and clear architectural boundaries.
Security Analysis ✅
The security implementation is particularly noteworthy:
PowerShell Injection Prevention:
internal/ops/get_computer_info.go:48: Field names are restricted to^[A-Za-z][A-Za-z0-9_]*$preventing injection via propertiesinternal/ops/get_computer_info.go:138: Subject values are properly single-quote escaped with PS literal string rules ('→'')internal/ops/get_computer_info.go:168-184: Character allowlist validation provides defense in depth beyond quotingInput Validation:
Architecture & Design ✅
Clean Separation of Concerns:
internal/config: Environment-driven configuration with service-specific validationinternal/winrm: Thin wrapper over third-party library with sensible defaultsinternal/ops: Operation abstraction with registry pattern for extensibilityInterface Design:
Executorinterface allows clean testing with mocks/fakesOperationinterface provides consistent contract for all operationsImplementation Quality ✅
Error Handling:
Configuration Management:
internal/config/config.go:78-117: Env-only approach is clean and Kubernetes-friendlyPowerShell Script Generation:
internal/ops/get_computer_info.go:136-160: Well-structured script with proper error handlingTest Coverage ✅
The test suite is comprehensive:
Config Tests:
Registry Tests:
Operation Tests:
WinRM Tests:
Minor Observations
Automated Flags (Non-Issues):
go.sumand test files is expected for dependency hashes and test dataMissing Tests (Acceptable for MVP):
The automated observation notes 4 files lack corresponding tests:
internal/config/config.go- Has comprehensive tests inconfig_test.gointernal/ops/get_computer_info.go- Tested viaregistry_test.gointernal/ops/registry.go- Has dedicated tests inregistry_test.gointernal/winrm/client.go- Has tests inclient_test.goThe automated tool seems to be looking for 1:1 file naming, but the actual test coverage is excellent.
Conclusion
This is high-quality infrastructure code that establishes solid foundations for the Windows management system. The security-first approach, clean architecture, and comprehensive testing make it ready for production use. The abstraction layers will facilitate future extensibility while maintaining security boundaries.