mirror of
https://github.com/Myzel394/config-lsp.git
synced 2025-06-18 23:15:26 +02:00
feat(sshd_config): Only show allowed completions inside a Match block
This commit is contained in:
parent
22cbfb711c
commit
9f76fedabb
@ -159,10 +159,14 @@ Match 192.168.0.2
|
|||||||
}
|
}
|
||||||
|
|
||||||
firstOption, firstMatchBlock := p.FindOption(uint32(3))
|
firstOption, firstMatchBlock := p.FindOption(uint32(3))
|
||||||
|
|
||||||
if !(firstOption.Key.Value == "PasswordAuthentication" && firstOption.OptionValue.Value == "yes" && firstMatchBlock.MatchEntry.Value == "Match 192.168.0.1") {
|
if !(firstOption.Key.Value == "PasswordAuthentication" && firstOption.OptionValue.Value == "yes" && firstMatchBlock.MatchEntry.Value == "Match 192.168.0.1") {
|
||||||
t.Errorf("Expected first option to be 'PasswordAuthentication yes' and first match block to be 'Match 192.168.0.1', but got: %v, %v", firstOption, firstMatchBlock)
|
t.Errorf("Expected first option to be 'PasswordAuthentication yes' and first match block to be 'Match 192.168.0.1', but got: %v, %v", firstOption, firstMatchBlock)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
emptyOption, matchBlock := p.FindOption(uint32(5))
|
||||||
|
if !(emptyOption == nil && matchBlock.MatchEntry.Value == "Match 192.168.0.1") {
|
||||||
|
t.Errorf("Expected empty option and match block to be 'Match 192.168.0.1', but got: %v, %v", emptyOption, matchBlock)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSimpleExampleWithComments(
|
func TestSimpleExampleWithComments(
|
||||||
|
@ -97,6 +97,8 @@ func (c SSHConfig) FindOption(line uint32) (*SSHOption, *SSHMatchBlock) {
|
|||||||
|
|
||||||
if found {
|
if found {
|
||||||
return rawEntry.(*SSHOption), matchBlock
|
return rawEntry.(*SSHOption), matchBlock
|
||||||
|
} else {
|
||||||
|
return nil, matchBlock
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
63
handlers/sshd_config/fields/match.go
Normal file
63
handlers/sshd_config/fields/match.go
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
package fields
|
||||||
|
|
||||||
|
var MatchAllowedOptions = map[string]struct{}{
|
||||||
|
"AcceptEnv": {},
|
||||||
|
"AllowAgentForwarding": {},
|
||||||
|
"AllowGroups": {},
|
||||||
|
"AllowStreamLocalForwarding": {},
|
||||||
|
"AllowTcpForwarding": {},
|
||||||
|
"AllowUsers": {},
|
||||||
|
"AuthenticationMethods": {},
|
||||||
|
"AuthorizedKeysCommand": {},
|
||||||
|
"AuthorizedKeysCommandUser": {},
|
||||||
|
"AuthorizedKeysFile": {},
|
||||||
|
"AuthorizedPrincipalsCommand": {},
|
||||||
|
"AuthorizedPrincipalsCommandUser": {},
|
||||||
|
"AuthorizedPrincipalsFile": {},
|
||||||
|
"Banner": {},
|
||||||
|
"CASignatureAlgorithms": {},
|
||||||
|
"ChannelTimeout": {},
|
||||||
|
"ChrootDirectory": {},
|
||||||
|
"ClientAliveCountMax": {},
|
||||||
|
"ClientAliveInterval": {},
|
||||||
|
"DenyGroups": {},
|
||||||
|
"DenyUsers": {},
|
||||||
|
"DisableForwarding": {},
|
||||||
|
"ExposeAuthInfo": {},
|
||||||
|
"ForceCommand": {},
|
||||||
|
"GatewayPorts": {},
|
||||||
|
"GSSAPIAuthentication": {},
|
||||||
|
"HostbasedAcceptedAlgorithms": {},
|
||||||
|
"HostbasedAuthentication": {},
|
||||||
|
"HostbasedUsesNameFromPacketOnly": {},
|
||||||
|
"IgnoreRhosts": {},
|
||||||
|
"Include": {},
|
||||||
|
"IPQoS": {},
|
||||||
|
"KbdInteractiveAuthentication": {},
|
||||||
|
"KerberosAuthentication": {},
|
||||||
|
"LogLevel": {},
|
||||||
|
"MaxAuthTries": {},
|
||||||
|
"MaxSessions": {},
|
||||||
|
"PasswordAuthentication": {},
|
||||||
|
"PermitEmptyPasswords": {},
|
||||||
|
"PermitListen": {},
|
||||||
|
"PermitOpen": {},
|
||||||
|
"PermitRootLogin": {},
|
||||||
|
"PermitTTY": {},
|
||||||
|
"PermitTunnel": {},
|
||||||
|
"PermitUserRC": {},
|
||||||
|
"PubkeyAcceptedAlgorithms": {},
|
||||||
|
"PubkeyAuthentication": {},
|
||||||
|
"PubkeyAuthOptions": {},
|
||||||
|
"RekeyLimit": {},
|
||||||
|
"RevokedKeys": {},
|
||||||
|
"RDomain": {},
|
||||||
|
"SetEnv": {},
|
||||||
|
"StreamLocalBindMask": {},
|
||||||
|
"StreamLocalBindUnlink": {},
|
||||||
|
"TrustedUserCAKeys": {},
|
||||||
|
"UnusedConnectionTimeout": {},
|
||||||
|
"X11DisplayOffset": {},
|
||||||
|
"X11Forwarding": {},
|
||||||
|
"X11UseLocalhos": {},
|
||||||
|
}
|
@ -17,8 +17,20 @@ func GetRootCompletions(
|
|||||||
) ([]protocol.CompletionItem, error) {
|
) ([]protocol.CompletionItem, error) {
|
||||||
kind := protocol.CompletionItemKindField
|
kind := protocol.CompletionItemKindField
|
||||||
|
|
||||||
|
availableOptions := make(map[string]docvalues.Value)
|
||||||
|
|
||||||
|
if parentMatchBlock == nil {
|
||||||
|
availableOptions = fields.Options
|
||||||
|
} else {
|
||||||
|
for option := range fields.MatchAllowedOptions {
|
||||||
|
if opt, found := fields.Options[option]; found {
|
||||||
|
availableOptions[option] = opt
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return utils.MapMapToSlice(
|
return utils.MapMapToSlice(
|
||||||
fields.Options,
|
availableOptions,
|
||||||
func(name string, rawValue docvalues.Value) protocol.CompletionItem {
|
func(name string, rawValue docvalues.Value) protocol.CompletionItem {
|
||||||
doc := rawValue.(docvalues.DocumentationValue)
|
doc := rawValue.(docvalues.DocumentationValue)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user