Skip to content

Commit deab1cd

Browse files
committed
flag(runtime): new flag format
1 parent e4492f4 commit deab1cd

File tree

22 files changed

+457
-54
lines changed

22 files changed

+457
-54
lines changed

cmd/tracee-ebpf/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,9 @@ func main() {
118118
Usage: "size, in event objects, of each pipeline stage's output channel",
119119
},
120120
&cli.StringFlag{
121-
Name: "install-path",
121+
Name: "runtime",
122122
Value: "/tmp/tracee",
123-
Usage: "path where tracee will install or lookup it's resources",
123+
Usage: "runtime config options eg: workdir",
124124
},
125125
&cli.StringSliceFlag{
126126
Name: server.ServerFlag,

cmd/tracee/cmd/root.go

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,19 @@ func initCmd() error {
115115
"[file|dir]\t\t\t\tPath to a policy or directory with policies",
116116
)
117117

118+
// Runtime flags
119+
120+
rootCmd.Flags().StringArrayP(
121+
"runtime",
122+
"r",
123+
[]string{"workdir=" + flags.WorkdirDefault},
124+
"[workdir=/tmp/tracee]\t\tControl runtime configurations",
125+
)
126+
err := viper.BindPFlag("runtime", rootCmd.Flags().Lookup("runtime"))
127+
if err != nil {
128+
return errfmt.WrapError(err)
129+
}
130+
118131
// Output flags
119132

120133
rootCmd.Flags().StringArrayP(
@@ -123,7 +136,7 @@ func initCmd() error {
123136
[]string{"table"},
124137
"[json|none|webhook...]\t\tControl how and where output is printed",
125138
)
126-
err := viper.BindPFlag("output", rootCmd.Flags().Lookup("output"))
139+
err = viper.BindPFlag("output", rootCmd.Flags().Lookup("output"))
127140
if err != nil {
128141
return errfmt.WrapError(err)
129142
}
@@ -268,16 +281,6 @@ func initCmd() error {
268281
return errfmt.WrapError(err)
269282
}
270283

271-
rootCmd.Flags().String(
272-
"install-path",
273-
"/tmp/tracee",
274-
"<dir>\t\t\t\tPath where tracee will install or lookup it's resources",
275-
)
276-
err = viper.BindPFlag("install-path", rootCmd.Flags().Lookup("install-path"))
277-
if err != nil {
278-
return errfmt.WrapError(err)
279-
}
280-
281284
rootCmd.Flags().StringArrayP(
282285
"log",
283286
"l",

deploy/helm/tracee/templates/tracee-config.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ data:
1818
pyroscope: {{ .Values.config.pyroscope }}
1919
listen-addr: {{ .Values.config.listenAddr }}
2020
{{- if .Values.config.installPath }}
21-
install-path: {{ .Values.config.installPath }}
21+
runtime:
22+
- workdir={{ .Values.config.installPath }}
2223
{{- end }}
2324
{{- if .Values.config.signaturesDir }}
2425
signatures-dir: {{ .Values.config.signaturesDir }}

docs/docs/flags/runtime.1.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
---
2+
title: TRACEE-RUNTIME
3+
section: 1
4+
header: Tracee Runtime Flag Manual
5+
date: 2025/01
6+
...
7+
8+
## NAME
9+
10+
tracee **\-\-runtime** - Control runtime configurations
11+
12+
## SYNOPSIS
13+
14+
tracee **\-\-runtime** [workdir=*path*] [**\-\-runtime** ...]
15+
16+
## DESCRIPTION
17+
18+
The **\-\-runtime** flag allows you to control runtime configurations for Tracee.
19+
20+
### Options
21+
22+
- **workdir**=*path*
23+
Set the working directory where Tracee stores temporary files and artifacts. The default value is `/tmp/tracee`.
24+
25+
Example:
26+
```console
27+
--runtime workdir=/tmp/tracee
28+
```
29+
30+
## EXAMPLES
31+
32+
1. Use the default working directory:
33+
```console
34+
--runtime workdir=/tmp/tracee
35+
```
36+
37+
2. Set a custom working directory:
38+
```console
39+
--runtime workdir=/var/lib/tracee
40+
```
41+
42+
3. Using the short form:
43+
```console
44+
-g workdir=/opt/tracee
45+
```
46+

docs/docs/install/config/index.md

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,16 +63,23 @@ A complete config file with all available options can be found [here](https://gi
6363
- process
6464
```
6565

66-
### Install Path
66+
### Runtime
6767

68-
- **`--install-path`**: Specifies the directory where Tracee will install or look for its resources. If not specified, the default installation directory is `/tmp/tracee`.
68+
- **`--runtime` (`-g`)**: Controls runtime configurations for Tracee.
69+
70+
CLI Examples:
71+
```bash
72+
# Set working directory
73+
tracee --runtime workdir=/opt/tracee
74+
```
6975

7076
YAML:
7177
```yaml
72-
install-path: /opt/tracee
78+
runtime:
79+
- workdir=/opt/tracee
7380
```
7481

75-
__NOTE__: This option is useful when running Tracee in environments where `/tmp` is not suitable or secure.
82+
__NOTE__: The working directory is where Tracee stores temporary files and artifacts. The default is `/tmp/tracee`. This option is useful when running Tracee in environments where `/tmp` is not suitable or secure.
7683

7784
### Log
7885

docs/docs/policies/usage/cli.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ tracee --config ./config.yaml --policy ./policy.yaml && cat /tmp/debug.json
3535
### config.yaml (example)
3636

3737
```yaml
38-
install-path: /tmp/tracee
38+
runtime:
39+
- workdir=/tmp/tracee
3940

4041
# server configuration
4142

docs/man/runtime.1

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
.\" Automatically generated by Pandoc 3.2
2+
.\"
3+
.TH "TRACEE\-RUNTIME" "1" "2025/01" "" "Tracee Runtime Flag Manual"
4+
.SS NAME
5+
tracee \f[B]\-\-runtime\f[R] \- Control runtime configurations
6+
.SS SYNOPSIS
7+
tracee \f[B]\-\-runtime\f[R] [workdir=\f[I]path\f[R]]
8+
[\f[B]\-\-runtime\f[R] \&...]
9+
.SS DESCRIPTION
10+
The \f[B]\-\-runtime\f[R] flag allows you to control runtime
11+
configurations for Tracee.
12+
.SS Options
13+
.IP \[bu] 2
14+
\f[B]workdir\f[R]=\f[I]path\f[R] Set the working directory where Tracee
15+
stores temporary files and artifacts.
16+
The default value is \f[CR]/tmp/tracee\f[R].
17+
.RS 2
18+
.PP
19+
Example:
20+
.IP
21+
.EX
22+
\-\-runtime workdir=/tmp/tracee
23+
.EE
24+
.RE
25+
.SS EXAMPLES
26+
.IP "1." 3
27+
Use the default working directory:
28+
.RS 4
29+
.IP
30+
.EX
31+
\-\-runtime workdir=/tmp/tracee
32+
.EE
33+
.RE
34+
.IP "2." 3
35+
Set a custom working directory:
36+
.RS 4
37+
.IP
38+
.EX
39+
\-\-runtime workdir=/var/lib/tracee
40+
.EE
41+
.RE
42+
.IP "3." 3
43+
Using the short form:
44+
.RS 4
45+
.IP
46+
.EX
47+
\-g workdir=/opt/tracee
48+
.EE
49+
.RE
50+

examples/config/global_config.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
"capabilities": [],
1010
"containers": [],
1111
"healthz": false,
12-
"install-path": "/tmp/tracee",
12+
"runtime": [
13+
"workdir=/tmp/tracee"
14+
],
1315
"listen-addr": ":3366",
1416
"log": [
1517
"info"

examples/config/global_config.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ events:
5555

5656
healthz: false
5757

58-
install-path: /tmp/tracee
58+
runtime:
59+
- workdir=/tmp/tracee
5960

6061
listen-addr: :3366
6162

pkg/cmd/cobra/cobra.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -316,9 +316,16 @@ func GetTraceeRunner(c *cobra.Command, version string) (cmd.Runner, error) {
316316
}
317317

318318
// Decide BTF & BPF files to use (based in the kconfig, release & environment info)
319+
runtimeFlags, err := GetFlagsFromViper("runtime")
320+
if err != nil {
321+
return runner, err
322+
}
323+
runtimeConfig, err := flags.PrepareRuntime(runtimeFlags)
324+
if err != nil {
325+
return runner, err
326+
}
319327

320-
traceeInstallPath := viper.GetString("install-path")
321-
err = initialize.BpfObject(&cfg, kernelConfig, osInfo, traceeInstallPath, version)
328+
err = initialize.BpfObject(&cfg, kernelConfig, osInfo, runtimeConfig.Workdir, version)
322329
if err != nil {
323330
return runner, errfmt.Errorf("failed preparing BPF object: %v", err)
324331
}
@@ -339,7 +346,7 @@ func GetTraceeRunner(c *cobra.Command, version string) (cmd.Runner, error) {
339346
cfg.MetricsEnabled = runner.HTTP.MetricsEndpointEnabled()
340347
runner.TraceeConfig = cfg
341348
runner.Printer = p
342-
runner.InstallPath = traceeInstallPath
349+
runner.Workdir = runtimeConfig.Workdir
343350

344351
noSignaturesMode := viper.GetBool("no-signatures")
345352
if noSignaturesMode {

0 commit comments

Comments
 (0)