Skip to content

Commit

Permalink
Change some struct member visibility
Browse files Browse the repository at this point in the history
  • Loading branch information
mjwolf committed Feb 22, 2024
1 parent fe4f0a3 commit f2443cd
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 26 deletions.
6 changes: 3 additions & 3 deletions x-pack/auditbeat/processors/sessionmd/add_session_metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
"github.com/elastic/beats/v7/x-pack/auditbeat/processors/sessionmd/procfs"
"github.com/elastic/beats/v7/x-pack/auditbeat/processors/sessionmd/provider"
"github.com/elastic/beats/v7/x-pack/auditbeat/processors/sessionmd/provider/ebpf_provider"
"github.com/elastic/elastic-agent-libs/config"
cfg "github.com/elastic/elastic-agent-libs/config"
"github.com/elastic/elastic-agent-libs/logp"
"github.com/elastic/elastic-agent-libs/mapstr"
)
Expand All @@ -34,13 +34,13 @@ func init() {
}

type addSessionMetadata struct {
config Config
config config
logger *logp.Logger
db *processdb.DB
provider provider.Provider
}

func New(cfg *config.C) (beat.Processor, error) {
func New(cfg *cfg.C) (beat.Processor, error) {
c := defaultConfig()
if err := cfg.Unpack(&c); err != nil {
return nil, fmt.Errorf("fail to unpack the %v configuration: %w", processorName, err)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ var (
enrichTests = []struct {
testName string
mockProcesses []types.ProcessExecEvent
config Config
config config
input beat.Event
expected beat.Event
expect_error bool
}{
{
testName: "Enrich Process",
config: Config{
config: config{
ReplaceFields: false,
PIDField: "process.pid",
},
Expand Down Expand Up @@ -93,7 +93,7 @@ var (
},
{
testName: "No PID Field in Event",
config: Config{
config: config{
ReplaceFields: false,
PIDField: "process.pid",
},
Expand All @@ -112,7 +112,7 @@ var (
},
{
testName: "PID Not Number",
config: Config{
config: config{
ReplaceFields: false,
PIDField: "process.pid",
},
Expand All @@ -132,7 +132,7 @@ var (
},
{
testName: "PID not in DB",
config: Config{
config: config{
ReplaceFields: false,
PIDField: "process.pid",
},
Expand Down
6 changes: 3 additions & 3 deletions x-pack/auditbeat/processors/sessionmd/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
package sessionmd

// Config for add_session_metadata processor.
type Config struct {
type config struct {
Backend string `config:"backend"`
ReplaceFields bool `config:"replace_fields"`
PIDField string `config:"pid_field"`
}

func defaultConfig() Config {
return Config{
func defaultConfig() config {
return config{
Backend: "auto",
ReplaceFields: false,
PIDField: "process.pid",
Expand Down
30 changes: 15 additions & 15 deletions x-pack/auditbeat/processors/sessionmd/processdb/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ func ttyDevFromProto(p types.TTYDev) types.TTYDev {
}

type DB struct {
sync.RWMutex
mutex sync.RWMutex
logger *logp.Logger
processes map[uint32]Process
entryLeaders map[uint32]EntryType
Expand Down Expand Up @@ -207,8 +207,8 @@ func basename(pathStr string) string {
}

func (db *DB) InsertFork(fork types.ProcessForkEvent) {
db.Lock()
defer db.Unlock()
db.mutex.Lock()
defer db.mutex.Unlock()

pid := fork.ChildPIDs.Tgid
ppid := fork.ParentPIDs.Tgid
Expand Down Expand Up @@ -240,8 +240,8 @@ func (db *DB) insertProcess(process Process) {
}

func (db *DB) InsertExec(exec types.ProcessExecEvent) {
db.Lock()
defer db.Unlock()
db.mutex.Lock()
defer db.mutex.Unlock()

proc := Process{
PIDs: pidInfoFromProto(exec.PIDs),
Expand Down Expand Up @@ -367,8 +367,8 @@ func (db *DB) evaluateEntryLeader(p Process) *uint32 {
}

func (db *DB) InsertSetsid(setsid types.ProcessSetsidEvent) {
db.Lock()
defer db.Unlock()
db.mutex.Lock()
defer db.mutex.Unlock()

if entry, ok := db.processes[setsid.PIDs.Tgid]; ok {
entry.PIDs = pidInfoFromProto(setsid.PIDs)
Expand All @@ -381,8 +381,8 @@ func (db *DB) InsertSetsid(setsid types.ProcessSetsidEvent) {
}

func (db *DB) InsertExit(exit types.ProcessExitEvent) {
db.Lock()
defer db.Unlock()
db.mutex.Lock()
defer db.mutex.Unlock()

pid := exit.PIDs.Tgid
delete(db.processes, pid)
Expand Down Expand Up @@ -528,8 +528,8 @@ func setSameAsProcess(process *types.Process) {
}

func (db *DB) GetProcess(pid uint32) (types.Process, error) {
db.RLock()
defer db.RUnlock()
db.mutex.RLock()
defer db.mutex.RUnlock()

process, ok := db.processes[pid]
if !ok {
Expand Down Expand Up @@ -568,8 +568,8 @@ func (db *DB) GetProcess(pid uint32) (types.Process, error) {
}

func (db *DB) GetEntryType(pid uint32) (EntryType, error) {
db.RLock()
defer db.RUnlock()
db.mutex.RLock()
defer db.mutex.RUnlock()

if entryType, ok := db.entryLeaders[pid]; ok {
return entryType, nil
Expand All @@ -578,8 +578,8 @@ func (db *DB) GetEntryType(pid uint32) (EntryType, error) {
}

func (db *DB) ScrapeProcfs() []uint32 {
db.Lock()
defer db.Unlock()
db.mutex.Lock()
defer db.mutex.Unlock()

procs, err := db.procfs.GetAllProcesses()
if err != nil {
Expand Down

0 comments on commit f2443cd

Please sign in to comment.