Skip to content

Commit

Permalink
fixed semgrep findings
Browse files Browse the repository at this point in the history
Signed-off-by: vivekr-splunk <94569031+vivekr-splunk@users.noreply.github.com>
  • Loading branch information
vivekr-splunk committed Jul 24, 2023
1 parent bac7dbd commit 785365a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
3 changes: 2 additions & 1 deletion pkg/splunk/enterprise/cp.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"archive/tar"
"io"
"os"
"path/filepath"
)

var cpMakeTar = func(src localPath, dest remotePath, writer io.Writer) error {
Expand Down Expand Up @@ -85,7 +86,7 @@ func recursiveTar(srcDir, srcFile localPath, destDir, destFile remotePath, tw *t
if err := tw.WriteHeader(hdr); err != nil {
return err
}

fpath = filepath.Clean(fpath)
f, err := os.Open(fpath)
if err != nil {
return err
Expand Down
4 changes: 2 additions & 2 deletions pkg/splunk/enterprise/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ func createAppDownloadDir(ctx context.Context, path string) error {
scopedLog := reqLogger.WithName("createAppDownloadDir").WithValues("path", path)
_, err := os.Stat(path)
if errors.Is(err, os.ErrNotExist) {
errDir := os.MkdirAll(path, 0755)
errDir := os.MkdirAll(path, 0700)
if errDir != nil {
scopedLog.Error(errDir, "Unable to create directory at path")
return errDir
Expand All @@ -447,7 +447,7 @@ func getAvailableDiskSpace(ctx context.Context) (uint64, error) {
if err != nil {
scopedLog.Error(err, "There is no default volume configured for the App framework, use the temporary location", "dir", TmpAppDownloadDir)
splcommon.AppDownloadVolume = TmpAppDownloadDir
err = os.MkdirAll(splcommon.AppDownloadVolume, 0755)
err = os.MkdirAll(splcommon.AppDownloadVolume, 0700)
if err != nil {
scopedLog.Error(err, "Unable to create the directory", "dir", splcommon.AppDownloadVolume)
return 0, err
Expand Down
6 changes: 4 additions & 2 deletions tools/k8s_collectors/k8s-splunk-collector-helper.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
from __future__ import print_function
import os
import shlex
import sys, getopt
import subprocess

def executeShellCommand(command):
stream = subprocess.popen(command).wait()
cmdlist = shlex.split(command)
stream = subprocess.Popen(cmdlist).wait()
output = stream.read()
return output

Expand All @@ -21,7 +23,7 @@ def runAndCollectDiag(collectDir, podDiagsDir, pod):
if len(dirs) >= 2 and len(dirs[3]) > 0:
diagFile = dirs[3]

#Copy the diag over
#Copy the diag over
executeShellCommand("kubectl cp %s:%s %s/%s/%s" % (pod, diagFileFullPath, collectDir, podDiagsDir, diagFile))

#Delete the diag
Expand Down

0 comments on commit 785365a

Please sign in to comment.