feat(go): enrich snapshots with package ownership

This commit is contained in:
Luna 2026-07-22 03:50:55 -07:00
parent 6355fb403d
commit 88d7a6e3b8
No known key found for this signature in database
8 changed files with 149 additions and 54 deletions

View file

@ -3,6 +3,8 @@
package enrich
import (
"os"
"path/filepath"
"testing"
"codeberg.org/anassaeneroi/enodia-sentinal/go-agent/internal/model"
@ -54,3 +56,21 @@ func TestBuildCapsAttackerControlledIndicators(t *testing.T) {
t.Fatal("indicator caps were not applied")
}
}
func TestCollectSlowAddsInjectedPackageOwnership(t *testing.T) {
directory := t.TempDir()
exe := filepath.Join(directory, "payload")
if err := os.WriteFile(exe, []byte("payload"), 0o700); err != nil {
t.Fatal(err)
}
result := CollectSlow([]Process{{PID: 42, Exe: exe}}, []string{exe}, func(path string) string {
if path == exe {
return "example-package 1.0-1"
}
return ""
})
if result.Processes[42]["package_owner"] != "example-package 1.0-1" ||
result.Files[exe]["package_owner"] != "example-package 1.0-1" {
t.Fatalf("result=%#v", result)
}
}