Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[v0.22.0] feat(time)!: epoch timestamps as standard #4507

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion builder/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ run_tracee() {
--capabilities drop=$CAPABILITIES_DROP \
--output=json \
--output=option:parse-arguments \
--output=option:relative-time \
--events signatures,container_create,container_remove
fi

Expand Down
1 change: 0 additions & 1 deletion deploy/helm/tracee/templates/tracee-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ data:
parse-arguments: {{ .Values.config.output.options.parseArguments }}
stack-addresses: {{ .Values.config.output.options.stackAddresses }}
exec-env: {{ .Values.config.output.options.execEnv }}
relative-time: {{ .Values.config.output.options.relativeTime }}
exec-hash: {{ .Values.config.output.options.execHash }}
sort-events: {{ .Values.config.output.options.sortEvents }}
{{- with .Values.config.output.webhook }}
Expand Down
1 change: 0 additions & 1 deletion deploy/helm/tracee/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ config:
parseArguments: true
stackAddresses: false
execEnv: false
relativeTime: true
execHash: dev-inode
sortEvents: false
# uncomment config.output.webhook to enable a single webhook
Expand Down
1 change: 0 additions & 1 deletion deploy/kubernetes/tracee/tracee.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ data:
parse-arguments: true
stack-addresses: false
exec-env: false
relative-time: true
exec-hash: dev-inode
sort-events: false
---
Expand Down
5 changes: 2 additions & 3 deletions docs/docs/flags/output.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ tracee **\-\-output** - Control how and where output is printed

## SYNOPSIS

tracee **\-\-output** <format[:file,...]\> | gotemplate=template[:file,...] | forward:url | webhook:url | option:{stack-addresses,exec-env,relative-time,exec-hash[={inode,dev-inode,digest-inode}],parse-arguments,parse-arguments-fds,sort-events} ...
tracee **\-\-output** <format[:file,...]\> | gotemplate=template[:file,...] | forward:url | webhook:url | option:{stack-addresses,exec-env,exec-hash[={inode,dev-inode,digest-inode}],parse-arguments,parse-arguments-fds,sort-events} ...


## DESCRIPTION
Expand Down Expand Up @@ -40,11 +40,10 @@ Webhook options:

Other options:

- **option:{stack-addresses,exec-env,relative-time,exec-hash,parse-arguments,sort-events}**: Augment output according to the given options. The default is none. Multiple options can be specified, separated by commas.
- **option:{stack-addresses,exec-env,exec-hash,parse-arguments,sort-events}**: Augment output according to the given options. The default is none. Multiple options can be specified, separated by commas.

- **stack-addresses**: Include stack memory addresses for each event.
- **exec-env**: When tracing execve/execveat, show the environment variables that were used for execution.
- **relative-time**: Use relative timestamp instead of wall timestamp for events.
- **exec-hash**: When tracing some file related events, show the file hash (sha256).
- Affected events: *sched_process_exec*, *shared_object_loaded*
- **inode** option recalculates the file hash if the inode's creation time (ctime) differs, which can occur in different namespaces even for identical inode. This option is performant, but not recommended and should only be used if container enrichment can't be enabled for digest-inode, and if performance is preferred over correctness.
Expand Down
1 change: 0 additions & 1 deletion docs/docs/install/config/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ output:
none: false
stack-addresses: true
exec-env: false
relative-time: true
exec-hash: dev-inode
parse-arguments: true
sort-events: false
Expand Down
12 changes: 1 addition & 11 deletions docs/docs/outputs/output-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,7 @@ Available options:
exec-hash: dev-inode
```

5. **relative-time**

The `relative-time` output option enables relative timestamp instead of wall timestamp for events.

```
output:
options:
relative-time: true
```

6. **sort-events**
5. **sort-events**

This makes it possible to sort the events as they happened. Especially in systems where Tracee tracks lots of events, it can happen that they are received unordered. More information is provided in the [deep-dive](../deep-dive/ordering-events.md) section of the documentation.

Expand Down
1 change: 0 additions & 1 deletion docs/docs/policies/usage/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ output:
none: false
stack-addresses: false
exec-env: true
relative-time: true
exec-hash: dev-inode
parse-arguments: true
parse-arguments-fds: true
Expand Down
7 changes: 2 additions & 5 deletions docs/man/output.1
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ tracee \f[B]\-\-output\f[R] \- Control how and where output is printed
tracee \f[B]\-\-output\f[R] <format[:file,\&...]> |
gotemplate=template[:file,\&...]
| forward:url | webhook:url |
option:{stack\-addresses,exec\-env,relative\-time,exec\-hash[={inode,dev\-inode,digest\-inode}],parse\-arguments,parse\-arguments\-fds,sort\-events}
option:{stack\-addresses,exec\-env,exec\-hash[={inode,dev\-inode,digest\-inode}],parse\-arguments,parse\-arguments\-fds,sort\-events}
\&...
.SS DESCRIPTION
The \f[B]\-\-output\f[R] flag allows you to control how and where the
Expand Down Expand Up @@ -49,7 +49,7 @@ webhook URL.
.PP
Other options:
.IP \[bu] 2
\f[B]option:{stack\-addresses,exec\-env,relative\-time,exec\-hash,parse\-arguments,sort\-events}\f[R]:
\f[B]option:{stack\-addresses,exec\-env,exec\-hash,parse\-arguments,sort\-events}\f[R]:
Augment output according to the given options.
The default is none.
Multiple options can be specified, separated by commas.
Expand All @@ -61,9 +61,6 @@ event.
\f[B]exec\-env\f[R]: When tracing execve/execveat, show the environment
variables that were used for execution.
.IP \[bu] 2
\f[B]relative\-time\f[R]: Use relative timestamp instead of wall
timestamp for events.
.IP \[bu] 2
\f[B]exec\-hash\f[R]: When tracing some file related events, show the
file hash (sha256).
.RS 2
Expand Down
1 change: 0 additions & 1 deletion examples/config/global_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ output:
# none: false
# stack-addresses: true
# exec-env: false
# relative-time: true
# exec-hash: dev-inode
# parse-arguments: true
# sort-events: false
Expand Down
4 changes: 0 additions & 4 deletions pkg/cmd/cobra/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -395,9 +395,6 @@ func (c *OutputConfig) flags() []string {
if c.Options.ExecEnv {
flags = append(flags, "option:exec-env")
}
if c.Options.RelativeTime {
flags = append(flags, "option:relative-time")
}
if c.Options.ExecHash != "" {
flags = append(flags, fmt.Sprintf("option:exec-hash=%s", c.Options.ExecHash))
}
Expand Down Expand Up @@ -478,7 +475,6 @@ type OutputOptsConfig struct {
None bool `mapstructure:"none"`
StackAddresses bool `mapstructure:"stack-addresses"`
ExecEnv bool `mapstructure:"exec-env"`
RelativeTime bool `mapstructure:"relative-time"`
ExecHash string `mapstructure:"exec-hash"`
ParseArguments bool `mapstructure:"parse-arguments"`
ParseArgumentsFDs bool `mapstructure:"parse-arguments-fds"`
Expand Down
6 changes: 0 additions & 6 deletions pkg/cmd/cobra/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,6 @@ output:
- none
- option:stack-addresses
- option:exec-env
- option:relative-time
- option:exec-hash=dev-inode
- option:parse-arguments
- option:parse-arguments-fds
Expand All @@ -295,7 +294,6 @@ output:
"none",
"option:stack-addresses",
"option:exec-env",
"option:relative-time",
"option:exec-hash=dev-inode",
"option:parse-arguments",
"option:parse-arguments-fds",
Expand All @@ -313,7 +311,6 @@ output:
none: false
stack-addresses: true
exec-env: true
relative-time: true
exec-hash: dev-inode
parse-arguments: true
parse-arguments-fds: true
Expand Down Expand Up @@ -367,7 +364,6 @@ output:
expectedFlags: []string{
"option:stack-addresses",
"option:exec-env",
"option:relative-time",
"option:exec-hash=dev-inode",
"option:parse-arguments",
"option:parse-arguments-fds",
Expand Down Expand Up @@ -983,7 +979,6 @@ func TestOutputConfigFlags(t *testing.T) {
None: true,
StackAddresses: true,
ExecEnv: true,
RelativeTime: true,
ExecHash: "dev-inode",
ParseArguments: true,
ParseArgumentsFDs: true,
Expand All @@ -994,7 +989,6 @@ func TestOutputConfigFlags(t *testing.T) {
"none",
"option:stack-addresses",
"option:exec-env",
"option:relative-time",
"option:exec-hash=dev-inode",
"option:parse-arguments",
"option:parse-arguments-fds",
Expand Down
9 changes: 3 additions & 6 deletions pkg/cmd/flags/output.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,6 @@ func setOption(cfg *config.OutputConfig, option string, newBinary bool) error {
cfg.StackAddresses = true
case "exec-env":
cfg.ExecEnv = true
case "relative-time":
cfg.RelativeTime = true
case "parse-arguments":
cfg.ParseArguments = true
case "parse-arguments-fds":
Expand Down Expand Up @@ -175,10 +173,9 @@ func getPrinterConfigs(printerMap map[string]string, traceeConfig *config.Output
}

printerConfigs = append(printerConfigs, config.PrinterConfig{
Kind: printerKind,
OutPath: outPath,
OutFile: outFile,
RelativeTS: traceeConfig.RelativeTime,
Kind: printerKind,
OutPath: outPath,
OutFile: outFile,
})
}

Expand Down
17 changes: 1 addition & 16 deletions pkg/cmd/flags/output_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -282,18 +282,6 @@ func TestPrepareOutput(t *testing.T) {
},
},
},
{
testName: "option relative-time",
outputSlice: []string{"json", "option:relative-time"},
expectedOutput: PrepareOutputResult{
PrinterConfigs: []config.PrinterConfig{
{Kind: "json", OutPath: "stdout", RelativeTS: true},
},
TraceeConfig: &config.OutputConfig{
RelativeTime: true,
},
},
},
{
testName: "option exec-hash",
outputSlice: []string{"option:exec-hash"},
Expand Down Expand Up @@ -374,20 +362,18 @@ func TestPrepareOutput(t *testing.T) {
"json",
"option:stack-addresses",
"option:exec-env",
"option:relative-time",
"option:exec-hash=dev-inode",
"option:parse-arguments",
"option:parse-arguments-fds",
"option:sort-events",
},
expectedOutput: PrepareOutputResult{
PrinterConfigs: []config.PrinterConfig{
{Kind: "json", OutPath: "stdout", RelativeTS: true},
{Kind: "json", OutPath: "stdout"},
},
TraceeConfig: &config.OutputConfig{
StackAddresses: true,
ExecEnv: true,
RelativeTime: true,
CalcHashes: config.CalcHashesDevInode,
ParseArguments: true,
ParseArgumentsFDs: true,
Expand Down Expand Up @@ -437,7 +423,6 @@ func assertPrinterConfigs(t *testing.T, expected []config.PrinterConfig, actual

assert.Equal(t, expectedPrinter.Kind, p.Kind)
assert.Equal(t, expectedPrinter.OutPath, p.OutPath)
assert.Equal(t, expectedPrinter.RelativeTS, p.RelativeTS)
assert.Equal(t, expectedPrinter.ContainerMode, p.ContainerMode)
}
}
15 changes: 6 additions & 9 deletions pkg/cmd/flags/tracee_ebpf_output.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,10 @@ Possible options:
[format:]gotemplate=/path/to/template output events formatted using a given gotemplate file
out-file:/path/to/file write the output to a specified file. create/trim the file if exists (default: stdout)
none ignore stream of events output, usually used with --capture
option:{stack-addresses,exec-env,relative-time,exec-hash,parse-arguments,sort-events}
option:{stack-addresses,exec-env,exec-hash,parse-arguments,sort-events}
augment output according to given options (default: none)
stack-addresses include stack memory addresses for each event
exec-env when tracing execve/execveat, show the environment variables that were used for execution
relative-time use relative timestamp instead of wall timestamp for events
exec-hash when tracing sched_process_exec, show the file hash(sha256) and ctime
parse-arguments do not show raw machine-readable values for event arguments, instead parse into human readable strings
parse-arguments-fds enable parse-arguments and enrich fd with its file path translation. This can cause pipeline slowdowns.
Expand Down Expand Up @@ -81,9 +80,8 @@ func TraceeEbpfPrepareOutput(outputSlice []string, newBinary bool) (PrepareOutpu

if outPath == "" {
stdoutConfig := config.PrinterConfig{
Kind: printerKind,
OutFile: os.Stdout,
RelativeTS: traceeConfig.RelativeTime,
Kind: printerKind,
OutFile: os.Stdout,
}

printerConfigs = append(printerConfigs, stdoutConfig)
Expand All @@ -94,10 +92,9 @@ func TraceeEbpfPrepareOutput(outputSlice []string, newBinary bool) (PrepareOutpu
}

printerConfig := config.PrinterConfig{
Kind: printerKind,
OutPath: outPath,
OutFile: file,
RelativeTS: traceeConfig.RelativeTime,
Kind: printerKind,
OutPath: outPath,
OutFile: file,
}

printerConfigs = append(printerConfigs, printerConfig)
Expand Down
11 changes: 0 additions & 11 deletions pkg/cmd/flags/tracee_ebpf_output_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,6 @@ func TestPrepareTraceeEbpfOutput(t *testing.T) {
},
},
},
{
testName: "option relative-time",
outputSlice: []string{"json", "option:relative-time"},
expectedOutput: PrepareOutputResult{
TraceeConfig: &config.OutputConfig{
RelativeTime: true,
},
},
},
{
testName: "option exec-hash=inode",
outputSlice: []string{"option:exec-hash=inode"},
Expand Down Expand Up @@ -131,7 +122,6 @@ func TestPrepareTraceeEbpfOutput(t *testing.T) {
"json",
"option:stack-addresses",
"option:exec-env",
"option:relative-time",
"option:exec-hash=none",
"option:parse-arguments",
"option:parse-arguments-fds",
Expand All @@ -141,7 +131,6 @@ func TestPrepareTraceeEbpfOutput(t *testing.T) {
TraceeConfig: &config.OutputConfig{
StackAddresses: true,
ExecEnv: true,
RelativeTime: true,
CalcHashes: config.CalcHashesNone,
ParseArguments: true,
ParseArgumentsFDs: true,
Expand Down
2 changes: 0 additions & 2 deletions pkg/cmd/printer/printer.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,12 @@ func New(cfg config.PrinterConfig) (EventPrinter, error) {
out: cfg.OutFile,
verbose: false,
containerMode: cfg.ContainerMode,
relativeTS: cfg.RelativeTS,
}
case kind == "table-verbose":
res = &tableEventPrinter{
out: cfg.OutFile,
verbose: true,
containerMode: cfg.ContainerMode,
relativeTS: cfg.RelativeTS,
}
case kind == "json":
res = &jsonEventPrinter{
Expand Down
10 changes: 0 additions & 10 deletions pkg/cmd/printer/printer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,6 @@ func TestTraceeEbpfPrepareOutputPrinterConfig(t *testing.T) {
},
expectedError: nil,
},
{
testName: "option relative timestamp",
outputSlice: []string{"option:relative-time"},
expectedPrinter: config.PrinterConfig{
Kind: "table",
OutFile: os.Stdout,
RelativeTS: true,
},
expectedError: nil,
},
}
for _, testcase := range testCases {
testcase := testcase
Expand Down
2 changes: 0 additions & 2 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,6 @@ func (c CalcHashesOption) String() string {
type OutputConfig struct {
StackAddresses bool
ExecEnv bool
RelativeTime bool
CalcHashes CalcHashesOption

ParseArguments bool
Expand All @@ -187,5 +186,4 @@ type PrinterConfig struct {
OutPath string
OutFile io.WriteCloser
ContainerMode ContainerMode
RelativeTS bool
}
3 changes: 2 additions & 1 deletion pkg/ebpf/capture.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/aquasecurity/tracee/pkg/bufferdecoder"
"github.com/aquasecurity/tracee/pkg/errfmt"
"github.com/aquasecurity/tracee/pkg/logger"
"github.com/aquasecurity/tracee/pkg/time"
"github.com/aquasecurity/tracee/pkg/utils"
)

Expand Down Expand Up @@ -109,7 +110,7 @@ func (t *Tracee) handleFileCaptures(ctx context.Context) {
continue
}
// note: size of buffer will determine maximum extracted file size! (as writes from kernel are immediate)
mprotectMeta.Ts = uint64(t.timeNormalizer.NormalizeTime(int(mprotectMeta.Ts)))
mprotectMeta.Ts = time.BootToEpochNS(uint64(mprotectMeta.Ts))
filename = fmt.Sprintf("bin.pid-%d.ts-%d", mprotectMeta.Pid, mprotectMeta.Ts)
} else if meta.BinType == bufferdecoder.SendKernelModule {
err = metaBuffDecoder.DecodeKernelModuleMeta(&kernelModuleMeta)
Expand Down
Loading
Loading