-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
[Auditbeat][System] Fix error handling around go-sysinfo.Host #17569
Conversation
Before a system dataset is loaded, host information is loaded to populate `entity_id` fields. Error handling around it was incorrect and resulted in a panic when fetching host info failed, which afaik it's limited to errors accessing /proc/stat file.
Pinging @elastic/siem (Team:SIEM) |
@@ -55,19 +55,20 @@ func NewModule(base mb.BaseModule) (mb.Module, error) { | |||
log := logp.NewLogger(moduleName) | |||
|
|||
var hostID string | |||
hostInfo, err := sysinfo.Host() | |||
if hostInfo != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What was going on in here is when sysinfo.Host()
errors, it returns a non-nil interface that wraps a nil pointer, causing the nil check to pass but a panic inside the hostInfo.Info()
call below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code LGTM
Does it need a Changelog entry?
…c#17569) (elastic#17603) Before a system dataset is loaded, host information is loaded to populate `entity_id` fields. Error handling around it was incorrect and resulted in a panic when fetching host info failed, which afaik it's limited to errors accessing /proc/stat file. (cherry picked from commit 7602e79)
Before a system dataset is loaded, host information is loaded to populate
entity_id
fields.Error handling around it was incorrect and resulted in a panic when fetching host info failed, which afaik it's limited to errors accessing
/proc/stat
file.