Skip to content

Commit af7d7f7

Browse files
committed
fix typos
1 parent 6eea6e6 commit af7d7f7

2 files changed

Lines changed: 18 additions & 18 deletions

File tree

pkg/snclient/snclient_windows.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -291,17 +291,17 @@ func (snc *Agent) makeCmd(ctx context.Context, command string) (*exec.Cmd, error
291291

292292
// powershell files
293293
case isPsFile(cmdName):
294-
// parse the command one more time, this time adding the shelltoken.KeepQuoutes option
294+
// parse the command one more time, this time adding the shelltoken.KeepQuotes option
295295
cmdName, cmdArgs, _, err = snc.shellParse(command, shelltoken.SplitKeepQuotes)
296296
if err != nil {
297297
return nil, err
298298
}
299299

300300
cmdArgsModified := make([]string, 0, len(cmdArgs))
301301
for _, cmdArg := range cmdArgs {
302-
// parsed arguments might include double quoutes.
303-
// cmd.SysProcAttr.CmdLine is set so that the arguments are found within double quoutes inside the -Command parameter
304-
// to include a double quoute here, you have to add three double quoutes.
302+
// parsed arguments might include double quotes.
303+
// cmd.SysProcAttr.CmdLine is set so that the arguments are found within double quotes inside the -Command parameter
304+
// to include a double quote here, you have to add three double quotes.
305305
// windows has very confusing, runtime-dependent command line argument parsing
306306
// This is done with the assumption that its using GetCommandLineW, and it works for now
307307
cmdArg = strings.ReplaceAll(cmdArg, `"`, `"""`)
@@ -344,10 +344,10 @@ func (snc *Agent) shellParse(command string, additionalOptions ...shelltoken.Spl
344344
// when invoking a script, the script might use $ARG1$ macro
345345
// arg1 here might be a single string composed of many arguments, e.g:
346346
// powershell_detail_arg1 "-option1 option1 -option2 `'option2`' -option3 `"option3`" -option4 `'foo,bar`' -option5 `"baz,xyz`" "
347-
// if sheltoken.SplitKeepQuoutes option is not set, it strips the quotation marks from each option value
348-
// this leads to arguments like foo,bar not being quouted and being left as is
347+
// if shelltoken.SplitKeepQuotes option is not set, it strips the quotation marks from each option value
348+
// this leads to arguments like foo,bar not being quoted and being left as is
349349
// powershell then thinks its an array due to comma
350-
// if they were quouted, it would think that they are a string that includes comma character
350+
// if they were quoted, it would think that they are a string that includes comma character
351351

352352
for _, opt := range additionalOptions {
353353
options |= opt

pkg/snclient/snclient_windows_test.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import (
1818
// scriptName_arg1 : ./${SCRIPT_FILENAME} "$ARG1$"
1919
// scriptName_arg_numbered : ./${SCRIPT_FILENAME} "$ARG1$" "$ARG2$" "$ARG3$" "$ARG4$" "$ARG5$" "$ARG6$" "$ARG7$" "$ARG8$" "$ARG9$" "$ARG10$"
2020
// scriptName_args : ./${SCRIPT_FILENAME} "$ARGS$"
21-
// scriptName_args_quouted : ./${SCRIPT_FILENAME} "$ARGS"$"
21+
// scriptName_args_quoted : ./${SCRIPT_FILENAME} "$ARGS"$"
2222
//
2323
//nolint:unparam // scriptName is so far always "powershell_detail" , no other test script uses this function. Keep it as a parameter for future use.
2424
func snclientConfigFileWithScript(t *testing.T, scriptsDir, scriptName, scriptFilename string) string {
@@ -58,9 +58,9 @@ allow arguments = true
5858
allow nasty characters = true
5959
6060
[/settings/external scripts/scripts]
61-
${SCRIPT_NAME}_args_quouted = ./${SCRIPT_FILENAME} $ARGS"$
61+
${SCRIPT_NAME}_args_quoted = ./${SCRIPT_FILENAME} $ARGS"$
6262
63-
[/settings/external scripts/scripts/${SCRIPT_NAME}_args_quouted]
63+
[/settings/external scripts/scripts/${SCRIPT_NAME}_args_quoted]
6464
allow arguments = true
6565
allow nasty characters = true
6666
`
@@ -96,12 +96,12 @@ func TestMakeCmd(t *testing.T) {
9696
// cmd.Args is unused if cmd.SysProcAttr.CmdLine is set and nonempty
9797
// snclient sets it and does not populate cmd.Args
9898

99-
// the quoutes should not be removed
100-
// the reasoning is to pass some arguments as written inside the quoutes, so that they can take a string form and not be converted
99+
// the quotes should not be removed
100+
// the reasoning is to pass some arguments as written inside the quotes, so that they can take a string form and not be converted
101101
// if an argument is passed like this --optionX foo,bar powershell parameter parser thinks it is an object/string array and refuses to parse it as string
102102
// it has to be passed like --optionX 'foo,bar' to be parsed as a string
103103

104-
// 1 double quoute (") has to be converted to 3 double quoutes of cmd.SysProcAttr.CmdLine
104+
// 1 double quote (") has to be converted to 3 double quotes of cmd.SysProcAttr.CmdLine
105105
// check snclient_windows.go powershell block for more explanation
106106
cmdLineExpectedContains := `-option1 option1 -option2 'option2' -option3 """option3""" -option4 'option4.option4,option4:option4;option4|option4$option4'`
107107
assert.Containsf(t, cmd.SysProcAttr.CmdLine,
@@ -161,7 +161,7 @@ func TestPowershellScriptArg1(t *testing.T) {
161161
scriptsDir := filepath.Join(testDir, "t", "scripts")
162162
scriptName := "powershell_detail"
163163
scriptFilename := scriptName + ".ps1"
164-
// arg1 adds a single double-quoute around the first argument, which includes everything
164+
// arg1 adds a single double-quote around the first argument, which includes everything
165165
scriptMacroType := "_arg1"
166166
scriptArgs := []string{"-option1 option1 -option2 'option2' -option3 \"option3\" -option4 'foo,bar' -option5 \"baz,xyz\" "}
167167

@@ -311,13 +311,13 @@ func TestPowershellScriptArgs(t *testing.T) {
311311
}
312312

313313
//nolint:dupl // the functions are largely the same, but scriptMacroType is different. Redefining expected strings for each macro type is easier to understand.
314-
func TestPowershellScriptArgsQuouted(t *testing.T) {
314+
func TestPowershellScriptArgsQuoted(t *testing.T) {
315315
testDir, _ := os.Getwd()
316316
scriptsDir := filepath.Join(testDir, "t", "scripts")
317317
scriptName := "powershell_detail"
318318
scriptFilename := scriptName + ".ps1"
319-
scriptMacroType := "_args_quouted"
320-
// args_quouted adds double quoutes around each argument and joins them with space in-between
319+
scriptMacroType := "_args_quoted"
320+
// args_quoted adds double quotes around each argument and joins them with space in-between
321321
// the arguments are passed as a list here, not a single string
322322
scriptArgs := []string{
323323
"-option1",
@@ -341,7 +341,7 @@ func TestPowershellScriptArgsQuouted(t *testing.T) {
341341

342342
outputString := string(checkResult.BuildPluginOutput())
343343

344-
// since option specifiers like -option1 and -option2 are also quouted, this prevents them from working properly
344+
// since option specifiers like -option1 and -option2 are also quoted, this prevents them from working properly
345345

346346
assert.Equalf(t, CheckExitUnknown, checkResult.State, "check should return state Unknown")
347347

0 commit comments

Comments
 (0)