diff --git a/server/handlers/sshd_config/analyzer/options.go b/server/handlers/sshd_config/analyzer/options.go index 0c13f62..8337ade 100644 --- a/server/handlers/sshd_config/analyzer/options.go +++ b/server/handlers/sshd_config/analyzer/options.go @@ -40,7 +40,7 @@ func checkOption( checkIsUsingDoubleQuotes(ctx, option.Key.Value, option.Key.LocationRange) checkQuotesAreClosed(ctx, option.Key.Value, option.Key.LocationRange) - key := fields.CreateNormalizedName(option.Key.Key) + key := option.Key.Key docOption, found := fields.Options[key] if !found { diff --git a/server/handlers/sshd_config/ast/listener.go b/server/handlers/sshd_config/ast/listener.go index cc5a414..287c1fb 100644 --- a/server/handlers/sshd_config/ast/listener.go +++ b/server/handlers/sshd_config/ast/listener.go @@ -4,6 +4,7 @@ import ( "config-lsp/common" commonparser "config-lsp/common/parser" "config-lsp/handlers/sshd_config/ast/parser" + "config-lsp/handlers/sshd_config/fields" "config-lsp/handlers/sshd_config/match-parser" "strings" @@ -76,7 +77,7 @@ func (s *sshdParserListener) EnterKey(ctx *parser.KeyContext) { s.sshdContext.currentOption.Key = &SSHDKey{ LocationRange: location, Value: value, - Key: key, + Key: fields.CreateNormalizedName(key), } } diff --git a/server/handlers/sshd_config/ast/sshd_config.go b/server/handlers/sshd_config/ast/sshd_config.go index 73513e2..f29285c 100644 --- a/server/handlers/sshd_config/ast/sshd_config.go +++ b/server/handlers/sshd_config/ast/sshd_config.go @@ -3,14 +3,16 @@ package ast import ( "config-lsp/common" commonparser "config-lsp/common/parser" + "config-lsp/handlers/sshd_config/fields" "config-lsp/handlers/sshd_config/match-parser" + "github.com/emirpasic/gods/maps/treemap" ) type SSHDKey struct { common.LocationRange Value commonparser.ParsedString - Key string + Key fields.NormalizedOptionName } type SSHDValue struct { diff --git a/server/handlers/sshd_config/fields/tokens.go b/server/handlers/sshd_config/fields/tokens.go new file mode 100644 index 0000000..ee9d875 --- /dev/null +++ b/server/handlers/sshd_config/fields/tokens.go @@ -0,0 +1,71 @@ +package fields + +var AvailableTokens = map[string]string{ + "%%": "A literal ‘%’.", + "%C": "Identifies the connection endpoints, containing four space-separated values: client address, client port number, server address, and server port number.", + "%D": "The routing domain in which the incoming connection was received.", + "%F": "The fingerprint of the CA key.", + "%f": "The fingerprint of the key or certificate.", + "%h": "The home directory of the user.", + "%i": "The key ID in the certificate.", + "%K": "The base64-encoded CA key.", + "%k": "The base64-encoded key or certificate for authentication.", + "%s": "The serial number of the certificate.", + "%T": "The type of the CA key.", + "%t": "The key or certificate type.", + "%U": "The numeric user ID of the target user.", + "%u": "The username.", +} + +// A map of