id
stringlengths
2
7
text
stringlengths
17
51.2k
title
stringclasses
1 value
c7000
r.indexByPort.DeleteByID(puID, true) r.indexByPort.DeleteByID(puID, false) return nil }
c7001
!ok { return nil, fmt.Errorf("Service not found: %s", id) } return svc, nil }
c7002
%s", ip.String(), port, host) } portContext, ok := data.(*PortContext) if !ok { return nil, fmt.Errorf("Internal server error") } return portContext, nil }
c7003
sctx.PUContext, }, true, ); err != nil { return fmt.Errorf("Possible port overlap: %s", err) } if service.Type == policy.ServiceHTTP && service.PublicNetworkInfo != nil { if err := r.indexByPort.Add( service.PublicNetworkInfo, sctx.PU.ContextID, &PortContext{ ID: sctx.P...
c7004
} if err := r.updateExposedPortAssociations(sctx, service, secrets); err != nil { return err } } return nil }
c7005
} if err := sctx.dependentServiceCache.Add( service.NetworkInfo, sctx.PU.ContextID, serviceData, false, ); err != nil { return fmt.Errorf("Possible overlap in dependent services: %s", err) } } return nil }
c7006
|| !m[v] { portSpec, err := portspec.NewPortSpecFromString(v, k) if err != nil { continue } d.contextIDFromTCPPort.AddPortSpec(portSpec) err = iptablesInstance.AddPortToPortSet(k, v) if err != nil { zap.L().Error("Failed to add port to portset", zap.String("context", k), zap.String("p...
c7007
} if attr, ok := claim.(string); ok { attributes = append(attributes, key+"="+attr) } if kv, ok := claim.(map[string]interface{}); ok { for ikey, ivalue := range kv { if attr, ok := ivalue.(string); ok { attributes = append(attributes, key+":"+ikey+"="+attr) } } } return attributes }
c7008
for i := 0; i < d.numberOfQueues; i++ { d.eventnotifications[i] = make(chan *events.Message, 1000) d.stopprocessor[i] = make(chan bool) } // Add handlers for the events that we know how to process d.addHandler(EventCreate, d.handleCreateEvent) d.addHandler(EventStart, d.handleStartEvent) d.addHandler(EventDi...
c7009
// Syncing all Existing containers depending on MonitorSetting if err := d.resyncContainers(ctx, containers); err != nil { zap.L().Error("Unable to sync existing containers", zap.Error(err)) } } else { // Starting the eventListener and wait to hear on channel for it to be ready. // We are not doing resync....
c7010
siphash.Hash(key0, key1, []byte(key)) d.eventnotifications[int(h%uint64(d.numberOfQueues))] <- r }
c7011
zap.String("action", event.Action), zap.Error(err), ) } continue } case <-ctx.Done(): return } } }(i) } }
c7012
zap.String("action", message.Action), zap.String("ID", message.ID), ) d.sendRequestToQueue(&message) case err := <-errs: if err != nil && err != io.EOF { zap.L().Warn("Received docker event error", zap.Error(err), ) } case <-ctx.Done(): return } } }
c7013
containers, err := d.dockerClient.ContainerList(ctx, options) if err != nil { return fmt.Errorf("unable to get container list: %s", err) } return d.resyncContainers(ctx, containers) }
c7014
runtime.SetPUType(common.LinuxProcessPU) } runtime.SetOptions(runtime.Options()) if err := d.config.Policy.HandlePUEvent(ctx, puID, event, runtime); err != nil { zap.L().Error("Unable to sync existing Container", zap.String("dockerID", c.ID), zap.Error(err), ) } // if the container has hostn...
c7015
found") } mark, _ := strconv.ParseUint(markval, 10, 32) if err := d.netcls.AssignMark(puID, mark); err != nil { return err } } else { // Add the container pid that is linked to hostnet to // the cgroup of the parent container. pausePUID = getPausePUID(policyExtensions(runtimeInfo)) } return d.ne...
c7016
return d.metadataExtractor(dockerInfo) } return extractors.DefaultMetadataExtractor(dockerInfo) }
c7017
constants.DockerHostMode { options := hostModeOptions(container) options.PolicyExtensions = runtime.Options().PolicyExtensions runtime.SetOptions(*options) runtime.SetPUType(common.LinuxProcessPU) } runtime.SetOptions(runtime.Options()) return d.config.Policy.HandlePUEvent(ctx, puID, tevents.EventCreate, ...
c7018
} d.config.Collector.CollectContainerEvent(&collector.ContainerRecord{ ContextID: event.ID, IPAddress: nil, Tags: nil, Event: collector.ContainerFailed, }) return fmt.Errorf("unable to start container because of policy: container %s killed: %s", event.ID, err) } return fmt.Errorf...
c7019
handle delete event", zap.Error(err), ) } if err := d.netcls.DeleteCgroup(puID); err != nil { zap.L().Warn("Failed to clean netcls group", zap.String("puID", puID), zap.Error(err), ) } return nil }
c7020
runtime := policy.NewPURuntimeWithDefaults() runtime.SetOptions(runtime.Options()) return d.config.Policy.HandlePUEvent(ctx, puID, tevents.EventPause, runtime) }
c7021
runtime.SetOptions(runtime.Options()) return d.config.Policy.HandlePUEvent(ctx, puID, tevents.EventUnpause, runtime) }
c7022
<- true }() select { case <-ctx.Done(): return nil case <-time.After(dockerInitializationWait): return fmt.Errorf("Unable to connect to docker daemon") case <-done: } return nil }
c7023
t.Certificate, t.CA, t.TokenCAs, t.Token, t.Compressed) default: return nil, fmt.Errorf("Unsupported type") } }
c7024
remoteHosts: map[string]entryList{}, localHosts: map[string]entryList{}, } }
c7025
data: data, id: id, } if err := s.addPorts(e, record, local); err != nil { return err } if err := s.addHostService(e, record, local); err != nil { return err } return s.addIPService(e, record, local) }
c7026
if host != "" { if data := s.findHost(host, port, local); data != nil { return data } } return s.findIP(ip, port, local) }
c7027
defer s.RUnlock() for _, spec := range s.localPorts { if spec.id == id { return spec.data, spec.ports } } return nil, nil }
c7028
} for l, prefix := range prefixes { for ip, ports := range prefix { prefix[ip] = deleteMatchingPorts(ports, id) if len(prefix[ip]) == 0 { delete(prefix, ip) } } if len(prefix) == 0 { delete(prefixes, l) } } }
c7029
if spec.ports.Overlaps(e.Ports) { return fmt.Errorf("service port overlap in the global port list: %+v %s", e.Addresses, e.Ports.String()) } } s.localPorts = append(s.localPorts, record) return nil }
c7030
*policy.PUInfo) error { return nil }
c7031
mock.recorder = &MockMonitorMockRecorder{mock} return mock }
c7032
ctrl} mock.recorder = &MockImplementationMockRecorder{mock} return mock }
c7033
interface{}) error { ret := m.ctrl.Call(m, "SetupConfig", registerer, cfg) ret0, _ := ret[0].(error) return ret0 }
c7034
reflect.TypeOf((*MockImplementation)(nil).SetupConfig), registerer, cfg) }
c7035
*config.ProcessorConfig) { m.ctrl.Call(m, "SetupHandlers", c) }
c7036
mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetupHandlers", reflect.TypeOf((*MockImplementation)(nil).SetupHandlers), c) }
c7037
error) { return ipset.New(name, hasht, p) }
c7038
return &ipset.IPSet{ Name: name, } }
c7039
continue } ips := i.GetIpset(s) if err := ips.Destroy(); err != nil { return ipset.DestroyAll() } } return nil }
c7040
Monitor configuration cannot change at this time. // TODO: return nil }
c7041
failure = true } } if failure { return fmt.Errorf("Monitor resync failed: %s", errs) } return nil }
c7042
err != nil { continue } // check for host pu and add its ports to the end. if puInfo.Runtime.PUType() == common.HostPU { d.contextIDFromUDPPort.AddPortSpecToEnd(portSpec) } else { d.contextIDFromUDPPort.AddPortSpec(portSpec) } } } else { d.puFromIP = pu } // pucontext launches a go...
c7043
port), zap.Error(err), ) } } for _, port := range pu.UDPPorts() { if err := d.contextIDFromUDPPort.RemoveStringPorts(port); err != nil { zap.L().Debug("Unable to remove cache entry during unenforcement", zap.String("UDPPort", port), zap.Error(err), ) } } // Cleanup the contextID cache ...
c7044
0 { networks = []string{"0.0.0.0/1", "128.0.0.0/1"} } d.targetNetworks = acls.NewACLCache() targetacl := createPolicy(networks) return d.targetNetworks.AddRuleList(targetacl) }
c7045
d.conntrack = conntrackClient } d.startApplicationInterceptor(ctx) d.startNetworkInterceptor(ctx) go d.nflogger.Run(ctx) return nil }
c7046
contextID, err := d.contextIDFromUDPPort.GetSpecValueFromPort(port) if err != nil { zap.L().Debug("Could not find PU context for UDP server port ", zap.Uint16("port", port)) return nil, errPortNotFound } pu, err := d.puFromContextID.Get(contextID) if err != nil { return nil, errContextIDNotFound ...
c7047
if err := ioutil.WriteFile(filepath.Join(basePath, s.TriremePath, cgroupname, markFile), []byte(markval), 0644); err != nil { return fmt.Errorf("failed to write to net_cls.classid file for new cgroup: %s", err) } return nil }
c7048
exist: %s", err) } PID := []byte(strconv.Itoa(pid)) if err := syscall.Kill(pid, 0); err != nil { return nil } if err := ioutil.WriteFile(filepath.Join(basePath, s.TriremePath, cgroupname, procs), PID, 0644); err != nil { return fmt.Errorf("cannot add process: %s", err) } return nil }
c7049
if !strings.Contains(string(data), strconv.Itoa(pid)) { return errors.New("cannot cleanup process. process is not a part of this cgroup") } if err := ioutil.WriteFile(filepath.Join(basePath, procs), []byte(strconv.Itoa(pid)), 0644); err != nil { return fmt.Errorf("cannot clean up process: %s", err) } return ...
c7050
err = os.Remove(filepath.Join(basePath, s.TriremePath, cgroupname)) if err != nil { return fmt.Errorf("unable to delete cgroup %s: %s", cgroupname, err) } return nil }
c7051
when removing Trireme Base Path", zap.Error(err)) } return true } return false }
c7052
return []string{}, fmt.Errorf("cannot read procs file: %s", err) } procs := []string{} for _, line := range strings.Split(string(data), "\n") { if len(line) > 0 { procs = append(procs, line) } } return procs, nil }
c7053
len(cgroups)) for i := 0; i < len(cgroups); i++ { names[i] = cgroups[i].Name() } return names }
c7054
markchan: make(chan uint64), ReleaseAgentPath: "", TriremePath: "", } return controller }
c7055
ReleaseAgentPath: binpath, TriremePath: "", } if releasePath != "" { controller.ReleaseAgentPath = releasePath } if triremepath != "" { controller.TriremePath = triremepath } return controller }
c7056
the token results to accelerate performance tokenCache: gcache.New(2048).LRU().Expiration(20 * time.Second).Build(), } }
c7057
defer p.Unlock() p.secrets = s p.globalCert = globalCert }
c7058
id, }, Profile: profile, Scopes: scopes, } token, err := jwt.NewWithClaims(jwt.SigningMethodES256, claims).SignedString(key) if err != nil { return "", err } localCache.AddOrUpdate(id, token) return token, nil }
c7059
empty from event info") } if len(eventInfo.PUID) < 12 { return "", errors.New("puid smaller than 12 characters") } return eventInfo.PUID[:12], nil }
c7060
tracker is unable to dial netlink: %s", err) } client := &Client{conn: c} go func() { <-ctx.Done() client.conn.Close() // nolint errcheck }() return client, nil }
c7061
conntrack.NewFlow(protonum, 0, ipSrc, ipDst, srcport, dstport, 0, newmark) return c.conn.Update(f) }
c7062
f.TupleReply.IP.SourceAddress = srcAddr f.TupleReply.IP.DestinationAddress = destAddr f.TupleReply.Proto.SourcePort = srcPort f.TupleReply.Proto.DestinationPort = destPort f.TupleReply.Proto.Protocol = proto return f }
c7063
v := range c.Monitors { buf += fmt.Sprintf("{%d:%+v},", k, v) } buf += fmt.Sprintf("}") return buf }
c7064
nil { return fmt.Errorf("Missing configuration: puHandler") } return nil }
c7065
least one flow is collected if record.Count == 0 { record.Count = 1 } c.Lock() defer c.Unlock() if r, ok := c.Flows[hash]; ok { r.Count = r.Count + record.Count return } c.Flows[hash] = record c.Flows[hash].Tags = record.Tags }
c7066
_, ok := c.ProcessedUsers[record.ID]; !ok { c.Users[record.ID] = record c.ProcessedUsers[record.ID] = true } }
c7067
defer c.Unlock() zap.L().Debug("Collected Packet Event") c.DatapathPacketReports = append(c.DatapathPacketReports, report) }
c7068
return nil, fmt.Errorf("Error Building config from Kubeconfig: %v", err) } return kubernetes.NewForConfig(config) }
c7069
interface{}) { if err := deleteFunc(deletedApiStruct.(*api.Pod)); err != nil { zap.L().Error("Error while handling Delete Pod", zap.Error(err)) } }, func(oldApiStruct, updatedApiStruct interface{}) { if err := updateFunc(oldApiStruct.(*api.Pod), updatedApiStruct.(*api.Pod)); err != nil { zap.L().E...
c7070
return nil, fmt.Errorf("error getting Kubernetes labels & IP for pod %v : %v ", podName, err) } return targetPod, nil }
c7071
int) (net.Conn, error) { return nil, nil }
c7072
(net.Listener, error) { return nil, nil }
c7073
return p.originalIP, p.originalPort }
c7074
{ return c.nc.Read(b) }
c7075
uidAddr.Address = "NotAvailable" } uidAddr.Address = strconv.Itoa(int(cred.Uid)) + ":" + strconv.Itoa(int(cred.Gid)) + ":" + strconv.Itoa(int(cred.Pid)) return uidAddr }
c7076
return c.nc.SetDeadline(t) }
c7077
return c.nc.SetReadDeadline(t) }
c7078
return c.nc.SetWriteDeadline(t) }
c7079
return nil, err } p.max = uint16(port) } else { port, err := strconv.Atoi(tcpport) if err != nil { return nil, err } p.min = uint16(port) p.max = p.min } if p.min > p.max { return nil, errors.New("min port is greater than max port") } p.policy = policy return p, nil }
c7080
event.PUID, CgroupMark: strconv.FormatUint(cgnetcls.MarkVal(), 10), Services: event.Services, } runtimeIps := policy.ExtendedMap{"bridge": "0.0.0.0/0"} return policy.NewPURuntime(event.Name, int(event.PID), "", runtimeTags, runtimeIps, event.PUType, options), nil }
c7081
nil { return userdata } gids, err := userid.GroupIds() if err != nil { return userdata } for i := 0; i < len(gids); i++ { userdata = append(userdata, "gids:"+gids[i]) group, err := user.LookupGroupId(gids[i]) if err != nil { continue } userdata = append(userdata, "groups:"+group.Name) } retu...
c7082
[]string{} } libraries, _ := f.ImportedLibraries() return libraries }
c7083
nil { return false } if mode != constants.LocalServer { return false } return runtime.PUType() == common.HostPU }
c7084
return nil, fmt.Errorf("error while adding provided CA") } return &AppProxy{ collector: c, tokenaccessor: tp, secrets: s, puFromID: puFromID, cert: certificate, clients: cache.NewCache("clients"), systemCAPool: systemPool, registry: serviceregistry.NewServiceReg...
c7085
int(t)), zap.Error(err)) } if err := server.ShutDown(); err != nil { zap.L().Debug("Unable to shutdown client server", zap.Error(err)) } } // Terminate the connection multiplexer. client.protomux.Close() // Remove the client from the cache. return p.clients.Remove(puID) }
c7086
defer p.Unlock() p.secrets = secret return nil }
c7087
// Start the corresponding proxy switch ltype { case common.HTTPApplication, common.HTTPSApplication, common.HTTPNetwork, common.HTTPSNetwork: c := httpproxy.NewHTTPProxy(p.collector, puID, caPool, appproxy, proxyMarkInt, p.secrets, p.registry) return c, c.RunNetworkServer(ctx, listener, encrypted) default: ...
c7088
zap.L().Warn("Failed to add Services CA") } } // Create the TLS certificate tlsCert, err := tls.X509KeyPair([]byte(certPEM), []byte(keyPEM)) if err != nil { return false, fmt.Errorf("Invalid certificates: %s", err) } for _, server := range client.netserver { server.UpdateSecrets(&tlsCert, caPool, p.secre...
c7089
d.filterQueue.GetNetworkQueueStart()+i, d.filterQueue.GetNetworkQueueSize(), nfqueue.NfDefaultPacketSize, networkCallback, errorCallback, d) <-time.After(3 * time.Second) } if err != nil { zap.L().Fatal("Unable to initialize netfilter queue", zap.Error(err)) } } } }
c7090
d.filterQueue.GetApplicationQueueStart()+i, d.filterQueue.GetApplicationQueueSize(), nfqueue.NfDefaultPacketSize, appCallBack, errorCallback, d) <-time.After(3 * time.Second) } if err != nil { zap.L().Fatal("Unable to initialize netfilter queue", zap.Int("QueueNum", int(d.filterQueue.GetNetworkQueueStart...
c7091
if ips == nil { ips = ExtendedMap{} } if options == nil { options = &OptionsType{} } return &PURuntime{ puType: puType, tags: tags, ips: ips, options: options, pid: pid, nsPath: nsPath, name: name, } }
c7092
Pid: r.pid, NSPath: r.nsPath, Name: r.name, IPAddresses: r.ips, Tags: r.tags, Options: r.options, }) }
c7093
r.name = a.Name r.ips = a.IPAddresses r.tags = a.Tags r.options = a.Options r.puType = a.PUType return nil }
c7094
r.Unlock() return r.pid }
c7095
defer r.Unlock() r.pid = pid }
c7096
defer r.Unlock() return r.nsPath }
c7097
defer r.Unlock() r.nsPath = nsPath }
c7098
defer r.Unlock() r.options = &options }
c7099
defer r.Unlock() return r.name }