feat: enable and verify xp_cmdshell for mssql setup and validation#93
Merged
Conversation
…ator **Added:** - Introduced Ansible tasks to enable `xp_cmdshell` in MSSQL, including error handling and logging for failures in the role's configuration tasks - Documented the new `xp_cmdshell` enable and logging steps in the MSSQL role README **Changed:** - Updated MSSQL validator to treat `xp_cmdshell` not being enabled as a FAIL instead of a WARN, making the check stricter for compliance **Removed:** - No removals
…alidator total **Changed:** - Updated mssql role to ensure BUILTIN\Administrators has SQL sysadmin, removing temporary ssm-user sysadmin grants and revokes for idempotency and simpler re-provisioning (config.yml, README.md) - Removed all unnecessary become/runas SYSTEM usage in mssql config tasks since ssm-user retains sysadmin - Improved documentation in mssql config tasks to clarify privilege rationale and bootstrap flow - Adjusted validator to compute report.Total as sum of Passed, Failed, and Warnings for accurate reporting **Removed:** - Removed tasks that granted and revoked ssm-user SQL sysadmin in mssql config for a simpler, persistent privilege model - Eliminated redundant become/runas SYSTEM parameters from mssql config tasks
…e for validator **Added:** - Introduced `runChecks` method to execute validation checks concurrently with bounded parallelism, ensuring each check's output appears in submission order - Defined `checkFunc` type for uniform check function signatures - Added tests (`validator_test.go`) for concurrent check execution, output ordering, result collection, and semaphore limit enforcement **Changed:** - Refactored all check methods in `checks.go` and their invocations to accept an `io.Writer` parameter for flexible output (required by `runChecks`) - Updated `addResult` to write colored status lines to a provided writer, improving testability and output control - Modified `DiscoverHosts` to use `addResult` with `os.Stdout` - `RunQuickChecks` and `RunAllChecks` now delegate check execution to `runChecks`, replacing sequential calls with concurrent, ordered execution - Added a mutex to `Validator` to protect concurrent mutation of the report - Improved output handling for status messages (e.g., INFO, SKIP, WARN) for consistency and testability **Removed:** - Eliminated direct `fmt.Println` and `color.*` calls from check methods in favor of writer-based output and the `printHeader` helper
**Added:** - Introduced a `captureResult` struct to carry both output and error from goroutine handling stdout capture **Changed:** - Updated stdout capturing logic to use `captureResult`, enabling error propagation from the goroutine to the test - Modified `restore` to fail the test with `t.Fatalf` if an error occurred during output capture **Removed:** - Removed use of string-only channels for capturing output, ensuring errors are not silently ignored
Changed: - Updated all fmt.Fprintf, fmt.Fprint, and os.Stdout.Write calls to explicitly ignore returned values by assigning them to blank identifiers, clarifying intent to discard errors and comply with static analysis tools - Modified test code to also explicitly ignore errors from fmt.Fprintf and io.Writer Close calls, improving consistency and code readability
4d51c3a to
f6d20cb
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Key Changes:
Added:
including error handling and output logging in the config task
Changed:
of a warning, improving enforcement of security and operational requirements
in the validation checks
enablement and error logging steps