File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -3,7 +3,9 @@ package main
3
3
import (
4
4
"bytes"
5
5
"encoding/json"
6
+ "fmt"
6
7
"log"
8
+ "os"
7
9
exec "os/exec"
8
10
"strings"
9
11
@@ -29,8 +31,15 @@ func executeCommandTrivy(command string) ([]byte, error) {
29
31
return outc .Bytes (), err
30
32
}
31
33
func RunTrivyK8sClusterScan (js nats.JetStreamContext ) error {
34
+ pvcMountPath := "/mnt/agent/kbz"
35
+ trivyCacheDir := fmt .Sprintf ("%s/trivy-cache" , pvcMountPath )
36
+ err := os .MkdirAll (trivyCacheDir , 0755 )
37
+ if err != nil {
38
+ log .Printf ("Error creating Trivy cache directory: %v\n " , err )
39
+ return err
40
+ }
32
41
var report report.ConsolidatedReport
33
- cmdString := "trivy k8s --report summary cluster --exclude-nodes kubernetes.io/arch:amd64 --timeout 60m -f json --cache-dir /tmp/.cache --debug"
42
+ cmdString := fmt . Sprintf ( "trivy k8s --report summary cluster --exclude-nodes kubernetes.io/arch:amd64 --timeout 60m -f json --cache-dir %s --debug" , trivyCacheDir )
34
43
clearCacheCmd := "trivy k8s --clear-cache"
35
44
out , err := executeCommandTrivy (cmdString )
36
45
if err != nil {
You can’t perform that action at this time.
0 commit comments