mirror of
https://github.com/Myzel394/config-lsp.git
synced 2025-06-18 15:05:28 +02:00
fix(sshd_config): Use normalized option keys
This commit is contained in:
parent
b9b932d0f2
commit
c3d1ec3b0f
@ -12,10 +12,12 @@ import (
|
||||
protocol "github.com/tliron/glsp/protocol_3_16"
|
||||
)
|
||||
|
||||
var matchOption = fields.CreateNormalizedName("Match")
|
||||
|
||||
func analyzeMatchBlocks(
|
||||
ctx *analyzerContext,
|
||||
) {
|
||||
for matchBlock, options := range ctx.document.Indexes.AllOptionsPerName["Match"] {
|
||||
for matchBlock, options := range ctx.document.Indexes.AllOptionsPerName[matchOption] {
|
||||
option := options[0]
|
||||
// Check if the match block has filled out all fields
|
||||
if matchBlock == nil || matchBlock.MatchValue == nil || len(matchBlock.MatchValue.Entries) == 0 {
|
||||
|
@ -234,7 +234,7 @@ Match Address 192.168.0.2
|
||||
}
|
||||
|
||||
firstOption, firstMatchBlock := p.FindOption(uint32(3))
|
||||
if !(firstOption.Key.Key == "PasswordAuthentication" && firstOption.OptionValue.Value.Value == "yes") {
|
||||
if !(firstOption.Key.Key == "passwordauthentication" && firstOption.OptionValue.Value.Value == "yes") {
|
||||
t.Errorf("Expected first option to be 'PasswordAuthentication yes' and first match block to be 'Match Address 192.168.0.1', but got: %v, %v", firstOption, firstMatchBlock)
|
||||
}
|
||||
|
||||
|
@ -11,6 +11,8 @@ import (
|
||||
|
||||
var whitespacePattern = regexp.MustCompile(`\S+`)
|
||||
|
||||
var includeOption = fields.CreateNormalizedName("Include")
|
||||
|
||||
func CreateIndexes(config ast.SSHDConfig) (*SSHDIndexes, []common.LSPError) {
|
||||
errs := make([]common.LSPError, 0)
|
||||
indexes := &SSHDIndexes{
|
||||
@ -42,7 +44,7 @@ func CreateIndexes(config ast.SSHDConfig) (*SSHDIndexes, []common.LSPError) {
|
||||
}
|
||||
|
||||
// Add Includes
|
||||
for matchBlock, options := range indexes.AllOptionsPerName["Include"] {
|
||||
for matchBlock, options := range indexes.AllOptionsPerName[includeOption] {
|
||||
includeOption := options[0]
|
||||
rawValue := includeOption.OptionValue.Value.Value
|
||||
pathIndexes := whitespacePattern.FindAllStringIndex(rawValue, -1)
|
||||
|
@ -34,7 +34,7 @@ Match Address 192.168.0.1/24
|
||||
}
|
||||
|
||||
firstMatchBlock := config.FindMatchBlock(uint32(6))
|
||||
opts := indexes.AllOptionsPerName["PermitRootLogin"]
|
||||
opts := indexes.AllOptionsPerName["permitrootlogin"]
|
||||
if !(len(opts) == 2 &&
|
||||
len(opts[nil]) == 1 &&
|
||||
opts[nil][0].Value.Value == "PermitRootLogin yes" &&
|
||||
@ -42,7 +42,7 @@ Match Address 192.168.0.1/24
|
||||
len(opts[firstMatchBlock]) == 1 &&
|
||||
opts[firstMatchBlock][0].Value.Value == "\tPermitRootLogin no" &&
|
||||
opts[firstMatchBlock][0].Start.Line == 6 &&
|
||||
opts[firstMatchBlock][0].Key.Key == "PermitRootLogin") {
|
||||
opts[firstMatchBlock][0].Key.Key == "permitrootlogin") {
|
||||
t.Errorf("Expected 3 PermitRootLogin options, but got %v", opts)
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user