fix(matches): split command into arguments

This commit is contained in:
Emmanuel BENOîT 2024-07-20 22:31:28 +02:00
parent 9333c6ff80
commit b8506e8a3f
Signed by: Emmanuel BENOîT
SSH key fingerprint: SHA256:l7PFUUF5TCDsvYeQC9OnTNz08dFY7Fvf4Hv3neIqYpg

View file

@ -5,6 +5,7 @@ import (
"context" "context"
"io" "io"
"os/exec" "os/exec"
"strings"
) )
// streamObtainer refers to functions that may return either an input stream or // streamObtainer refers to functions that may return either an input stream or
@ -72,7 +73,8 @@ func (pc *pipeCopy) abort() {
// from both stderr and stdout to the dataPipe. // from both stderr and stdout to the dataPipe.
func (pluginInst *matchesPlugin) readFromProgram(ctx context.Context, pipes *readerPipes) { func (pluginInst *matchesPlugin) readFromProgram(ctx context.Context, pipes *readerPipes) {
go func() { go func() {
cmd := exec.Command(pluginInst.dataSource) //nolint:gosec // Command is in fact user-provided args := strings.Split(pluginInst.dataSource, " ")
cmd := exec.Command(args[0], args[1:]...) //nolint:gosec // Command is in fact user-provided
outs := startPipeCopy(func() (io.ReadCloser, error) { return cmd.StdoutPipe() }, pipes) outs := startPipeCopy(func() (io.ReadCloser, error) { return cmd.StdoutPipe() }, pipes)
defer outs.close() defer outs.close()