You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Adding csv output creating report and details csv files (#16)
* adding csv output creating report and details csv files
*proper csv format split from file output system + some facorization
* factorized and reordered for more logical reding of the code
* updated readme with format and saving instructions
---------
Co-authored-by: Kevin KADOSH <kevin@crowdsec.net>
Co-authored-by: jdv <julien@crowdsec.net>
Copy file name to clipboardExpand all lines: README.md
+66-30Lines changed: 66 additions & 30 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,36 +15,41 @@ Your ultimate IP dex!
15
15
16
16
## Table of Contents
17
17
18
-
-[Introduction](#introduction)
19
-
-[Prerequisites](#prerequisites)
20
-
-[Quickstart](#quickstart)
21
-
-[Install](#1-install)
22
-
-[Make sure the binary is in your PATH](#2-make-sure-the-binary-is-in-your-path)
23
-
-[Initialize the tool](#3-initialize-the-tool)
24
-
-[Query an IP](#4-query-an-ip)
25
-
-[Scan a file](#5-scan-a-file)
26
-
-[Configuration](#configuration)
27
-
-[User Guide](#user-guide)
28
-
-[Scan an IP](#scan-an-ip)
29
-
-[Refresh an IP](#refresh-an-ip)
30
-
-[Scan a file](#scan-a-file-1)
31
-
-[Refresh a file](#refresh-a-file)
32
-
-[Display all reports](#display-all-reports)
33
-
-[Showing a specific report](#showing-a-specific-report)
34
-
-[Commands](#commands)
35
-
-[`init`](#init)
36
-
-[`report`](#report)
37
-
-[List reports](#list-reports)
38
-
-[View a report](#view-a-report)
39
-
-[Delete a report](#delete-a-report)
40
-
-[`search`](#search)
41
-
-[Search IPs reported for a specific CVE](#search-ips-reported-for-a-specific-cve)
42
-
-[Search IPs reported for HTTP scan since 30 minutes](#search-ips-reported-for-http-scan-since-30-minutes)
43
-
-[Search malicious VPN or Proxy IPs since 1h and show all IPs](#search-malicious-vpn-or-proxy-ips-since-1h-and-show-all-ips)
44
-
-[`config`](#config)
45
-
-[Show config](#show-config)
46
-
-[Set a new API Key](#set-a-new-api-key)
47
-
-[License](#license)
18
+
-[ipdex](#ipdex)
19
+
-[Table of Contents](#table-of-contents)
20
+
-[Introduction](#introduction)
21
+
-[Prerequisites](#prerequisites)
22
+
-[Quickstart](#quickstart)
23
+
-[1. Install](#1-install)
24
+
-[Install with Go](#install-with-go)
25
+
-[macOS / Linux](#macos--linux)
26
+
-[Linux](#linux)
27
+
-[macOS](#macos)
28
+
-[Windows](#windows)
29
+
-[2. Make sure the binary is in your PATH](#2-make-sure-the-binary-is-in-your-path)
30
+
-[3. Initialize the tool](#3-initialize-the-tool)
31
+
-[4. Query an IP](#4-query-an-ip)
32
+
-[5. Scan a file](#5-scan-a-file)
33
+
-[Configuration](#configuration)
34
+
-[User Guide](#user-guide)
35
+
-[Scan an IP](#scan-an-ip)
36
+
-[Refresh an IP](#refresh-an-ip)
37
+
-[Scan a file](#scan-a-file)
38
+
-[Refresh a file](#refresh-a-file)
39
+
-[Output formats](#output-formats)
40
+
-[Saving reports to files](#saving-reports-to-files)
41
+
-[`report`](#report)
42
+
-[List reports](#list-reports)
43
+
-[View a report](#view-a-report)
44
+
-[Delete a report](#delete-a-report)
45
+
-[`search`](#search)
46
+
-[Search IPs reported for a specific CVE](#search-ips-reported-for-a-specific-cve)
47
+
-[Search IPs reported for HTTP scan since 30 minutes](#search-ips-reported-for-http-scan-since-30-minutes)
48
+
-[Search malicious VPN or Proxy IPs since 1h and show all IPs](#search-malicious-vpn-or-proxy-ips-since-1h-and-show-all-ips)
49
+
-[`config`](#config)
50
+
-[Show config](#show-config)
51
+
-[Set a new API Key](#set-a-new-api-key)
52
+
-[License](#license)
48
53
49
54
---
50
55
@@ -162,6 +167,8 @@ ipdex /var/log/nginx.log
162
167
163
168
<palign="center"> <imgsrc="img/ipdex_file.svg"alt="ipdex scanning a file"width="900" /> </p>
164
169
170
+
**💡 Tip:** You can output results in different formats (`-o json`, `-o csv`) and save them to files using `--output-path`. See [Output formats](#output-formats) and [Saving reports to files](#saving-reports-to-files) for more details.
171
+
165
172
---
166
173
167
174
## Configuration
@@ -202,6 +209,31 @@ When running ipdex on a file that has been previously scanned, it will update th
202
209
ipdex <filepath> -r
203
210
```
204
211
212
+
### Output formats
213
+
214
+
ipdex supports multiple output formats to suit different use cases using the -o option:
215
+
216
+
-**human** (default): Interactive, colorized output optimized for terminal viewing
217
+
-**json**: `-o json` Machine-readable JSON format for programmatic processing
218
+
-**csv**: `-o csv` Comma-separated values format for spreadsheet analysis
219
+
220
+
### Saving reports to files
221
+
222
+
You can save reports to disk using the `--output-path` flag. This works with all output formats and automatically creates separate files for the report summary and the detailed IP information (if you used the -d option).
Copy file name to clipboardExpand all lines: cmd/ipdex/main.go
+2-1Lines changed: 2 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -75,7 +75,8 @@ func init() {
75
75
rootCmd.Flags().BoolVarP(&config.ForceRefresh, "refresh", "r", false, "Force refresh an IP or all the IPs of a report")
76
76
rootCmd.Flags().BoolVarP(&config.Yes, "yes", "y", false, "Say automatically yes to the warning about the number of IPs to scan")
77
77
rootCmd.PersistentFlags().BoolVarP(&config.Detailed, "detailed", "d", false, "Show all informations about an IP or a report")
78
-
rootCmd.PersistentFlags().StringVarP(&config.OutputFormat, "output", "o", "", "Output format: human or json")
78
+
rootCmd.PersistentFlags().StringVarP(&config.OutputFormat, "output", "o", "", "Output format: human, json, or csv")
79
+
rootCmd.PersistentFlags().StringVar(&config.OutputFilePath, "output-path", "", "Output file path for saving reports in the format specified by -o (saves report and details files separately)")
79
80
rootCmd.Flags().StringVarP(&config.ReportName, "name", "n", "", "Report name when scanning a file or making a search query")
80
81
rootCmd.Flags().BoolVarP(&config.Batching, "batch", "b", false, "Use batching to request the CrowdSec API. Make sure you have a premium API key to use this feature.")
0 commit comments