event-generator

command module
v0.13.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 15, 2026 License: Apache-2.0 Imports: 1 Imported by: 0

README ¶

event-generator

Falco Ecosystem Repository Incubating

Release License Go Report Card Docker pulls Architectures

Generate a variety of suspect actions that are detected by Falco rulesets.

Warning — We strongly recommend that you run the program within Docker (see below), since some commands might alter your system. For example, some actions modify files and directories below /bin, /etc, /dev, etc. Make sure you fully understand what is the purpose of this tool before running any action.

Release notes

Version Notes
before v0.11 Previous versions of the event-generator might be compatible Falco versions up to 0.36, however, we do not guarantee it.
v0.11 Requires Falco 0.37.0 or newer. k8saudit is maintained on a best-effort basis.
v0.12 Requires Falco 0.38.0 or newer. Events collection has been aligned with the stable Falco ruleset.
v0.13 Requires Falco 0.44.0 or newer. Introduces the suite command, which consumes declarative YAML test descriptions and may replace the traditional commands in future versions. See New suite command.

Usage

The full command line documentation is here.

List actions
$ event-generator list --all

helper.CombinedServerClient
helper.DoNothing
helper.ExecLs
helper.InboundConnection
helper.NetworkActivity
helper.OutboundConnection
helper.RunShell
k8saudit.ClusterRoleWithPodExecCreated
k8saudit.ClusterRoleWithWildcardCreated
k8saudit.ClusterRoleWithWritePrivilegesCreated
k8saudit.CreateDisallowedPod
k8saudit.CreateHostNetworkPod
k8saudit.CreateModifyConfigmapWithPrivateCredentials
k8saudit.CreateNodePortService
k8saudit.CreatePrivilegedPod
k8saudit.CreateSensitiveMountPod
k8saudit.K8SConfigMapCreated
k8saudit.K8SDeploymentCreated
k8saudit.K8SServiceCreated
k8saudit.K8SServiceaccountCreated
syscall.AddingSshKeysToAuthorizedKeys
syscall.ChangeNamespacePrivilegesViaUnshare
syscall.ChangeThreadNamespace
syscall.ClearLogActivities
syscall.ContactEC2InstanceMetadataServiceFromContainer
syscall.ContainerDriftDetectedChmod
syscall.ContainerDriftDetectedOpenCreate
syscall.CreateFilesBelowDev
syscall.CreateHardlinkOverSensitiveFiles
syscall.CreateHiddenFilesOrDirectories
syscall.CreateSymlinkOverSensitiveFiles
syscall.DbProgramSpawnedProcess
syscall.DebugfsLaunchedInPrivilegedContainer
syscall.DecodingPayloadInContainer
syscall.DeleteOrRenameShellHistory
syscall.DetectCryptoMinersUsingTheStratumProtocol
syscall.DetectReleaseAgentFileContainerEscapes
syscall.DirectoryTraversalMonitoredFileRead
syscall.DisallowedSSHConnectionNonStandardPort
syscall.DropAndExecuteNewBinaryInContainer
syscall.ExecutionFromDevShm
syscall.FilelessExecutionViaMemfdCreate
syscall.FindAwsCredentials
syscall.InterpretedProcsInboundNetworkActivity
syscall.InterpretedProcsOutboundNetworkActivity
syscall.JavaProcessClassFileDownload
syscall.KubernetesClientToolLaunchedInContainer
syscall.LaunchIngressRemoteFileCopyToolsInContainer
syscall.LaunchPackageManagementProcessInContainer
syscall.LaunchRemoteFileCopyToolsInContainer
syscall.LaunchSuspiciousNetworkToolInContainer
syscall.LaunchSuspiciousNetworkToolOnHost
syscall.MkdirBinaryDirs
syscall.ModifyBinaryDirs
syscall.ModifyContainerEntrypoint
syscall.ModifyShellConfigurationFile
syscall.MountLaunchedInPrivilegedContainer
syscall.NetcatRemoteCodeExecutionInContainer
syscall.NonSudoSetuid
syscall.PacketSocketCreatedInContainer
syscall.PolkitLocalPrivilegeEscalationVulnerabilityCVE20214034
syscall.PotentialLocalPrivilegeEscalationViaEnvironmentVariablesMisuse
syscall.ProgramRunWithDisallowedHttpProxyEnv
syscall.PtraceAntiDebugAttempt
syscall.PtraceAttachedToProcess
syscall.ReadEnvironmentVariableFromProcFiles
syscall.ReadSensitiveFileTrustedAfterStartup
syscall.ReadSensitiveFileUntrusted
syscall.ReadShellConfigurationFile
syscall.ReadSshInformation
syscall.RemoveBulkDataFromDisk
syscall.RunShellUntrusted
syscall.ScheduleCronJobs
syscall.SearchPrivateKeysOrPasswords
syscall.SetSetuidOrSetgidBit
syscall.SudoPotentialPrivilegeEscalation
syscall.SystemProcsNetworkActivity
syscall.SystemUserInteractive
syscall.UnexpectedUDPTraffic
syscall.UnprivilegedDelegationOfPageFaultsHandlingToAUserspaceProcess
syscall.UserMgmtBinaries
syscall.WriteBelowBinaryDir
syscall.WriteBelowEtc
syscall.WriteBelowMonitoredDir
syscall.WriteBelowRoot
syscall.WriteBelowRpmDatabase
Run actions
event-generator run [regexp]

