github.com/aporeto-inc/trireme-lib@v10.358.0+incompatible/monitor/extractors/uid.go (about) 1 package extractors 2 3 import ( 4 "fmt" 5 "strconv" 6 "strings" 7 8 "go.aporeto.io/trireme-lib/common" 9 "go.aporeto.io/trireme-lib/policy" 10 "go.aporeto.io/trireme-lib/utils/cgnetcls" 11 ) 12 13 // UIDMetadataExtractor is a metadata extractor for uid/gid. 14 func UIDMetadataExtractor(event *common.EventInfo) (*policy.PURuntime, error) { 15 16 runtimeTags := policy.NewTagStore() 17 18 for _, tag := range event.Tags { 19 parts := strings.SplitN(tag, "=", 2) 20 if len(parts) != 2 { 21 return nil, fmt.Errorf("invalid tag: %s", tag) 22 } 23 // TODO: Remove OLDTAGS 24 runtimeTags.AppendKeyValue("@sys:"+parts[0], parts[1]) 25 runtimeTags.AppendKeyValue("@app:linux:"+parts[0], parts[1]) 26 } 27 28 if event.Name == "" { 29 event.Name = event.PUID 30 } 31 32 // TODO: improve with additional information here. 33 options := &policy.OptionsType{ 34 CgroupName: event.PUID, 35 CgroupMark: strconv.FormatUint(cgnetcls.MarkVal(), 10), 36 UserID: event.PUID, 37 Services: event.Services, 38 } 39 40 runtimeIps := policy.ExtendedMap{"bridge": "0.0.0.0/0"} 41 42 return policy.NewPURuntime(event.Name, int(event.PID), "", runtimeTags, runtimeIps, common.UIDLoginPU, options), nil 43 }