Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions grammars/tree-sitter-ssh-server-config/grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ module.exports = grammar({
repeat1(choice($.comment, $.keyword)),
),

arguments: $ => repeat1(choice($.boolean, $.number, $._quotedString, $._commaSeparatedString)),
arguments: $ => repeat1(choice($.boolean, $.number, $.quotedString, $._commaSeparatedString)),

alphanumeric: $ => /[a-zA-Z0-9]+/i,
boolean: $ => choice('yes', 'no'),
Expand All @@ -43,7 +43,7 @@ module.exports = grammar({
string: $ => /[^\r\n,"]+/,

_commaSeparatedString: $ => seq($.string, repeat(seq(',', $.string))),
_quotedString: $ => seq('\"', $.string, '\"'),
quotedString: $ => seq('\"', $.string, '\"'),
}

});
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ authorizedKEYSfile "path to authorized keys file"
(keyword
(alphanumeric)
(arguments
(string))))
(quotedString
(string)))))
=====
comment
=====
Expand All @@ -36,7 +37,8 @@ authorizedkeysfile "path to authorized keys file"
(keyword
(alphanumeric)
(arguments
(string)))))
(quotedString
(string))))))
=====
boolean and match
=====
Expand All @@ -59,7 +61,8 @@ authorizedkeysfile "path to authorized keys file"
(keyword
(alphanumeric)
(arguments
(string)))))
(quotedString
(string))))))
=====
directive with = operator
=====
Expand Down Expand Up @@ -108,7 +111,8 @@ AllowGroups group1 "group two"
(alphanumeric)
(arguments
(string)
(string))))
(quotedString
(string)))))
=====
directive with comma-separated arguments
=====
Expand Down Expand Up @@ -316,7 +320,8 @@ passwordauthentication yes
(alphanumeric)
(arguments
(string)
(string))))
(quotedString
(string)))))
(match
(keyword
(alphanumeric)
Expand Down Expand Up @@ -367,4 +372,5 @@ allowgroups administrators "openssh users"
(alphanumeric)
(arguments
(string)
(string))))
(quotedString
(string)))))
2 changes: 2 additions & 0 deletions resources/sshdconfig/locales/en-us.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,10 @@ invalidValue = "operator is an invalid value for node"
keyNotFound = "key '%{key}' not found"
keyNotRepeatable = "key '%{key}' is not repeatable"
keywordDebug = "Parsing keyword: '%{text}'"
missingCriteriaInMatch = "missing criteria field in match block: '%{input}'"
missingValueInChildNode = "missing value in child node: '%{input}'"
missingKeyInChildNode = "missing key in child node: '%{input}'"
noArgumentsFound = "no arguments found in node: '%{input}'"
valueDebug = "Parsed argument value:"
unknownNode = "unknown node: '%{kind}'"
unknownNodeType = "unknown node type: '%{node}'"
Expand Down
28 changes: 19 additions & 9 deletions resources/sshdconfig/src/metadata.rs
Original file line number Diff line number Diff line change
@@ -1,29 +1,39 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

// keywords that can have multiple argments per line but cannot be repeated over multiple lines,
// keywords that can have multiple comma-separated arguments per line but cannot be repeated over multiple lines,
// as subsequent entries are ignored, should be represented as arrays
pub const MULTI_ARG_KEYWORDS: [&str; 16] = [
pub const MULTI_ARG_KEYWORDS_COMMA_SEP: [&str; 10] = [
"authenticationmethods",
"authorizedkeysfile",
"casignaturealgorithms",
"channeltimeout",
"ciphers",
"hostbasedacceptedalgorithms",
"hostkeyalgorithms",
"ipqos",
"kexalgorithms",
"macs",
"permitlisten",
"permitopen",
"permituserenvironment",
"persourcepenalties",
"persourcepenaltyexemptlist",
"pubkeyacceptedalgorithms"
];

// keywords that can have multiple space-separated arguments per line but cannot be repeated over multiple lines,
// as subsequent entries are ignored, should be represented as arrays
pub const MULTI_ARG_KEYWORDS_SPACE_SEP: [&str; 11] = [
"acceptenv",
"allowgroups",
"allowusers",
"authorizedkeysfile",
"channeltimeout",
"denygroups",
"denyusers",
"ipqos",
"permitlisten",
"permitopen",
"persourcepenalties",
];

// keywords that can be repeated over multiple lines and should be represented as arrays.
// note that some keywords can be both multi-arg and repeatable, in which case they only need to be listed here
// note that some keywords can be both multi-arg space-separated and repeatable
pub const REPEATABLE_KEYWORDS: [&str; 12] = [
"acceptenv",
"allowgroups",
Expand Down
Loading