Without arguments, it runs all actions; otherwise, only those actions match the given regular expression.

For example, to run only those actions containing the word Files in their name:

$ sudo event-generator run syscall\.\*Files\.\*

INFO sleep for 100ms                               action=syscall.ReadSensitiveFileUntrusted
INFO action executed                               action=syscall.ReadSensitiveFileUntrusted
INFO sleep for 100ms                               action=syscall.CreateSymlinkOverSensitiveFiles
INFO action executed                               action=syscall.CreateSymlinkOverSensitiveFiles
INFO sleep for 100ms                               action=syscall.DirectoryTraversalMonitoredFileRead
INFO action executed                               action=syscall.DirectoryTraversalMonitoredFileRead
INFO sleep for 100ms                               action=syscall.ReadSensitiveFileTrustedAfterStartup
INFO spawn as "httpd"                              action=syscall.ReadSensitiveFileTrustedAfterStartup args="^syscall.ReadSensitiveFileUntrusted$ --sleep 6s"
INFO sleep for 6s                                  action=syscall.ReadSensitiveFileUntrusted as=httpd
INFO action executed                               action=syscall.ReadSensitiveFileUntrusted as=httpd

Useful options:

  • --loop to run actions in a loop
  • --sleep to set the length of time to wait before running an action (default to 100ms)

Also, note that not all actions are enabled by default. To run all actions, use the --all option.

Further options are documented here.

With Docker

Run all events with the Docker image locally:

docker run -it --rm falcosecurity/event-generator run
With Kubernetes

It can be deployed in a Kubernetes cluster using the event-generator helm chart. Before installing the chart, add the falcosecurity charts repository:

helm repo add falcosecurity https://falcosecurity.github.io/charts
helm repo update

Run all events once using a Kubernetes job:

helm install event-generator falcosecurity/event-generator \
  --namespace event-generator \
  --create-namespace \
  --set config.loop=false \
  --set config.actions=""

Run all events in a loop using a Kubernetes deployment:

helm install event-generator falcosecurity/event-generator \
  --namespace event-generator \
  --create-namespace \
  --set config.actions=""

N.B. The above commands apply to the event-generator namespace. Use a different name to use a different namespace. It will generate events in the same namespace.

Collections

Generate System Call activity

The syscall collection performs a variety of suspect actions detected by the default Falco ruleset.

Note that only actions for stable rules are enabled by default. To enable all other actions, use the --all option.

$ docker run -it --rm falcosecurity/event-generator run syscall --loop

