fix: add support for preserving quoted group names in sshd_config - #1639
fix: add support for preserving quoted group names in sshd_config#1639Gijsreyn wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes a Windows-specific parsing/export bug in the Microsoft.OpenSSH.SSHD/sshd_config resource where space-containing, quoted list entries (e.g. AllowGroups administrators "openssh users") were incorrectly split into separate items during get and export.
Changes:
- Added a Pester test that verifies
getandexportpreserve quoted group names containing spaces. - Updated
get_sshd_settings()to prefer explicitly-parsed config-file values for space-separated multi-arg keywords (avoidingsshd -Tquote-stripping/splitting behavior). - Added Rust unit tests covering the new override behavior.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| resources/sshdconfig/tests/sshdconfig.get.tests.ps1 | Adds coverage ensuring quoted group values remain a single array entry for both get and export. |
| resources/sshdconfig/src/get.rs | Restores correct list semantics by overriding sshd -T-normalized values with explicitly parsed config values for affected keywords. |
0faeeaf to
9b7da04
Compare
|
@tgauth - is this something you can take a quick look at? |
|
Thanks for opening this! My initial thoughts are that this issue is applicable to other arguments that can have spaces as well (i.e. regular arguments for paths) and I wonder if we can address those here as well. I'm going to think on it a bit and see if there's a good way to do that, and if not, we can defer it to a future PR. |
9b7da04 to
b991333
Compare
| } | ||
|
|
||
| fn prefer_explicit_space_sep_lists(result: &mut Map<String, Value>, explicit_settings: &Map<String, Value>) { | ||
| for keyword in MULTI_ARG_KEYWORDS_SPACE_SEP { |
There was a problem hiding this comment.
Ok to cover broader cases, I think there's two changes needed:
- Expand this check to be any keyword in
explicit_settingsthat has spaces, rather than only checking for keywords inMULTI_ARG_KEYWORDS_SPACE_SEP - When the Rust parser is parsing keywords from
sshd -T, it should not error on "regular, single-value" keywords with a spaced value (i.e. Banner "C:\Program Files\ssh\sample_banner.txt" is output as Banner c:\program files\ssh\sample_banner.txt which seems like Banner has two args "c:\program" and "file\ssh\sample_banner.txt" so the parser errors currently. We should have the parser combine them into a single value)
@Gijsreyn, if you want to leave the PR as-is and then I'll add these changes after, that's fine with me too!
There was a problem hiding this comment.
@tgauth - thanks for the feedback! I tried to incorporate it already into this PR. Let me know what you think :)
0161afd to
4f80db6
Compare
PR Summary
Fixes a bug where
sshd_configlist keywords with quoted, space-containing values (e.g. the Windows group "openssh users") were split into separate entries on export and get.PR Context
Fixes #1508.