in aucoalesce/coalesce.go [686:760]
func setFileObject(event *Event, pathIndexHint int) error {
if len(event.Paths) == 0 {
return errors.New("path message not found")
}
var pathIndex int
if len(event.Paths) > pathIndexHint {
pathIndex = pathIndexHint
}
path := event.Paths[pathIndex]
for _, p := range event.Paths[pathIndex:] {
// Skip over PARENT and UNKNOWN types in case the path index was wrong.
if nametype := p["nametype"]; nametype != "PARENT" && nametype != "UNKNOWN" {
path = p
break
}
}
event.File = &File{}
if value, found := path["name"]; found {
event.Summary.Object.Primary = value
event.File.Path = value
}
if value, found := path["inode"]; found {
event.File.Inode = value
}
if value, found := path["rdev"]; found {
event.File.Device = value
}
if value, found := path["mode"]; found {
mode, err := strconv.ParseUint(value, 8, 64)
if err != nil {
return fmt.Errorf("failed to parse file mode: %w", err)
}
m := os.FileMode(mode)
event.File.Mode = fmt.Sprintf("%04o", 0o7777&m)
switch {
case m.IsRegular():
event.Summary.Object.Type = "file"
case m.IsDir():
event.Summary.Object.Type = "directory"
case m&os.ModeCharDevice != 0:
event.Summary.Object.Type = "character-device"
case m&modeBlockDevice != 0:
event.Summary.Object.Type = "block-device"
case m&os.ModeNamedPipe != 0:
event.Summary.Object.Type = "named-pipe"
case m&os.ModeSymlink != 0:
event.Summary.Object.Type = "symlink"
case m&os.ModeSocket != 0:
event.Summary.Object.Type = "socket"
}
}
if value, found := path["ouid"]; found {
event.File.UID = value
}
if value, found := path["ogid"]; found {
event.File.GID = value
}
for k, v := range path {
if strings.HasPrefix(k, "obj_") {
addFileSELinuxLabel(k[4:], v, event)
}
}
return nil
}