The above command loops forever, incessantly generating a sample event every 100 miliseconds.

Generate activity for the k8saudit rules

The k8saudit events collection in the event-generator is maintained on a best-effort basis and may not fully work.

The k8saudit collection generates activity that matches the k8s audit event ruleset.

Note that all k8saudit are disabled by default. To enable them, use the --all option.

$ event-generator run k8saudit --all --loop --namespace `falco-eg-sandbox`

N.B.: the namespace must exist already.

The above command loops forever, creating resources in the falco-eg-sandbox namespace and deleting the after each iteration.

N.B.

  • the namespace must already exist
  • to produce any effect the Kubernetes audit log must be enabled, see here

Test rules

Since v0.4.0, this tool introduces a convenient integration test suite for Falco rules. The event-generator test command can run actions and test them against a running Falco instance.

This feature requires Falco 0.24.0 or newer. Before using the command below, you need Falco installed and running with the gRPC Output enabled.

Test locally (syscall only)

Run the following command to test syscall actions on a local Falco instance (connects via Unix socket to /run/falco/falco.sock by default):

sudo ./event-generator test syscall
Test on Kubernetes

Before running the following commands make sure you have added the falcosecurity charts repository as explained here.

Test all events once using a Kubernetes job:

helm install event-generator falcosecurity/event-generator \
  --namespace event-generator \
  --create-namespace \
  --set config.command=test \
  --set config.loop=false \
  --set config.actions=""

Test all events in a loop using a Kubernetes deployment:

helm install event-generator falcosecurity/event-generator \
  --namespace event-generator \
  --create-namespace \
  --set config.command=test \
  --set config.actions=""

Note that to test k8saudit events, you need Kubernetes Audit Log functionality enabled in Kubernetes and the k8saudit plugin in Falco.

Benchmark

Since v0.5.0, the event-generator can also be used for benchmarking a running instance of Falco. The command event-generator bench generates a high number of Event Per Second (EPS) to show you events throughput allowed by your Falco installation.

Be aware that before Falco 0.37 a rate-limiter for notifications that affects the gRPC Outputs APIs was present. You probably need to increase the outputs.rate and outputs.max_burst values within the Falco configuration, otherwise EPS will be rate-limited by the throttling mechanism.

Run a benchmark

Before starting a benchmark, the most important thing to understand is that the --sleep option controls the number of EPS (default to 250ms): reducing this value will increase the EPS. Furthermore, if the --loop option is set, the sleeping duration is automatically halved on each round. The --pid option can be used to monitor the Falco process.

You can find more details about the command-line usage here.

Please, keep in mind that not all actions can be used for benchmarking since some of them take too long to generate a high number of EPS. For example, k8saudit actions are not supposed to work, since those actions need some time to create Kubernetes resources. Also, some syscall actions sleep for a while (like the syscall.ReadSensitiveFileUntrusted) thus cannot be used.

Benchmark example

A common way for benchmarking a local Falco instance is by running the following command (that connects via Unix socket to /run/falco/falco.sock by default):

sudo event-generator bench "ChangeThreadNamespace|ReadSensitiveFileUntrusted" --all --loop --sleep 10ms --pid $(pidof -s falco)

📣 New suite command

Since v0.13, the event-generator ships a new top-level suite command that consumes test scenarios described in YAML files. While the traditional run, test and bench sub-commands execute actions coded in Go, the new suite sub-commands consume YAML descriptions, so a new scenario can be added without writing any Go code.

Tests are grouped into test suites by the Falco rule they target, and reports are emitted per suite. Three sub-commands are available:

The example below exercises a containerised process chain, a clientServer resource, a step that binds to a value exposed by the resource, an expected Falco outcome and template cases that expand into multiple concrete tests:

