Skip to content

Commit f16fe4b

Browse files
committed
refactor: Trim the k prefix from config types
Most notable change is the refactoring of KstreamConfig to EventSourceConfig type along with other changes that trim the `k` prefix from types, identifiers or methods.
1 parent 0e1e8a1 commit f16fe4b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+494
-495
lines changed

cmd/fibratus/app/config/config.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import (
2222
"fmt"
2323
"github.com/rabbitstack/fibratus/internal/bootstrap"
2424
"github.com/rabbitstack/fibratus/pkg/config"
25-
kerrors "github.com/rabbitstack/fibratus/pkg/errors"
25+
errs "github.com/rabbitstack/fibratus/pkg/errors"
2626
"github.com/rabbitstack/fibratus/pkg/util/rest"
2727
"github.com/spf13/cobra"
2828
"os"
@@ -49,7 +49,7 @@ func printConfig(cmd *cobra.Command, args []string) error {
4949
}
5050
body, err := rest.Get(rest.WithTransport(cfg.API.Transport), rest.WithURI("config"))
5151
if err != nil {
52-
return kerrors.ErrHTTPServerUnavailable(cfg.API.Transport, err)
52+
return errs.ErrHTTPServerUnavailable(cfg.API.Transport, err)
5353
}
5454
_, err = fmt.Fprintln(os.Stdout, string(body))
5555
if err != nil {

cmd/fibratus/app/stats/stats.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import (
2626

2727
"github.com/jedib0t/go-pretty/v6/table"
2828
"github.com/rabbitstack/fibratus/pkg/config"
29-
kerrors "github.com/rabbitstack/fibratus/pkg/errors"
29+
errs "github.com/rabbitstack/fibratus/pkg/errors"
3030
"github.com/rabbitstack/fibratus/pkg/util/rest"
3131
"github.com/spf13/cobra"
3232
)
@@ -123,7 +123,7 @@ func stats(cmd *cobra.Command, args []string) error {
123123
c := cfg.API
124124
body, err := rest.Get(rest.WithTransport(c.Transport), rest.WithURI("debug/vars"))
125125
if err != nil {
126-
return kerrors.ErrHTTPServerUnavailable(c.Transport, err)
126+
return errs.ErrHTTPServerUnavailable(c.Transport, err)
127127
}
128128
var stats Stats
129129
if err := json.Unmarshal(body, &stats); err != nil {

configs/fibratus.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,15 @@
3030
"init-snapshot": true
3131
},
3232

33-
"kevent": {
33+
"event": {
3434

3535
},
3636

37-
"kcap": {
37+
"cap": {
3838

3939
},
4040

41-
"kstream": {},
41+
"eventsource": {},
4242
"logging": {},
4343

4444
"output": {

configs/fibratus.yml

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
# =============================== Aggregator ==========================================
44

5-
# Aggregator is responsible for creating kernel event batches, applying transformers to each event
5+
# Aggregator is responsible for creating event batches, applying transformers to each event
66
# present in the batch, and forwarding those batches to the output sinks.
77
aggregator:
8-
# Determines the flush period that triggers the flushing of the kernel event batches to output sinks
8+
# Determines the flush period that triggers the flushing of the event batches to output sinks
99
flush-period: 500ms
1010

1111
# Represents the max time to wait before announcing failed flushing of enqueued events when fibratus
@@ -111,7 +111,7 @@ forward: false
111111

112112
# =============================== Filament =============================================
113113

114-
# Filaments are lightweight Python scriplets that are executed on top of the kernel event stream. You can easily
114+
# Filaments are lightweight Python scriplets that are executed on top of the event stream. You can easily
115115
# extend Fibratus with custom features that is encapsulated in filaments. This section controls the behaviour of
116116
# the filament engine.
117117
filament:
@@ -156,10 +156,10 @@ handle:
156156
# Indicates if process handles are collected during startup or when a new process is spawn.
157157
enumerate-handles: false
158158

159-
# =============================== Kevent ===============================================
159+
# =============================== Event ===============================================
160160

161-
# The following settings control the state of the kernel event.
162-
kevent:
161+
# The following settings control the state of the event.
162+
event:
163163
# Indicates if threads are serialized as part of the process state
164164
serialize-threads: false
165165

@@ -175,19 +175,19 @@ kevent:
175175
# Indicates if environment variables are serialized as part of the process state
176176
serialize-envs: false
177177

178-
# =============================== Kcap =================================================
178+
# =============================== Capture =================================================
179179

180-
# Contains the settings that dictate the behaviour of the kernel event captures.
180+
# Contains the settings that dictate the behaviour of the captures.
181181

182-
kcap:
183-
# Specifies the name of the output kcap file. If not empty, capture files are always stored
182+
cap:
183+
# Specifies the name of the output cap file. If not empty, capture files are always stored
184184
# to this file by overwriting any existing capture file
185185
file: ""
186186

187-
# =============================== Kstream ==============================================
187+
# =============================== Event source ==============================================
188188

189-
# Tweaks for controlling the behaviour of the kernel stream consumer.
190-
kstream:
189+
# Tweaks for controlling the behaviour of the event source.
190+
eventsource:
191191
# Determines the maximum number of buffers allocated for the event tracing session's buffer pool
192192
#max-buffers:
193193

@@ -202,32 +202,32 @@ kstream:
202202
# less memory but it increases the rate at which buffers must be flushed)
203203
#buffer-size:
204204

205-
# Determines whether thread kernel events are collected by Kernel Logger provider
205+
# Determines whether thread events are collected by Kernel Logger provider
206206
#enable-thread: true
207207

208-
# Determines whether registry kernel events are collected by Kernel Logger provider
208+
# Determines whether registry events are collected by Kernel Logger provider
209209
#enable-registry: true
210210

211-
# Determines whether network kernel events are collected by Kernel Logger provider
211+
# Determines whether network events are collected by Kernel Logger provider
212212
#enable-net: true
213213

214-
# Determines whether file kernel events are collected by Kernel Logger provider
214+
# Determines whether file events are collected by Kernel Logger provider
215215
#enable-fileio: true
216216

217217
# Determines whether VA map/unmap events are collected by Kernel Logger provider
218218
#enable-vamap: true
219219

220-
# Determines whether image kernel events are collected by Kernel Logger provider
220+
# Determines whether image events are collected by Kernel Logger provider
221221
#enable-image: true
222222

223-
# Determines whether object manager kernel events (handle creation/destruction) are
223+
# Determines whether object manager events (handle creation/destruction) are
224224
# collected by Kernel Logger provider
225225
#enable-handle: false
226226

227-
# Determines whether memory manager kernel events are collected by Kernel Logger provider
227+
# Determines whether memory manager events are collected by Kernel Logger provider
228228
#enable-mem: true
229229

230-
# Determines whether kernel Audit API calls events are collected
230+
# Determines whether Audit API calls events are collected
231231
#enable-audit-api: true
232232

233233
# Determines whether DNS client events are collected
@@ -282,7 +282,7 @@ logging:
282282

283283
# =============================== Output ================================================
284284

285-
# Outputs transport the event flowing through kernel event stream to its final destination. Only one output
285+
# Outputs transport the event flowing through event stream to its final destination. Only one output
286286
# can be active at the time. The following section contains available outputs and their preferences.
287287
output:
288288
# Console output writes the event to standard output stream.
@@ -296,7 +296,7 @@ output:
296296

297297
# Template that's feed into event formatter. The default event formatter template is:
298298
#
299-
# {{ .Seq }} {{ .Timestamp }} - {{ .CPU }} {{ .Process }} ({{ .Pid }}) - {{ .Type }} ({{ .Kparams }})
299+
# {{ .Seq }} {{ .Timestamp }} - {{ .CPU }} {{ .Process }} ({{ .Pid }}) - {{ .Type }} ({{ .Params }})
300300
#
301301
#template:
302302

@@ -330,7 +330,7 @@ output:
330330
# Specifies the timeout for periodic health checks
331331
#healthcheck-timeout: 5s
332332

333-
# Identifies the user name for the basic HTTP authentication
333+
# Identifies the username for the basic HTTP authentication
334334
#username:
335335

336336
# Identifies the password for the basic HTTP authentication
@@ -349,7 +349,7 @@ output:
349349
# Specifies the name of the index template
350350
#template-name: fibratus
351351

352-
# Represents the target index for kernel events. It allows time specifiers to create indices per time frame.
352+
# Represents the target index for events. It allows time specifiers to create indices per time frame.
353353
# For example, fibratus-%Y-%m generates the index name with current year and month time specifiers
354354
#index-name: fibratus
355355

@@ -380,7 +380,7 @@ output:
380380
# Specifies the AMQP connection timeout
381381
#timeout: 5s
382382

383-
# Specifies target exchange name that receives inbound kernel events
383+
# Specifies target exchange name that receives inbound events
384384
#exchange: fibratus
385385

386386
# Represents the AMQP exchange type. Available exchange type include common types are "direct", "fanout",
@@ -519,15 +519,15 @@ pe:
519519

520520
# =============================== Transformers =========================================
521521

522-
# Transformers are responsible for augmenting, parsing or enriching kernel events.
522+
# Transformers are responsible for augmenting, parsing or enriching events.
523523
transformers:
524524
# Remove transformer deletes provided event parameters.
525525
remove:
526526
# Indicates if the remove transformer is enabled
527527
enabled: false
528528

529529
# Represents the list of parameters that are removed from the event
530-
#kparams:
530+
#params:
531531
# - irp
532532

533533
# Rename transformer renames parameter from old to new name.
@@ -537,7 +537,7 @@ transformers:
537537

538538
# Contains the list of old/new mappings. Old represents the original
539539
# parameter name, while new is the new parameter name
540-
#kparams:
540+
#params:
541541
# - old:
542542
# new:
543543

@@ -549,7 +549,7 @@ transformers:
549549
# Contains the list of parameter replacements. For each target event parameter, the old represent the substring
550550
# that gets replaced by the new string.
551551
#replacements:
552-
# - kparam:
552+
# - param:
553553
# old:
554554
# new:
555555

@@ -571,12 +571,12 @@ transformers:
571571

572572
# Contains the list of parameters associated with the prefix that is trimmed from the parameter's value
573573
#prefixes:
574-
# - kparam:
574+
# - param:
575575
# trim:
576576

577577
# Contains the list of parameters associated with the suffix that is trimmed from the parameter's value
578578
#suffixes:
579-
# - kparam:
579+
# - param:
580580
# trim:
581581

582582
# =============================== YARA =================================================

filaments/teamviewer_remote_file_copy.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,13 @@
5252

5353

5454
def on_init():
55-
kfilter("evt.name = 'CreateFile' and ps.name = 'TeamViewer.exe' and file.operation = 'create' "
55+
set_filter("evt.name = 'CreateFile' and ps.name = 'TeamViewer.exe' and file.operation = 'create' "
5656
"and file.extension in (%s)"
5757
% (', '.join([f'\'{ext}\'' for ext in extensions])))
5858

5959

6060
@dotdictify
61-
def on_next_kevent(event):
61+
def on_next_event(event):
6262
emit_alert(
6363
f'Remote File Copy via TeamViewer',
6464
f'TeamViewer downloaded an executable or script file {event.params.file_name} via transfer session',

internal/bootstrap/bootstrap.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ func NewApp(cfg *config.Config, options ...Option) (*App, error) {
120120
sigs = signals.Install()
121121
}
122122
if opts.isCaptureReplay {
123-
reader, err := cap.NewReader(cfg.KcapFile, cfg)
123+
reader, err := cap.NewReader(cfg.CapFile, cfg)
124124
if err != nil {
125125
return nil, err
126126
}
@@ -230,7 +230,7 @@ func (f *App) Run(args []string) error {
230230
}()
231231
} else {
232232
// register stack symbolizer
233-
if cfg.Kstream.StackEnrichment {
233+
if cfg.EventSource.StackEnrichment {
234234
f.symbolizer = symbolize.NewSymbolizer(symbolize.NewDebugHelpResolver(cfg), f.psnap, cfg, false)
235235
f.evs.RegisterEventListener(f.symbolizer)
236236
}
@@ -288,7 +288,7 @@ func (f *App) WriteCapture(args []string) error {
288288
if err != nil {
289289
return err
290290
}
291-
f.writer, err = cap.NewWriter(f.config.KcapFile, f.psnap, f.hsnap)
291+
f.writer, err = cap.NewWriter(f.config.CapFile, f.psnap, f.hsnap)
292292
if err != nil {
293293
return err
294294
}

internal/etw/consumer.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ func NewConsumer(
5353
evts chan *event.Event,
5454
) *Consumer {
5555
return &Consumer{
56-
q: event.NewQueueWithChannel(evts, config.Kstream.StackEnrichment, config.ForwardMode || config.IsCaptureSet()),
56+
q: event.NewQueueWithChannel(evts, config.EventSource.StackEnrichment, config.ForwardMode || config.IsCaptureSet()),
5757
sequencer: sequencer,
5858
processors: processors.NewChain(psnap, hsnap, config),
5959
psnap: psnap,
@@ -77,7 +77,7 @@ func (c *Consumer) ProcessEvent(ev *etw.EventRecord) error {
7777
if event.IsCurrentProcDropped(ev.Header.ProcessID) {
7878
return nil
7979
}
80-
if c.config.Kstream.ExcludeKevent(ev.Header.ProviderID, ev.HookID()) {
80+
if c.config.EventSource.ExcludeEvent(ev.Header.ProviderID, ev.HookID()) {
8181
eventsExcluded.Add(1)
8282
return nil
8383
}
@@ -129,7 +129,7 @@ func (c *Consumer) ProcessEvent(ev *etw.EventRecord) error {
129129
// the filter is evaluated on the event to
130130
// decide whether it should get dropped
131131
if (evt.IsDropped(c.config.IsCaptureSet()) ||
132-
c.config.Kstream.ExcludeImage(evt.PS)) && !evt.IsStackWalk() {
132+
c.config.EventSource.ExcludeImage(evt.PS)) && !evt.IsStackWalk() {
133133
eventsExcluded.Add(1)
134134
return nil
135135
}

internal/etw/processors/chain_windows.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,22 +50,22 @@ func NewChain(
5050

5151
chain.addProcessor(newPsProcessor(psnap, vaRegionProber))
5252

53-
if config.Kstream.EnableFileIOKevents {
53+
if config.EventSource.EnableFileIOEvents {
5454
chain.addProcessor(newFsProcessor(hsnap, psnap, devMapper, devPathResolver, config))
5555
}
56-
if config.Kstream.EnableRegistryKevents {
56+
if config.EventSource.EnableRegistryEvents {
5757
chain.addProcessor(newRegistryProcessor(hsnap))
5858
}
59-
if config.Kstream.EnableImageKevents {
59+
if config.EventSource.EnableImageEvents {
6060
chain.addProcessor(newImageProcessor(psnap))
6161
}
62-
if config.Kstream.EnableNetKevents {
62+
if config.EventSource.EnableNetEvents {
6363
chain.addProcessor(newNetProcessor())
6464
}
65-
if config.Kstream.EnableHandleKevents {
65+
if config.EventSource.EnableHandleEvents {
6666
chain.addProcessor(newHandleProcessor(hsnap, psnap, devMapper, devPathResolver))
6767
}
68-
if config.Kstream.EnableMemKevents {
68+
if config.EventSource.EnableMemEvents {
6969
chain.addProcessor(newMemProcessor(psnap, vaRegionProber))
7070
}
7171

internal/etw/processors/fs_windows.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ func (f *fsProcessor) processEvent(e *event.Event) (*event.Event, error) {
208208
f.files[fileObject] = fileinfo
209209
}
210210

211-
if f.config.Kstream.EnableHandleKevents {
211+
if f.config.EventSource.EnableHandleEvents {
212212
f.devPathResolver.AddPath(ev.GetParamAsString(params.FilePath))
213213
}
214214

@@ -228,7 +228,7 @@ func (f *fsProcessor) processEvent(e *event.Event) (*event.Event, error) {
228228
// the previous stack walk for CreateFile is popped from
229229
// the queue and the callstack parameter attached to the
230230
// event.
231-
if f.config.Kstream.StackEnrichment {
231+
if f.config.EventSource.StackEnrichment {
232232
f.mu.Lock()
233233
defer f.mu.Unlock()
234234

0 commit comments

Comments
 (0)