-
Notifications
You must be signed in to change notification settings - Fork 56
Expand sshdconfig parser #1284
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Expand sshdconfig parser #1284
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR expands the sshdconfig Rust parser to add support for three key features:
- Match blocks: Parses SSH
matchdirectives with criteria and associated keywords, storing them as nested objects with repeatability support - Operator nodes: Handles the +, -, and ^ operators used to modify keyword values, wrapping them in a structure with separate "operator" and "value" fields
- Keyword separation types: Distinguishes between comma-separated and space-separated multi-argument keywords for correct parsing
The changes improve the parser's ability to handle complex SSH server configurations, particularly conditional settings via match blocks and list modifications via operators.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
resources/sshdconfig/src/parser.rs |
Main parser logic updated to handle match blocks, operators, and different keyword separation types; adds new KeywordType enum and refactors parsing functions for reusability |
resources/sshdconfig/src/metadata.rs |
Splits MULTI_ARG_KEYWORDS into separate MULTI_ARG_KEYWORDS_COMMA_SEP and MULTI_ARG_KEYWORDS_SPACE_SEP constants to distinguish separation types |
resources/sshdconfig/locales/en-us.toml |
Adds new error messages for match block parsing (missingCriteriaInMatch, noArgumentsFound) |
grammars/tree-sitter-ssh-server-config/grammar.js |
Changes _quotedString to quotedString (removes underscore prefix) to make it a named node in the parse tree |
grammars/tree-sitter-ssh-server-config/test/corpus/valid_expressions.txt |
Updates test expectations to reflect quotedString as a named node instead of inline string |
Comments suppressed due to low confidence (1)
resources/sshdconfig/src/parser.rs:251
- This error case is unreachable. Since
map.contains_key(key)was checked on line 234,map.get_mut(key)on line 236 will always returnSome(...), neverNone. Consider simplifying this code by removing the else branch or using.unwrap()with a comment explaining why it's safe.
} else {
return Err(SshdConfigError::ParserError(t!("parser.keyNotFound", key = key).to_string()));
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
PR Summary
matchblocksoperatornodes - add (+), remove (-), insert (^)PR Context