Skip to content

Commit fbad6ed

Browse files
committed
fix: scan and helm install command update
1 parent 58adb50 commit fbad6ed

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

cmd/sdkr/scan.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import (
99
"github.com/spf13/cobra"
1010
)
1111

12+
var timeout int
13+
1214
// scanCmd provides functionality to scan a Docker image for known security issues.
1315
// It supports both direct command-line arguments and configuration file values for the image name,
1416
// and optionally allows saving the scan report to a specified SARIF file.
@@ -34,7 +36,7 @@ var scanCmd = &cobra.Command{
3436
}
3537

3638
pterm.Info.Printf("Scanning Docker image %q...\n", imageRef)
37-
err := docker.Trivy(imageRef, useAI)
39+
err := docker.Trivy(imageRef, timeout, useAI)
3840
if err != nil {
3941
return err
4042
}
@@ -51,5 +53,6 @@ var scanCmd = &cobra.Command{
5153

5254
func init() {
5355
scanCmd.Flags().BoolVar(&useAI, "ai", false, "To enable AI help mode, export the OPENAI_API_KEY environment variable with your OpenAI API key.")
56+
scanCmd.Flags().IntVar(&timeout, "timeout", 600, "timeout for docker image scan")
5457
sdkrCmd.AddCommand(scanCmd)
5558
}

internal/docker/scan.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ import (
1212

1313
// Trivy runs 'trivy image' to scan a Docker image for vulnerabilities
1414
// and displays the results. It's a simplified version that accepts just the image name and tag.
15-
func Trivy(dockerImage string, useAI bool) error {
15+
func Trivy(dockerImage string, timeout int, useAI bool) error {
1616
ctx := context.Background()
17-
args := []string{"image", dockerImage, "--format", "table"}
17+
args := []string{"image", dockerImage, string(timeout), "--format", "table"}
1818

1919
cmd := exec.CommandContext(ctx, "trivy", args...)
2020
var stdoutBuf, stderrBuf bytes.Buffer

internal/helm/install.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -579,7 +579,7 @@ func isSafeDirectory(dir string) bool {
579579
}
580580

581581
// Check if it's in user's home directory (potentially unsafe)
582-
if homeDir := os.Getenv("HOME"); homeDir != "" && strings.HasPrefix(dir, homeDir) {
582+
if homeDir := os.Getenv("HOME"); homeDir != "" && strings.HasPrefix(dir, homeDir) {
583583
return false
584584
}
585585

0 commit comments

Comments
 (0)