From 9bb760474a9f679ae98f069c670cd0e93add826e Mon Sep 17 00:00:00 2001 From: Ayoub Faouzi Date: Sun, 5 Apr 2026 08:33:19 +0100 Subject: [PATCH] fix logging error message --- README.md | 32 +++++++++++++++++++++++++++++++- cmd/download.go | 2 +- cmd/rescan.go | 2 +- cmd/scan.go | 2 +- cmd/view.go | 14 +++++++------- 5 files changed, 41 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index dd67d8d..0520264 100755 --- a/README.md +++ b/README.md @@ -34,6 +34,7 @@ Available Commands: init Configure saferwall CLI credentials scan Upload and scan files rescan Rescan an existing file using its hash + view View scan results for a file by its SHA256 hash download Download a sample (and its artifacts) souk Populate malware-souk database version Version number @@ -44,9 +45,30 @@ Available Commands: Upload and scan files. Supports scanning a single file or an entire directory. ```sh -saferwall-cli scan -p /path/to/sample +# Scan a single file +saferwall-cli scan /path/to/sample + +# Scan an entire directory +saferwall-cli scan /path/to/directory + +# Scan with parallel uploads +saferwall-cli scan -p 4 /path/to/directory + +# Force rescan if the file already exists +saferwall-cli scan -f /path/to/sample + +# Enable detonation with custom timeout and OS +saferwall-cli scan -d -t 30 -o win-7 /path/to/sample ``` +| Flag | Short | Default | Description | +|------|-------|---------|-------------| +| `--force` | `-f` | `false` | Force rescan if the file already exists | +| `--parallel` | `-p` | `1` | Number of files to scan in parallel | +| `--enableDetonation` | `-d` | `false` | Enable detonation (dynamic analysis) | +| `--timeout` | `-t` | `15` | Detonation duration in seconds | +| `--os` | `-o` | `win-10` | Preferred OS for detonation (`win-7` or `win-10`) | + ### Rescan Rescan an existing file by its SHA256 hash, or rescan a batch of hashes from a text file. @@ -55,6 +77,14 @@ Rescan an existing file by its SHA256 hash, or rescan a batch of hashes from a t saferwall-cli rescan ``` +### View + +View scan results for a file by its SHA256 hash. Displays file identification (hashes, size), properties (format, packer, timestamps), classification verdict, and antivirus detection results. For archive files, it shows a summary table of all contained files. + +```sh +saferwall-cli view +``` + ### Download Download a sample by its SHA256 hash, or provide a text file with one hash per line to download in batch. diff --git a/cmd/download.go b/cmd/download.go index f0af104..6a15c77 100644 --- a/cmd/download.go +++ b/cmd/download.go @@ -46,7 +46,7 @@ var downloadCmd = &cobra.Command{ webSvc := webapi.New(cfg.Credentials.URL) token, err := webSvc.Login(cfg.Credentials.Username, cfg.Credentials.Password) if err != nil { - log.Fatalf("failed to login to saferwall web service") + log.Fatalf("failed to authenticate: %v", err) } hashes := collectHashes(arg) diff --git a/cmd/rescan.go b/cmd/rescan.go index e9c0554..a9d28fb 100644 --- a/cmd/rescan.go +++ b/cmd/rescan.go @@ -50,7 +50,7 @@ var reScanCmd = &cobra.Command{ webSvc := webapi.New(cfg.Credentials.URL) token, err := webSvc.Login(cfg.Credentials.Username, cfg.Credentials.Password) if err != nil { - log.Fatalf("failed to login to saferwall web service") + log.Fatalf("failed to authenticate: %v", err) } arg := args[0] diff --git a/cmd/scan.go b/cmd/scan.go index 7b2b4a3..97ba6d8 100644 --- a/cmd/scan.go +++ b/cmd/scan.go @@ -119,7 +119,7 @@ var scanCmd = &cobra.Command{ webSvc := webapi.New(cfg.Credentials.URL) token, err := webSvc.Login(cfg.Credentials.Username, cfg.Credentials.Password) if err != nil { - log.Fatalf("failed to login to saferwall web service") + log.Fatalf("failed to authenticate: %v", err) } scanFile(webSvc, args[0], token) diff --git a/cmd/view.go b/cmd/view.go index 33788cd..ef8c009 100644 --- a/cmd/view.go +++ b/cmd/view.go @@ -28,7 +28,7 @@ var viewCmd = &cobra.Command{ webSvc := webapi.New(cfg.Credentials.URL) _, err := webSvc.Login(cfg.Credentials.Username, cfg.Credentials.Password) if err != nil { - log.Fatalf("failed to login: %v", err) + log.Fatalf("failed to authenticate: %v", err) } var file entity.File @@ -46,12 +46,12 @@ func init() { // Styles for the report output. var ( - titleStyle = lipgloss.NewStyle().Bold(true).Foreground(lipgloss.Color("12")) - headerStyle = lipgloss.NewStyle().Bold(true).Foreground(lipgloss.Color("14")) - keyStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("8")) - detectStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("1")) - cleanStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("2")) - avNameStyle = lipgloss.NewStyle().Width(24) + titleStyle = lipgloss.NewStyle().Bold(true).Foreground(lipgloss.Color("12")) + headerStyle = lipgloss.NewStyle().Bold(true).Foreground(lipgloss.Color("14")) + keyStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("8")) + detectStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("1")) + cleanStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("2")) + avNameStyle = lipgloss.NewStyle().Width(24) ) func printFileReport(file entity.File, webSvc webapi.Service) {