Skip to content

Commit 3356710

Browse files
committed
cli!: improve flag shorthands and fix outdated docs
Add intuitive shorthands for frequently used flags: - --artifacts: add -a shorthand (was -c) - --config: add -c shorthand (follows common CLI convention) Fix documentation references to deprecated --capture flag, replacing all instances with --artifacts. BREAKING CHANGE: The --artifacts flag now uses -a instead of -c.
1 parent 6d2040e commit 3356710

4 files changed

Lines changed: 38 additions & 41 deletions

File tree

cmd/tracee/cmd/man.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ var capabilitiesCmd = &cobra.Command{
103103

104104
var artifactsCmd = &cobra.Command{
105105
Use: "artifacts",
106-
Aliases: []string{"c"},
106+
Aliases: []string{"a"},
107107
Short: "Show manual page for the --artifacts flag",
108108
RunE: func(cmd *cobra.Command, args []string) error {
109109
return runManForFlag("artifacts")
@@ -112,7 +112,7 @@ var artifactsCmd = &cobra.Command{
112112

113113
var configCmd = &cobra.Command{
114114
Use: "config",
115-
Aliases: []string{},
115+
Aliases: []string{"c"},
116116
Short: "Show manual page for the --config flag",
117117
RunE: func(cmd *cobra.Command, args []string) error {
118118
return runManForFlag("config")

cmd/tracee/cmd/root.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ func initCmd() error {
143143
// artifacts is bound to viper
144144
rootCmd.Flags().StringArrayP(
145145
flags.ArtifactsFlag,
146-
"c",
146+
"a",
147147
[]string{},
148148
"[file-write|executable...]\t\tCapture artifacts that were written, executed or found to be suspicious",
149149
)
@@ -155,9 +155,10 @@ func initCmd() error {
155155
// Config flag
156156

157157
// config is not bound to viper
158-
rootCmd.Flags().StringVar(
158+
rootCmd.Flags().StringVarP(
159159
&cfgFileFlag,
160160
"config",
161+
"c",
161162
"",
162163
"<file>\t\t\t\tGlobal config file (yaml, json between others - see documentation)",
163164
)

docs/docs/forensics.md

Lines changed: 31 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
# Getting Started with Forensics
22

33
Tracee has a unique feature that lets you capture interesting artifacts from
4-
running applications, using the `--capture` flag.
4+
running applications, using the `--artifacts` flag.
55

66
```console
7-
./dist/tracee man capture
7+
./dist/tracee man artifacts
88
```
99

1010
```console
11-
sudo ./dist/tracee --capture xxx
11+
sudo ./dist/tracee --artifacts xxx
1212
```
1313

1414
!!! Tip
1515
All captured artifacts are saved in Tracee's "output directory", which can
16-
be configured using `--capture dir:/path/to/dir`. You may also use
17-
`--capture clear-dir` if you want contents of the destination directory
16+
be configured using `--artifacts dir.path=/path/to/dir`. You may also use
17+
`--artifacts dir.clear` if you want contents of the destination directory
1818
to be cleared every time you execute tracee.
1919

2020
## Artifacts Types
@@ -37,13 +37,9 @@ Tracee can capture the following types of artifacts:
3737
--scope comm=bash \
3838
--scope follow \
3939
--output option:parse-arguments \
40-
--capture dir:/tmp/tracee/ \
41-
--capture write='/tmp/*'
40+
--artifacts dir.path=/tmp/tracee \
41+
--artifacts file-write.filters=path=/tmp/*
4242
```
43-
44-
!!! Note
45-
Using file capture without filter name will be path by default. Hence,
46-
`--capture write='/tmp/*` is the same as `--capture write:path='/tmp/*`.
4743

4844
```console
4945
echo write testing 123 > /tmp/testing.txt
@@ -72,9 +68,9 @@ Tracee can capture the following types of artifacts:
7268
--scope comm=bash \
7369
--scope follow \
7470
--output option:parse-arguments \
75-
--capture dir:/tmp/tracee/ \
76-
--capture read:type=pipe \
77-
--capture read:fd=stdin'
71+
--artifacts dir.path=/tmp/tracee \
72+
--artifacts file-read.filters=type=pipe \
73+
--artifacts file-read.filters=fd=stdin
7874
```
7975

8076
```console
@@ -107,8 +103,8 @@ Tracee can capture the following types of artifacts:
107103
--scope comm=bash \
108104
--scope follow \
109105
--output option:parse-arguments \
110-
--capture dir:/tmp/tracee/ \
111-
--capture exec
106+
--artifacts dir.path=/tmp/tracee \
107+
--artifacts executable
112108
```
113109

114110
```console
@@ -161,8 +157,8 @@ Tracee can capture the following types of artifacts:
161157
--output none \
162158
--scope comm=bash \
163159
--scope follow \
164-
--capture dir:/tmp/tracee/ \
165-
--capture mem
160+
--artifacts dir.path=/tmp/tracee \
161+
--artifacts memory-regions
166162
```
167163

168164
!!! Note
@@ -178,8 +174,8 @@ Tracee can capture the following types of artifacts:
178174
The default behavior when capturing network traffic is to capture
179175
ALL traffic, despite given event filters. If you want to make
180176
capture feature to follow the given event filters, like for example
181-
capturing DNS events only, then you have to provide `--capture
182-
pcap-options:filtered` argument in the command line. Then only
177+
capturing DNS events only, then you have to provide `--artifacts
178+
network.pcap.options=filtered` argument in the command line. Then only
183179
net_packet_XXX events will be captured (IPv4, IPv6, TCP, UDP,
184180
ICMP, ICMPv6, DNS, HTTP, etc).
185181

@@ -188,8 +184,8 @@ Tracee can capture the following types of artifacts:
188184
```console
189185
sudo ./dist/tracee \
190186
--events net_packet_ipv4 \
191-
--capture network \
192-
--capture pcap-options:filtered
187+
--artifacts network \
188+
--artifacts network.pcap.options=filtered
193189
```
194190

195191
and observe a single **pcap file** for all ipv4 packets created:
@@ -208,8 +204,8 @@ Tracee can capture the following types of artifacts:
208204
```console
209205
sudo ./dist/tracee \
210206
--events net_packet_dns \
211-
--capture network \
212-
--capture pcap-options:filtered
207+
--artifacts network \
208+
--artifacts network.pcap.options=filtered
213209
```
214210

215211
and the file `/tmp/tracee/out/pcap/single.pcap` would only contain DNS
@@ -250,9 +246,9 @@ Tracee can capture the following types of artifacts:
250246
```console
251247
sudo ./dist/tracee \
252248
--events net_packet_icmp \
253-
--capture network \
254-
--capture pcap-options:filtered \
255-
--capture pcap:process,container,command
249+
--artifacts network \
250+
--artifacts network.pcap.options=filtered \
251+
--artifacts network.pcap.split=process,container,command
256252
```
257253

258254
```console
@@ -349,10 +345,10 @@ Tracee can capture the following types of artifacts:
349345
```console
350346
sudo ./dist/tracee \
351347
--events net_packet_tcp \
352-
--capture network \
353-
--capture pcap-options:filtered \
354-
--capture pcap:single,command \
355-
--capture pcap-snaplen:default
348+
--artifacts network \
349+
--artifacts network.pcap.options=filtered \
350+
--artifacts network.pcap.split=single,command \
351+
--artifacts network.pcap.snaplen=default
356352
```
357353

358354
To capture packet headers + 96 bytes of payload. Or replace `default` by:
@@ -375,8 +371,8 @@ Tracee can capture the following types of artifacts:
375371
--output none \
376372
--scope comm=bash \
377373
--scope follow \
378-
--capture clear-dir \
379-
--capture module
374+
--artifacts dir.clear \
375+
--artifacts kernel-modules
380376
```
381377

382378
Captured module will be found in tracee destination directory, just like
@@ -428,8 +424,8 @@ Tracee can capture the following types of artifacts:
428424
--output none \
429425
--scope comm=bash \
430426
--scope follow \
431-
--capture clear-dir \
432-
--capture bpf
427+
--artifacts dir.clear \
428+
--artifacts bpf-programs
433429
```
434430

435431
Captured bpf bytecode will be found in tracee destination directory, just like

tests/integration/capture_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,9 @@ func Test_TraceeCapture(t *testing.T) {
8181
for _, tc := range tt {
8282
t.Run(tc.name, func(t *testing.T) {
8383
coolDown(t, tc.coolDown)
84-
cmd := fmt.Sprintf("--events init_namespaces -c dir:%s", tc.directory)
84+
cmd := fmt.Sprintf("--events init_namespaces -a dir:%s", tc.directory)
8585
for _, filter := range tc.captureFilters {
86-
cmd = fmt.Sprintf("%s -c %s", cmd, filter)
86+
cmd = fmt.Sprintf("%s -a %s", cmd, filter)
8787
}
8888
running := testutils.NewRunningTracee(context.Background(), cmd)
8989

0 commit comments

Comments
 (0)