Ensure scripting command watched only JS files

This commit is contained in:
Alon Girmonsky
2024-10-08 10:04:46 -07:00
parent 783aa03b6a
commit 3fcc51c5c3
2 changed files with 10 additions and 0 deletions

View File

@@ -4,6 +4,7 @@ import (
"io/fs"
"os"
"path/filepath"
"strings"
"github.com/kubeshark/kubeshark/misc"
"github.com/rs/zerolog/log"
@@ -33,6 +34,10 @@ func (config *ScriptingConfig) GetScripts() (scripts []*misc.Script, err error)
var script *misc.Script
path := filepath.Join(config.Source, f.Name())
if !strings.HasSuffix(path, ".js") {
log.Info().Str("path", path).Msg("Skipping non-JS file")
continue
}
script, err = misc.ReadScriptFile(path)
if err != nil {
return