From f739ecc4cbbf2c830980f6e0583188960d770b99 Mon Sep 17 00:00:00 2001 From: Brian Davis Date: Thu, 26 Dec 2024 20:02:08 -0500 Subject: [PATCH] fix procAll to skip invalid pids --- cmd/procAll.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/cmd/procAll.go b/cmd/procAll.go index e0c6f45..b800784 100644 --- a/cmd/procAll.go +++ b/cmd/procAll.go @@ -4,6 +4,7 @@ import ( "fmt" "os" "path/filepath" + "strings" "github.com/slimm609/checksec/pkg/utils" @@ -22,11 +23,15 @@ var procAllCmd = &cobra.Command{ processes, _ := process.Processes() for _, process := range processes { proc := process.Pid + // skip checksec + if proc == int32(os.Getpid()) { + continue + } filePath := filepath.Join("/proc", fmt.Sprint(proc), "exe") file, err := os.Readlink(filePath) + file = strings.Split(file, " ")[0] if err != nil { - fmt.Printf("Error: Pid %d not found", proc) - os.Exit(1) + continue } data, color := utils.RunFileChecks(file) Elements = append(Elements, data...)