From ead761a398b815eeec0863eef6110a6f603cd8dc Mon Sep 17 00:00:00 2001 From: an1l4 <1995anila@gmail.com> Date: Wed, 23 Aug 2023 01:47:45 +0530 Subject: [PATCH] testing26 --- agent/kubviz/trivy_sbom.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/agent/kubviz/trivy_sbom.go b/agent/kubviz/trivy_sbom.go index 2fcdc7bc..19c9a297 100644 --- a/agent/kubviz/trivy_sbom.go +++ b/agent/kubviz/trivy_sbom.go @@ -1,6 +1,7 @@ package main import ( + "bytes" "encoding/json" "log" "os/exec" @@ -31,13 +32,20 @@ func publishTrivySbomReport(report model.Sbom, js nats.JetStreamContext, errCh c func executeCommandSbom(command string) ([]byte, error) { cmd := exec.Command("/bin/sh", "-c", command) //cmd := exec.Command(command) - stdout, err := cmd.Output() + var outc, errc bytes.Buffer + cmd.Stdout = &outc + cmd.Stderr = &errc + log.Println("*******before ece command") + //stdout, err := cmd.Output() + err := cmd.Run() + log.Println("*******command ececuted") if err != nil { log.Println("Execute Command Error", err.Error()) } + log.Println("*******output", outc.String(), errc.String()) - return stdout, err + return outc.Bytes(), err } // func RunTrivySbomScan(config *rest.Config, js nats.JetStreamContext, wg *sync.WaitGroup, errCh chan error) {