tests:
  - name: "Drop and execute new binary in container"
    rule: "Drop and execute new binary in container"
    description: "Testing reverse shell rule"
    runner: HostRunner
    context:
      container:
        image: image-name
        name: container-name
      processes:
        - args: "arg1 arg2"
          name: "proc0"
          exe: "arg0"
          user: user1
        - user: user2
        - user: root
          capabilities: "cap_net_admin,cap_net_bind_service,cap_chown=ep"
    resources:
      - type: clientServer
        name: cs1
        l4Proto: "%{item.l4Proto}"
        address: "%{item.address}"
    steps:
      - type: syscall
        name: d1
        syscall: dup2
        args:
          oldFd: "${cs1.client.fd}"
          newFd: 0
    expectedOutcome:
      source: "syscall"
    cases:
      - strategy: matrix
        values:
          l4Proto: ["tcp4", "udp4"]
          address: ["11.0.0.1:80"]
      - strategy: vector
        values:
          l4Proto: "unix"
          address: ""

The full YAML language is documented in the YAML description reference. Working examples covering each feature are available under samples/.

FAQ

What sample events can this tool generate?

See the events registry.

Can I contribute by adding new events?

Sure!

Check out the events registry conventions, then feel free to open a PR!

Your contribution is highly appreciated.

Can I use this project as a library?

This project provides three main packages that can be imported and used separately:

  • /cmd contains the CLI implementation
  • /events contains the events registry
  • /pkg/runner contains the actions runner implementations

Feel free to use them as you like on your projects.

Acknowledgments

Special thanks to Mark Stemm (@mstemm) — the author of the first event generator.

Documentation ¶

The Go Gopher

There is no documentation for this package.

Directories ¶

