Skip to content

Commit ffe48f3

Browse files
authored
fix: display log errors message when failing to authenticate (#20)
Co-authored-by: Ayoub Faouzi <ayoubfaouzi@users.noreply.github.com>
1 parent 623c215 commit ffe48f3

5 files changed

Lines changed: 41 additions & 11 deletions

File tree

README.md

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ Available Commands:
3434
init Configure saferwall CLI credentials
3535
scan Upload and scan files
3636
rescan Rescan an existing file using its hash
37+
view View scan results for a file by its SHA256 hash
3738
download Download a sample (and its artifacts)
3839
souk Populate malware-souk database
3940
version Version number
@@ -44,9 +45,30 @@ Available Commands:
4445
Upload and scan files. Supports scanning a single file or an entire directory.
4546

4647
```sh
47-
saferwall-cli scan -p /path/to/sample
48+
# Scan a single file
49+
saferwall-cli scan /path/to/sample
50+
51+
# Scan an entire directory
52+
saferwall-cli scan /path/to/directory
53+
54+
# Scan with parallel uploads
55+
saferwall-cli scan -p 4 /path/to/directory
56+
57+
# Force rescan if the file already exists
58+
saferwall-cli scan -f /path/to/sample
59+
60+
# Enable detonation with custom timeout and OS
61+
saferwall-cli scan -d -t 30 -o win-7 /path/to/sample
4862
```
4963

64+
| Flag | Short | Default | Description |
65+
|------|-------|---------|-------------|
66+
| `--force` | `-f` | `false` | Force rescan if the file already exists |
67+
| `--parallel` | `-p` | `1` | Number of files to scan in parallel |
68+
| `--enableDetonation` | `-d` | `false` | Enable detonation (dynamic analysis) |
69+
| `--timeout` | `-t` | `15` | Detonation duration in seconds |
70+
| `--os` | `-o` | `win-10` | Preferred OS for detonation (`win-7` or `win-10`) |
71+
5072
### Rescan
5173

5274
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
5577
saferwall-cli rescan <sha256>
5678
```
5779

80+
### View
81+
82+
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.
83+
84+
```sh
85+
saferwall-cli view <sha256>
86+
```
87+
5888
### Download
5989

6090
Download a sample by its SHA256 hash, or provide a text file with one hash per line to download in batch.

cmd/download.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ var downloadCmd = &cobra.Command{
4646
webSvc := webapi.New(cfg.Credentials.URL)
4747
token, err := webSvc.Login(cfg.Credentials.Username, cfg.Credentials.Password)
4848
if err != nil {
49-
log.Fatalf("failed to login to saferwall web service")
49+
log.Fatalf("failed to authenticate: %v", err)
5050
}
5151

5252
hashes := collectHashes(arg)

cmd/rescan.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ var reScanCmd = &cobra.Command{
5050
webSvc := webapi.New(cfg.Credentials.URL)
5151
token, err := webSvc.Login(cfg.Credentials.Username, cfg.Credentials.Password)
5252
if err != nil {
53-
log.Fatalf("failed to login to saferwall web service")
53+
log.Fatalf("failed to authenticate: %v", err)
5454
}
5555

5656
arg := args[0]

cmd/scan.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ var scanCmd = &cobra.Command{
119119
webSvc := webapi.New(cfg.Credentials.URL)
120120
token, err := webSvc.Login(cfg.Credentials.Username, cfg.Credentials.Password)
121121
if err != nil {
122-
log.Fatalf("failed to login to saferwall web service")
122+
log.Fatalf("failed to authenticate: %v", err)
123123
}
124124

125125
scanFile(webSvc, args[0], token)

cmd/view.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ var viewCmd = &cobra.Command{
2828
webSvc := webapi.New(cfg.Credentials.URL)
2929
_, err := webSvc.Login(cfg.Credentials.Username, cfg.Credentials.Password)
3030
if err != nil {
31-
log.Fatalf("failed to login: %v", err)
31+
log.Fatalf("failed to authenticate: %v", err)
3232
}
3333

3434
var file entity.File
@@ -46,12 +46,12 @@ func init() {
4646

4747
// Styles for the report output.
4848
var (
49-
titleStyle = lipgloss.NewStyle().Bold(true).Foreground(lipgloss.Color("12"))
50-
headerStyle = lipgloss.NewStyle().Bold(true).Foreground(lipgloss.Color("14"))
51-
keyStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("8"))
52-
detectStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("1"))
53-
cleanStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("2"))
54-
avNameStyle = lipgloss.NewStyle().Width(24)
49+
titleStyle = lipgloss.NewStyle().Bold(true).Foreground(lipgloss.Color("12"))
50+
headerStyle = lipgloss.NewStyle().Bold(true).Foreground(lipgloss.Color("14"))
51+
keyStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("8"))
52+
detectStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("1"))
53+
cleanStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("2"))
54+
avNameStyle = lipgloss.NewStyle().Width(24)
5555
)
5656

5757
func printFileReport(file entity.File, webSvc webapi.Service) {

0 commit comments

Comments
 (0)