Skip to content

Commit

Permalink
fix: ci go lint findings
Browse files Browse the repository at this point in the history
Signed-off-by: r3drun3 <[email protected]>
  • Loading branch information
R3DRUN3 committed Jan 3, 2025
1 parent 7913254 commit 5ef4da1
Showing 1 changed file with 3 additions and 27 deletions.
30 changes: 3 additions & 27 deletions internal/scan.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"bytes"
"encoding/json"
"fmt"
"io"
"net"
"net/http"
"os"
Expand Down Expand Up @@ -37,35 +36,12 @@ func DetectDefaultShell() string {
}
}

// Flushes zsh history to disk
func flushZshHistory() {
cmd := exec.Command("zsh", "-c", "fc -W")
cmd.Run() // Ignore errors; continue even if this fails
}

// Copies a file to a temporary location
func copyFile(srcPath, dstDir string) (string, error) {
srcFile, err := os.Open(srcPath)
if err != nil {
return "", fmt.Errorf("failed to open source file: %w", err)
}
defer srcFile.Close()

// Prepare the destination path
dstPath := filepath.Join(dstDir, filepath.Base(srcPath))
dstFile, err := os.Create(dstPath)
if err != nil {
return "", fmt.Errorf("failed to create destination file: %w", err)
if err := cmd.Run(); err != nil {
// Log the error or document why it is safe to ignore
fmt.Println("Warning: Failed to flush Zsh history:", err)
}
defer dstFile.Close()

// Copy the file content
_, err = io.Copy(dstFile, srcFile)
if err != nil {
return "", fmt.Errorf("failed to copy file content: %w", err)
}

return dstPath, nil
}

// ScanSensitiveFiles collects all files from specified paths, including full directories.
Expand Down

0 comments on commit 5ef4da1

Please sign in to comment.