Skip to content
Merged
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
7 changes: 5 additions & 2 deletions pkg/snclient/check_tasksched_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"context"
_ "embed"
"fmt"
"slices"
"strconv"
"strings"
"syscall"
Expand Down Expand Up @@ -36,8 +37,10 @@ func (l *CheckTasksched) addTasks(ctx context.Context, snc *Agent, check *CheckD
}

if l.Folder != CheckTaskschedDefaultFolder {
if strings.ContainsFunc(l.Folder, func(r rune) bool { return !unicode.IsLetter(r) && r != '\\' }) {
return fmt.Errorf("custom specified folder should be all letters or backslashes, but it isnt: %s", l.Folder)
// NTFS characters are generally allowed, expect quotes
allowedRunes := []rune{' ', '-', '\\', '_', '(', ')', '[', ']', '.', ','}
if strings.ContainsFunc(l.Folder, func(r rune) bool { return !unicode.IsLetter(r) && !slices.Contains(allowedRunes, r) }) {
return fmt.Errorf("custom specified folder should be all letters or allowed runes: '%s', but it isnt: %s", string(allowedRunes), l.Folder)
}
}

Expand Down
8 changes: 4 additions & 4 deletions pkg/snclient/snclient_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -406,17 +406,17 @@ func powerShellCmd(ctx context.Context, command string, parameters ...PowerShell
cmd = exec.CommandContext(ctx, "powershell")
cmd.Args = nil

checkQuoutes := func(str string) bool {
checkQuotes := func(str string) bool {
if strings.ContainsRune(str, '\'') || strings.ContainsRune(str, '"') {
return true
}

return false
}
for _, para := range parameters {
if checkQuoutes(para.name) || checkQuoutes(para.parameterType) ||
checkQuoutes(para.defaultValue) || checkQuoutes(para.specifiedValue) {
return nil, errors.New("one of the parameters has its name/type or values contain single or double quoutes")
if checkQuotes(para.name) || checkQuotes(para.parameterType) ||
checkQuotes(para.defaultValue) || checkQuotes(para.specifiedValue) {
return nil, errors.New("one of the parameters has its name/type or values contain single or double quotes")
}
}

Expand Down