From 408588c5dc14ebc34feecd99e6bb030c5b4a3599 Mon Sep 17 00:00:00 2001 From: Jake Correnti Date: Thu, 17 Aug 2023 09:33:01 -0400 Subject: [PATCH] Fix golangci-lint errors Fixes golangci-lint errors introduced by #258 If `gosec` linting is enabled for the return statement in `Cmd`, an error will be returned: `G204: Subprocess launched with a potential tainted input or cmd arguments (gosec)`. This error tries to make sure a user cannot provide a binary that could cause harm to the system. We can't do much about this since the binary is externally provided. It is up to the caller to make sure they don't provide a "dangerous" binary. Therefore, it's ok that we ignore this linting error. Signed-off-by: Jake Correnti --- pkg/types/command.go | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/pkg/types/command.go b/pkg/types/command.go index 5ebca3a2..d3f80d53 100644 --- a/pkg/types/command.go +++ b/pkg/types/command.go @@ -85,11 +85,7 @@ func (c *Command) AddVfkitSocket(socket string) { } func (c *Command) addForwardInfo(flag, value string) { - if _, ok := c.forwardInfo[flag]; ok { - c.forwardInfo[flag] = append(c.forwardInfo[flag], value) - } else { - c.forwardInfo[flag] = []string{value} - } + c.forwardInfo[flag] = append(c.forwardInfo[flag], value) } func (c *Command) AddForwardSock(socket string) { @@ -189,5 +185,5 @@ func (c *Command) ToCmdline() []string { // Cmd converts Command to a commandline format and returns an exec.Cmd which // can be executed by os/exec func (c *Command) Cmd(gvproxyPath string) *exec.Cmd { - return exec.Command(gvproxyPath, c.ToCmdline()...) + return exec.Command(gvproxyPath, c.ToCmdline()...) // #nosec G204 }