mirror of
https://github.com/mudler/LocalAI.git
synced 2025-01-30 08:04:13 +00:00
fix: security scanner dislikes runCommand
function arguments (#2140)
runCommand ==> ffmpegCommand. No functional changes, but makes it clear to the security scanner and future developers that this function cannot run arbitrary commands Signed-off-by: Dave Lee <dave@gray101.com>
This commit is contained in:
parent
6b411ae212
commit
44bc540bb5
@ -11,8 +11,8 @@ import (
|
|||||||
"github.com/go-skynet/LocalAI/core/schema"
|
"github.com/go-skynet/LocalAI/core/schema"
|
||||||
)
|
)
|
||||||
|
|
||||||
func runCommand(command []string) (string, error) {
|
func ffmpegCommand(args []string) (string, error) {
|
||||||
cmd := exec.Command(command[0], command[1:]...)
|
cmd := exec.Command("ffmpeg", args...) // Constrain this to ffmpeg to permit security scanner to see that the command is safe.
|
||||||
cmd.Env = os.Environ()
|
cmd.Env = os.Environ()
|
||||||
out, err := cmd.CombinedOutput()
|
out, err := cmd.CombinedOutput()
|
||||||
return string(out), err
|
return string(out), err
|
||||||
@ -21,8 +21,8 @@ func runCommand(command []string) (string, error) {
|
|||||||
// AudioToWav converts audio to wav for transcribe.
|
// AudioToWav converts audio to wav for transcribe.
|
||||||
// TODO: use https://github.com/mccoyst/ogg?
|
// TODO: use https://github.com/mccoyst/ogg?
|
||||||
func audioToWav(src, dst string) error {
|
func audioToWav(src, dst string) error {
|
||||||
command := []string{"ffmpeg", "-i", src, "-format", "s16le", "-ar", "16000", "-ac", "1", "-acodec", "pcm_s16le", dst}
|
commandArgs := []string{"-i", src, "-format", "s16le", "-ar", "16000", "-ac", "1", "-acodec", "pcm_s16le", dst}
|
||||||
out, err := runCommand(command)
|
out, err := ffmpegCommand(commandArgs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("error: %w out: %s", err, out)
|
return fmt.Errorf("error: %w out: %s", err, out)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user