MCPcopy
hub / github.com/slimtoolkit/slim / Run

Function Run

pkg/app/sensor/app.go:120–199  ·  view source on GitHub ↗

Run starts the sensor app

()

Source from the content-addressed store, hash-verified

118
119// Run starts the sensor app
120func Run() {
121 flag.Parse()
122
123 if *getAppBom {
124 dumpAppBom()
125 return
126 }
127
128 errutil.FailOn(configureLogger(*enableDebug, *logLevel, *logFormat, *logFile))
129 ctx := context.Background()
130 if len(os.Args) > 1 && os.Args[1] == "control" {
131 if err := runControlCommand(ctx); err != nil {
132 fmt.Fprintln(os.Stderr, "Control command failed: "+err.Error())
133 os.Exit(1)
134 }
135 return
136 }
137
138 activeCaps, maxCaps, err := sysenv.Capabilities(0)
139 errutil.WarnOn(err)
140
141 sr := &report.SensorReport{
142 Version: version.Current(),
143 Args: os.Args,
144 }
145
146 log.Infof("sensor: ver=%v", sr.Version)
147 log.Debugf("sensor: args => %#v", sr.Args)
148
149 log.Tracef("sensor: uid=%v euid=%v", os.Getuid(), os.Geteuid())
150 log.Tracef("sensor: privileged => %v", sysenv.IsPrivileged())
151 log.Tracef("sensor: active capabilities => %#v", activeCaps)
152 log.Tracef("sensor: max capabilities => %#v", maxCaps)
153 log.Tracef("sensor: sysinfo => %#v", system.GetSystemInfo())
154 log.Tracef("sensor: kernel flags => %#v", system.DefaultKernelFeatures.Raw)
155
156 var artifactsExtra []string
157 if len(*commandsFile) > 0 {
158 artifactsExtra = append(artifactsExtra, *commandsFile)
159 }
160 if len(*logFile) > 0 {
161 artifactsExtra = append(artifactsExtra, *logFile)
162 }
163 artifactor := artifact.NewProcessor(sr, *artifactsDir, artifactsExtra)
164
165 exe, err := newExecution(
166 ctx,
167 *sensorMode,
168 *commandsFile,
169 eventsFilePath(),
170 *lifecycleHookCommand,
171 )
172 if err != nil {
173 errutil.WarnOn(artifactor.Archive())
174 errutil.FailOn(err) // calls os.Exit(1)
175 }
176
177 mondelFile := filepath.Join(*artifactsDir, report.DefaultMonDelFileName)

Callers 1

mainFunction · 0.92

Calls 15

ArchiveMethod · 0.95
FailOnFunction · 0.92
CapabilitiesFunction · 0.92
WarnOnFunction · 0.92
CurrentFunction · 0.92
IsPrivilegedFunction · 0.92
GetSystemInfoFunction · 0.92
NewProcessorFunction · 0.92
NewPublisherFunction · 0.92
dumpAppBomFunction · 0.85
configureLoggerFunction · 0.85
runControlCommandFunction · 0.85

Tested by

no test coverage detected