Skip to content
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

check for nil values in evt.time and proc.pid #527

Merged
merged 1 commit into from
Jun 21, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions outputs/spyderbat.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"bytes"
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"log"
"net/http"
Expand Down Expand Up @@ -131,15 +132,28 @@ type spyderbatPayload struct {

func newSpyderbatPayload(falcopayload types.FalcoPayload) (spyderbatPayload, error) {
nowTime := float64(time.Now().UnixNano()) / 1000000000
jsonTime, err := falcopayload.OutputFields["evt.time"].(json.Number).Int64()

timeStr := falcopayload.OutputFields["evt.time"]
if timeStr == nil {
errStr := fmt.Sprintf("evt.time is nil for rule %s", falcopayload.Rule)
return spyderbatPayload{}, errors.New(errStr)
}
jsonTime, err := timeStr.(json.Number).Int64()
if err != nil {
return spyderbatPayload{}, err
}
eventTime := float64(jsonTime / 1000000000.0)
pid, err := falcopayload.OutputFields["proc.pid"].(json.Number).Int64()

pidStr := falcopayload.OutputFields["proc.pid"]
if pidStr == nil {
errStr := fmt.Sprintf("proc.pid is nil for rule %s", falcopayload.Rule)
return spyderbatPayload{}, errors.New(errStr)
}
pid, err := pidStr.(json.Number).Int64()
if err != nil {
return spyderbatPayload{}, err
}

level := PriorityMap[falcopayload.Priority]
args := strings.Split(falcopayload.Output, " ")
var message []string
Expand Down
Loading