fleet/server/datastore/inmem/file_integrity_monitoring.go
John Murphy d5f9fcaeb2 Added FIM support (#1548)
This PR adds support for file integrity monitoring. This is done by providing a simplified API that can be used to PATCH/GET FIM configurations. There is also code to build the FIM configuration to send back to osquery. Each PATCH request, if successful, replaces Fleet's existing FIM configuration. For example:

curl -X "PATCH" "https://localhost:8080/api/v1/kolide/fim" \
     -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzZXNzaW9uX2tleSI6IkVhaFhvZWswMGtWSEdaTTNCWndIMnhpYWxkNWZpcVFDR2hEcW1HK2UySmRNOGVFVE1DeTNTaUlFWmhZNUxhdW1ueFZDV2JiR1Bwdm5TKzdyK3NJUzNnPT0ifQ.SDCHAUA1vTuWGjXtcQds2GZLM27HAAiOUhR4WvgvTNY" \
     -H "Content-Type: application/json; charset=utf-8" \
     -d $'{
  "interval": 500,
  "file_paths": {
    "etc": [
      "/etc/%%"
    ],
    "users": [
      "/Users/%/Library/%%",
      "/Users/%/Documents/%%"
    ],
    "usr": [
      "/usr/bin/%%"
    ]
  }
}'
2017-08-18 10:37:33 -05:00

28 lines
661 B
Go

package inmem
import (
"github.com/kolide/fleet/server/kolide"
)
func (d *Datastore) NewFIMSection(fp *kolide.FIMSection, opts ...kolide.OptionalArg) (*kolide.FIMSection, error) {
d.mtx.Lock()
defer d.mtx.Unlock()
fp.ID = d.nextID(fp)
d.filePaths[fp.ID] = fp
return fp, nil
}
func (d *Datastore) FIMSections() (kolide.FIMSections, error) {
d.mtx.Lock()
defer d.mtx.Unlock()
result := make(kolide.FIMSections)
for _, filePath := range d.filePaths {
result[filePath.SectionName] = append(result[filePath.SectionName], filePath.Paths...)
}
return result, nil
}
func (d *Datastore) ClearFIMSections() error {
panic("inmem is being deprecated")
}