Path Synopsis
cmd
internal/alertretriever
Package alertretriever defines a Config object that allows to store the configuration for an HTTP alert retriever and build it.
Package alertretriever defines a Config object that allows to store the configuration for an HTTP alert retriever and build it.
suite
Package suite provides the implementation of the "suite" command.
Package suite provides the implementation of the "suite" command.
suite/config
Package config provides the implementation of Config, the configuration shared among suite-related commands.
Package config provides the implementation of Config, the configuration shared among suite-related commands.
suite/explain
Package explain provides the implementation of the "explain" command.
Package explain provides the implementation of the "explain" command.
suite/run
Package run provides the implementation of the "run" command.
Package run provides the implementation of the "run" command.
suite/test
Package test provides the implementation of the "test" command.
Package test provides the implementation of the "test" command.
syscall
SPDX-License-Identifier: Apache-2.0
SPDX-License-Identifier: Apache-2.0
pkg
alert
Package alert provides the definition of an Alert and an alert Retriever.
Package alert provides the definition of an Alert and an alert Retriever.
alert/retriever/httpretriever
Package httpretriever provides an implementation of alert.Retriever leveraging the HTTP Falco Outputs API.
Package httpretriever provides an implementation of alert.Retriever leveraging the HTTP Falco Outputs API.
baggage
Package baggage provides support for parsing and serializing a set of supported key-pair pairs.
Package baggage provides support for parsing and serializing a set of supported key-pair pairs.
capability
Package capability provides utilities for capabilities manipulation.
Package capability provides utilities for capabilities manipulation.
container
Package container provides the definition of a Container and a container Builder.
Package container provides the definition of a Container and a container Builder.
container/builder
Package builder provides an implementation of container.Builder and container.Container leveraging containerd.
Package builder provides an implementation of container.Builder and container.Container leveraging containerd.
log
Package log provides logging capability.
Package log provides logging capability.
osutil
Package osutil provides higher level functionality with respect to the ones provided by the standard os package.
Package osutil provides higher level functionality with respect to the ones provided by the standard os package.
process
Package process provides the definition of a Process and a process Builder.
Package process provides the definition of a Process and a process Builder.
process/builder
Package builder provides an implementation of process.Builder and process.Process.
Package builder provides an implementation of process.Builder and process.Process.
random
Package random defines utility functions to generate random objects.
Package random defines utility functions to generate random objects.
test
Package test provides the definition of a Test and a test Builder, as well as some error types useful to identify error conditions and retrieve additional information, like step/resource name and index.
Package test provides the definition of a Test and a test Builder, as well as some error types useful to identify error conditions and retrieve additional information, like step/resource name and index.
test/builder
Package builder provides an implementation of test.Builder.
Package builder provides an implementation of test.Builder.
test/field
Package field defines a generic way to reference and assign values to any test field by leveraging reflection and struct field tagging.
Package field defines a generic way to reference and assign values to any test field by leveraging reflection and struct field tagging.
test/loader
Package loader defines a Loader, able to unmarshall a YAML document into a Description.
Package loader defines a Loader, able to unmarshall a YAML document into a Description.
test/loader/schema
Package schema provides validation for the loaded tests description and documentation generation leveraging JSON schemas.
Package schema provides validation for the loaded tests description and documentation generation leveraging JSON schemas.
test/resource
Package resource provides the definition of a test Resource and a test resource Builder.
Package resource provides the definition of a test Resource and a test resource Builder.
test/resource/builder
Package builder provides an implementation of resource.Builder.
Package builder provides an implementation of resource.Builder.
test/resource/clientserver
Package clientserver provides the implementation of a clientServer test resource.
Package clientserver provides the implementation of a clientServer test resource.
test/resource/fd/directory
Package directory provides the implementation of a directory fd test resource.
Package directory provides the implementation of a directory fd test resource.
test/resource/fd/epoll
Package epoll provides the implementation of an eventpoll fd test resource.
Package epoll provides the implementation of an eventpoll fd test resource.
test/resource/fd/event
Package event provides the implementation of an event fd test resource.
Package event provides the implementation of an event fd test resource.
test/resource/fd/file
Package file provides the implementation of a regular file fd test resource.
Package file provides the implementation of a regular file fd test resource.
test/resource/fd/inotify
Package inotify provides the implementation of an inotify fd test resource.
Package inotify provides the implementation of an inotify fd test resource.
test/resource/fd/mem
Package mem provides the implementation of a memfd fd test resource.
Package mem provides the implementation of a memfd fd test resource.
test/resource/fd/pipe
Package pipe provides the implementation of a pipe fd test resource.
Package pipe provides the implementation of a pipe fd test resource.
test/resource/fd/signal
Package signal provides the implementation of a signal fd test resource.
Package signal provides the implementation of a signal fd test resource.
test/resource/process
Package process provides the implementation of a process test resource.
Package process provides the implementation of a process test resource.
test/runner
Package runner provides the definition of a Runner and a runner Builder.
Package runner provides the definition of a Runner and a runner Builder.
test/runner/builder
Package builder provides an implementation of runner.Builder.
Package builder provides an implementation of runner.Builder.
test/runner/host
Package host provides an implementation of runner.Runner enabling test execution on the host system.
Package host provides an implementation of runner.Runner enabling test execution on the host system.
test/script/shell
Package shell provides the implementation of a shell test script.
Package shell provides the implementation of a shell test script.
test/step
Package step provides the definition of a test Step and a test step Builder.
Package step provides the definition of a test Step and a test step Builder.
test/step/builder
Package builder provides an implementation of step.Builder.
Package builder provides an implementation of step.Builder.
test/step/syscall
Package syscall provides the definition of a Syscall test step and a syscall test step Builder.
Package syscall provides the definition of a Syscall test step and a syscall test step Builder.
test/step/syscall/base
Package base provides the definition of a generic syscall.Syscall test step.
Package base provides the definition of a generic syscall.Syscall test step.
test/step/syscall/builder
Package builder provides the implementation of a syscall.Builder.
Package builder provides the implementation of a syscall.Builder.
test/step/syscall/connect
Package connect provides the implementation of a connect system call test step.
Package connect provides the implementation of a connect system call test step.
test/step/syscall/dup
Package dup provides the implementation of a dup system call test step.
Package dup provides the implementation of a dup system call test step.
test/step/syscall/dup2
Package dup2 provides the implementation of a dup2 system call test step.
Package dup2 provides the implementation of a dup2 system call test step.
test/step/syscall/dup3
Package dup3 provides the implementation of a dup3 system call test step.
Package dup3 provides the implementation of a dup3 system call test step.
test/step/syscall/finitmodule
Package finitmodule provides the implementation of an finit_module system call test step.
Package finitmodule provides the implementation of an finit_module system call test step.
test/step/syscall/initmodule
Package initmodule provides the implementation of an init_module system call test step.
Package initmodule provides the implementation of an init_module system call test step.
test/step/syscall/kill
Package kill provides the implementation of a kill system call test step.
Package kill provides the implementation of a kill system call test step.
test/step/syscall/link
Package link provides the implementation of a link system call test step.
Package link provides the implementation of a link system call test step.
test/step/syscall/linkat
Package linkat provides the implementation of a linkat system call test step.
Package linkat provides the implementation of a linkat system call test step.
test/step/syscall/open
Package open provides the implementation of an open system call test step.
Package open provides the implementation of an open system call test step.
test/step/syscall/openat
Package openat provides the implementation of an openat system call test step.
Package openat provides the implementation of an openat system call test step.
test/step/syscall/openat2
Package openat2 provides the implementation of an openat2 system call test step.
Package openat2 provides the implementation of an openat2 system call test step.
test/step/syscall/read
Package read provides the implementation of a write system call test step.
Package read provides the implementation of a write system call test step.
test/step/syscall/sendto
Package sendto provides the implementation of a sendto system call test step.
Package sendto provides the implementation of a sendto system call test step.
test/step/syscall/socket
Package socket provides the implementation of a socket system call test step.
Package socket provides the implementation of a socket system call test step.
test/step/syscall/symlink
Package symlink provides the implementation of a symlink system call test step.
Package symlink provides the implementation of a symlink system call test step.
test/step/syscall/symlinkat
Package symlinkat provides the implementation of a symlinkat system call test step.
Package symlinkat provides the implementation of a symlinkat system call test step.
test/step/syscall/write
Package write provides the implementation of a write system call test step.
Package write provides the implementation of a write system call test step.
test/suite
Package suite provides the definition of a test suite as well as a mechanism to load multiple test suites from multiple sources through the Loader interface.
Package suite provides the definition of a test suite as well as a mechanism to load multiple test suites from multiple sources through the Loader interface.
test/suite/loader
Package loader provides the implementation of a suite.Loader.
Package loader provides the implementation of a suite.Loader.
test/suite/reportencoder/jsonencoder
Package jsonencoder provides an implementation of suite.ReportEncoder allowing to write a report to the underlying destination using a JSON encoding.
Package jsonencoder provides an implementation of suite.ReportEncoder allowing to write a report to the underlying destination using a JSON encoding.
test/suite/reportencoder/textencoder
Package textencoder provides an implementation of suite.ReportEncoder allowing to write a report to the underlying destination using a formatted text encoding.
Package textencoder provides an implementation of suite.ReportEncoder allowing to write a report to the underlying destination using a formatted text encoding.
test/suite/reportencoder/yamlencoder
Package yamlencoder provides an implementation of suite.ReportEncoder allowing to write a report to the underlying destination using a YAML encoding.
Package yamlencoder provides an implementation of suite.ReportEncoder allowing to write a report to the underlying destination using a YAML encoding.
test/suite/source
Package source provides the implementation of a suite.Source.
Package source provides the implementation of a suite.Source.
test/test
Package test provides an implementation the test.Test interface.
Package test provides an implementation the test.Test interface.
test/tester
Package tester provides the definition of test Tester, tester Report and ReportEncoder.
Package tester provides the definition of test Tester, tester Report and ReportEncoder.
test/tester/tester
Package tester provides an implementation of tester.Tester.
Package tester provides an implementation of tester.Tester.
tools
docgen command
file-bundler command

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL