anchor dict | positive dict | negative dict |
|---|---|---|
{
"audio": "",
"image": "",
"text": "func (mr *MockRPCClientMockRecorder) NewRPCClient(contextID, channel, rpcSecret interface{}) *gomock.Call {\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock,",
"video": ""
} | {
"audio": "",
"image": "",
"text": " \"NewRPCClient\", reflect.TypeOf((*MockRPCClient)(nil).NewRPCClient), contextID, channel, rpcSecret)\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"ChangeConnectionID\", reflect.TypeOf((*MockCryptoSetup)(nil).ChangeConnectionID), arg0)\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (m *MockRPCClient) GetRPCClient(contextID string) (*rpcwrapper.RPCHdl, error) {\n\tret",
"video": ""
} | {
"audio": "",
"image": "",
"text": " := m.ctrl.Call(m, \"GetRPCClient\", contextID)\n\tret0, _ := ret[0].(*rpcwrapper.RPCHdl)\n\tret1, _ := ret[1].(error)\n\treturn ret0, ret1\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " {\n\terr = cache.ListAll(s.indexer, selector, func(m interface{}) {\n\t\tret = append(ret, m.(*v1.ConfigMap))\n\t})\n\treturn ret, err\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (m *MockRPCClient) RemoteCall(contextID, methodName string, req *rpcwrapper.Request, resp",
"video": ""
} | {
"audio": "",
"image": "",
"text": " *rpcwrapper.Response) error {\n\tret := m.ctrl.Call(m, \"RemoteCall\", contextID, methodName, req, resp)\n\tret0, _ := ret[0].(error)\n\treturn ret0\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\tctx.Resp.Header().Set(\"Expires\", \"0\")\n\tctx.Resp.Header().Set(\"Cache-Control\", \"must-revalidate\")\n\tctx.Resp.Header().Set(\"Pragma\", \"public\")\n\thttp.ServeFile(ctx.Resp, ctx.Req.Request, file)\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (mr *MockRPCClientMockRecorder) RemoteCall(contextID, methodName, req, resp interface{}) *gomock.Call {\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock,",
"video": ""
} | {
"audio": "",
"image": "",
"text": " \"RemoteCall\", reflect.TypeOf((*MockRPCClient)(nil).RemoteCall), contextID, methodName, req, resp)\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"ChangeConnectionID\", reflect.TypeOf((*MockCryptoSetup)(nil).ChangeConnectionID), arg0)\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (m *MockRPCClient) DestroyRPCClient(contextID string) {\n\tm.ctrl.Call(m,",
"video": ""
} | {
"audio": "",
"image": "",
"text": " \"DestroyRPCClient\", contextID)\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " string) {\n\tm.ctrl.Call(m, \"Delete\", arg0)\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (mr *MockRPCClientMockRecorder) DestroyRPCClient(contextID interface{}) *gomock.Call {\n\treturn",
"video": ""
} | {
"audio": "",
"image": "",
"text": " mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"DestroyRPCClient\", reflect.TypeOf((*MockRPCClient)(nil).DestroyRPCClient), contextID)\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\n\t\treturn nil, ErrInvalidParams()\n\t}\n\n\tmr.m.RLock()\n\tmd, ok := mr.r[r.Method]\n\tmr.m.RUnlock()\n\tif !ok {\n\t\treturn nil, ErrMethodNotFound()\n\t}\n\n\treturn md.Handler, nil\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (m *MockRPCClient) ContextList() []string {\n\tret := m.ctrl.Call(m, \"ContextList\")\n",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\tret0, _ := ret[0].([]string)\n\treturn ret0\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"GetAckFrame\", arg0)\n\tret0, _ := ret[0].(*wire.AckFrame)\n\treturn ret0\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (mr *MockRPCClientMockRecorder) CheckValidity(req, secret interface{}) *gomock.Call {\n\treturn",
"video": ""
} | {
"audio": "",
"image": "",
"text": " mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"CheckValidity\", reflect.TypeOf((*MockRPCClient)(nil).CheckValidity), req, secret)\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " internal.Call(c, \"user\", \"CheckOAuthSignature\", req, res)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\treturn *res.OauthConsumerKey, err\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (m *MockRPCServer) StartServer(ctx context.Context, protocol, path string, handler interface{}) error {\n\tret := m.ctrl.Call(m, \"StartServer\", ctx,",
"video": ""
} | {
"audio": "",
"image": "",
"text": " protocol, path, handler)\n\tret0, _ := ret[0].(error)\n\treturn ret0\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " bool) error {\n\tret := m.ctrl.Call(m, \"VolumeRemove\", ctx, volumeID, force)\n\tret0, _ := ret[0].(error)\n\treturn ret0\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (mr *MockRPCServerMockRecorder) StartServer(ctx, protocol, path, handler interface{}) *gomock.Call {\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock,",
"video": ""
} | {
"audio": "",
"image": "",
"text": " \"StartServer\", reflect.TypeOf((*MockRPCServer)(nil).StartServer), ctx, protocol, path, handler)\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"ChangeConnectionID\", reflect.TypeOf((*MockCryptoSetup)(nil).ChangeConnectionID), arg0)\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (mr *MockRPCServerMockRecorder) ProcessMessage(req, secret interface{}) *gomock.Call {\n\treturn",
"video": ""
} | {
"audio": "",
"image": "",
"text": " mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"ProcessMessage\", reflect.TypeOf((*MockRPCServer)(nil).ProcessMessage), req, secret)\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " internal.Call(c, \"user\", \"CheckOAuthSignature\", req, res)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\treturn *res.OauthConsumerKey, err\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (m *MockRPCServer) CheckValidity(req *rpcwrapper.Request, secret string)",
"video": ""
} | {
"audio": "",
"image": "",
"text": " bool {\n\tret := m.ctrl.Call(m, \"CheckValidity\", req, secret)\n\tret0, _ := ret[0].(bool)\n\treturn ret0\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\t}\n\treturn func(req *http.Request, ctx *ProxyCtx) bool {\n\t\t_, ok := hostSet[req.URL.Host]\n\t\treturn ok\n\t}\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (w *WatchPodMapper) Map(obj handler.MapObject) []reconcile.Request {\n\tpod, ok := obj.Object.(*corev1.Pod)\n\tif !ok {\n\t\treturn nil\n\t}\n\n\tif pod.Spec.NodeName != w.nodeName {\n\t\treturn nil\n\t}\n\n\tif pod.Spec.HostNetwork && !w.enableHostPods {\n\t\treturn",
... | {
"audio": "",
"image": "",
"text": " nil\n\t}\n\n\treturn []reconcile.Request{\n\t\t{\n\t\t\tNamespacedName: types.NamespacedName{\n\t\t\t\tName: pod.Name,\n\t\t\t\tNamespace: pod.Namespace,\n\t\t\t},\n\t\t},\n\t}\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " !deleted && !volumeutil.IsPodTerminated(pod, pod.Status) && pod.Spec.NodeName != \"\" {\n\t\treturn\n\t}\n\n\tklog.V(4).Infof(\"Got event on pod %s/%s\", pod.Namespace, pod.Name)\n\n\t// Enqueue all PVCs that the pod uses\n\tfor _, volume := range pod.Spec.Volumes {\n\t\tif v... |
{
"audio": "",
"image": "",
"text": "func NewPKIIssuer(privateKey *ecdsa.PrivateKey) PKITokenIssuer",
"video": ""
} | {
"audio": "",
"image": "",
"text": " {\n\n\treturn &tokenManager{\n\t\tprivateKey: privateKey,\n\t\tsignMethod: jwt.SigningMethodES256,\n\t}\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\n\treturn m.SigningIdentity.PrivateKey()\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func NewPKIVerifier(publicKeys []*ecdsa.PublicKey, cacheValidity time.Duration) PKITokenVerifier {\n\n\tvalidity := defaultValidity * time.Second\n\tif cacheValidity > 0 {\n\t\tvalidity = cacheValidity\n\t}\n\n\treturn &tokenManager{\n\t\tpublicKeys: publicKeys,",
"video": "... | {
"audio": "",
"image": "",
"text": "\n\t\tsignMethod: jwt.SigningMethodES256,\n\t\tkeycache: cache.NewCacheWithExpiration(\"PKIVerifierKey\", validity),\n\t\tvalidity: validity,\n\t}\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " {\n\treturn time.Duration(1<<uint(i)) * time.Second\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (p *tokenManager) Verify(token []byte) (*DatapathKey, error) {\n\n\ttokenString := string(token)\n\tif pk, err := p.keycache.Get(tokenString); err == nil {\n\t\treturn pk.(*DatapathKey), err\n\t}\n\n\tclaims := &verifierClaims{}\n\tvar JWTToken *jwt.Token\n\tvar err error... | {
"audio": "",
"image": "",
"text": "\tcontinue\n\t\t}\n\n\t\tdp := &DatapathKey{\n\t\t\tPublicKey: KeyFromClaims(claims),\n\t\t\tTags: claims.Tags,\n\t\t}\n\n\t\tif time.Now().Add(p.validity).Unix() <= claims.ExpiresAt {\n\t\t\tp.keycache.AddOrUpdate(tokenString, dp)\n\t\t}\n\t\treturn dp, nil\n\t}\n\n\tret... | {
"audio": "",
"image": "",
"text": " token.Method.(*jwt.SigningMethodHMAC); !ok {\n\t\t\t\t//TODO: On ne passe jamais à l'intérieur\n\t\t\t\treturn nil, fmt.Errorf(\"Unexpected signing method: %v\", token.Header[\"alg\"])\n\t\t\t}\n\t\t\treturn []byte(cnf.Jwt.Key), nil\n\t\t})\n\t\tif err == nil && token.Valid {... |
{
"audio": "",
"image": "",
"text": "func (p *tokenManager) CreateTokenFromCertificate(cert *x509.Certificate, tags []string) ([]byte, error) {\n\n\t// Combine the application claims with the standard claims\n\tclaims := &verifierClaims{\n\t\tX: cert.PublicKey.(*ecdsa.PublicKey).X,\n\t\tY: cert.PublicKey.(*... | {
"audio": "",
"image": "",
"text": "\n\t// Create the token and sign with our key\n\tstrtoken, err := jwt.NewWithClaims(p.signMethod, claims).SignedString(p.privateKey)\n\tif err != nil {\n\t\treturn []byte{}, err\n\t}\n\n\treturn []byte(strtoken), nil\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " formatKeyID(cert.AuthorityKeyId),\n\t\tSKI: formatKeyID(cert.SubjectKeyId),\n\t\tSerialNumber: cert.SerialNumber.String(),\n\t}\n\tfor _, ip := range cert.IPAddresses {\n\t\tc.SANs = append(c.SANs, ip.String())\n\t}\n\treturn c\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func KeyFromClaims(claims *verifierClaims) *ecdsa.PublicKey {\n\treturn &ecdsa.PublicKey{\n\t",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\tCurve: elliptic.P256(),\n\t\tX: claims.X,\n\t\tY: claims.Y,\n\t}\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\n\t\t\treturn nil,err\n\t\t}\n\t}\n\n\tvar ok bool\n\t\t\n\tif key,ok=parsedKey.(*ecdsa.PrivateKey);!ok {\n\t\treturn nil, errors.New(\"Ecc.ReadPrivate(): Key is not valid *ecdsa.PrivateKey\")\n\t}\n\t\n\treturn key,nil\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func NewTCPProxy(\n\ttp tokenaccessor.TokenAccessor,\n\tc collector.EventCollector,\n\tpuContext string,\n\tregistry *serviceregistry.Registry,\n\tcertificate *tls.Certificate,\n\tcaPool *x509.CertPool,\n) *Proxy {\n\n\tlocalIPs := markedconn.GetInterfaces()\n\n\treturn &Proxy... | {
"audio": "",
"image": "",
"text": " c,\n\t\ttokenaccessor: tp,\n\t\tpuContext: puContext,\n\t\tregistry: registry,\n\t\tlocalIPs: localIPs,\n\t\tcertificate: certificate,\n\t\tca: caPool,\n\t}\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\n\treturn func(c *config) {\n\t\tc.tracerOptions.Collector.Host = satelliteHost\n\t}\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (p *Proxy) RunNetworkServer(ctx context.Context, listener net.Listener, encrypted bool) error {\n\n\t// Encryption is",
"video": ""
} | {
"audio": "",
"image": "",
"text": " done transparently for TCP.\n\tgo p.serve(ctx, listener)\n\n\treturn nil\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " func(ctx context.Context) error {\n\t\treturn UpdateTenant(ctx, config)\n\t}\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (p *Proxy) UpdateSecrets(cert *tls.Certificate, caPool *x509.CertPool, s secrets.Secrets, certPEM, keyPEM string) {\n\tp.Lock()\n",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\tdefer p.Unlock()\n\n\tp.certificate = cert\n\tp.ca = caPool\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " \"CERTIFICATE\", Bytes: certBytes})\n\tkeypem := pem.EncodeToMemory(pemBlockForKey(privateKey))\n\treturn certpem, keypem, nil\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (p *Proxy) handle(ctx context.Context, upConn net.Conn) {\n\tdefer upConn.Close() // nolint\n\tip, port := upConn.(*markedconn.ProxiedConnection).GetOriginalDestination()\n\n\tdownConn, err := p.downConnection(ctx, ip, port)\n\tif err != nil {\n\t\tflowproperties := &prox... | {
"audio": "",
"image": "",
"text": "\n\t\t}\n\n\t\tp.reportRejectedFlow(flowproperties, puContext.ManagementID(), \"default\", puContext, collector.UnableToDial, nil, nil)\n\t\treturn\n\t}\n\tdefer downConn.Close() // nolint\n\n\t// Now let us handle the state machine for the down connection\n\tisEncrypted, err ... | {
"audio": "",
"image": "",
"text": " PIDs of the user are gone, we can delete the user context.\n\tif err := u.config.Policy.HandlePUEvent(ctx, userID, common.EventStop, runtime); err != nil {\n\t\tzap.L().Warn(\"Failed to stop trireme PU \",\n\t\t\tzap.String(\"puID\", puID),\n\t\t\tzap.Error(err),\n\t\t)\n\t}\... |
{
"audio": "",
"image": "",
"text": "func (p *Proxy) downConnection(ctx context.Context, ip net.IP, port int) (net.Conn, error) {\n\n\traddr := &net.TCPAddr{\n\t\tIP: ip,\n\t\tPort: port,\n\t}\n\n",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\treturn markedconn.DialMarkedWithContext(ctx, \"tcp4\", raddr.String(), proxyMarkInt)\n\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " &NetAddress{\n\t\tIP: ip,\n\t\tPort: port,\n\t}\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (m *KubernetesMonitor) RefreshPUs(ctx context.Context, pod *api.Pod) error {\n\tif pod == nil {\n\t\treturn fmt.Errorf(\"pod is nil\")\n\t}\n\n\tpodNamespace := pod.GetNamespace()\n\tpodName := pod.GetName()\n\n\tpuIDs := m.cache.getPUIDsbyPod(podNamespace, podName)\n\n\t... | {
"audio": "",
"image": "",
"text": " far if it is a non managed container anyways.\n\t\tif !managedContainer {\n\t\t\tzap.L().Debug(\"unmanaged Kubernetes container\", zap.String(\"puID\", puid), zap.String(\"podNamespace\", podNamespace), zap.String(\"podName\", podName))\n\t\t\tcontinue\n\t\t}\n\n\t\t// We kee... | {
"audio": "",
"image": "",
"text": "\n\t\t}\n\t\tif now.After(*ps.deadline) {\n\t\t\tklog.Warningf(\"Pod %s/%s expired\", ps.pod.Namespace, ps.pod.Name)\n\t\t\tif err := cache.expirePod(key, ps); err != nil {\n\t\t\t\tklog.Errorf(\"ExpirePod failed for %s: %v\", key, err)\n\t\t\t}\n\t\t}\n\t}\n}",
"video": ""
... |
{
"audio": "",
"image": "",
"text": "func getKubernetesInformation(runtime policy.RuntimeReader) (string, string, error) {\n\tpodNamespace, ok := runtime.Tag(KubernetesPodNamespaceIdentifier)\n\tif !ok {\n\t",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\treturn \"\", \"\", fmt.Errorf(\"Error getting Kubernetes Pod namespace\")\n\t}\n\tpodName, ok := runtime.Tag(KubernetesPodNameIdentifier)\n\tif !ok {\n\t\treturn \"\", \"\", fmt.Errorf(\"Error getting Kubernetes Pod name\")\n\t}\n\n\treturn podNamespace, podName, nil\n}",
... | {
"audio": "",
"image": "",
"text": " string, _ string) (string, error) {\n\treturn \"\", nil\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (m *KubernetesMonitor) decorateRuntime(puID string, runtimeInfo policy.RuntimeReader, event common.Event,\n\tpodName, podNamespace string) (err error) {\n\n\t// Do nothing on other events apart from start event.\n\tif event != common.EventStart {\n\t\treturn nil\n\t}\n\n\... | {
"audio": "",
"image": "",
"text": " {\n\t\t\tcontinue\n\t\t}\n\n\t\tif isPodInfraContainer(rtm) && rtm.PUType() == common.LinuxProcessPU {\n\t\t\tpausePUID = id\n\t\t\tbreak\n\t\t}\n\n\t\t// if the pause container is not host net container, nothing to do.\n\t\tif isPodInfraContainer(rtm) {\n\t\t\treturn nil\n\t... | {
"audio": "",
"image": "",
"text": "\n\t\t}\n\t}\n\n\tif event.EventType == common.EventStop || event.EventType == common.EventDestroy {\n\t\tregStop := regexp.MustCompile(\"^/trireme/[a-zA-Z0-9_]{1,11}$\")\n\t\tif event.Cgroup != \"\" && !regStop.Match([]byte(event.Cgroup)) {\n\t\t\treturn fmt.Errorf(\"Cgroup i... |
{
"audio": "",
"image": "",
"text": "func NewMockStatsClient(ctrl *gomock.Controller) *MockStatsClient {\n\tmock := &MockStatsClient{ctrl: ctrl}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\n\tmock.recorder = &MockStatsClientMockRecorder{mock}\n\treturn mock\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " {\n\tmock := &MockDockerMetadataClient{ctrl: ctrl}\n\tmock.recorder = &MockDockerMetadataClientMockRecorder{mock}\n\treturn mock\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (mr *MockStatsClientMockRecorder) SendStats() *gomock.Call {\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock,",
"video": ""
} | {
"audio": "",
"image": "",
"text": " \"SendStats\", reflect.TypeOf((*MockStatsClient)(nil).SendStats))\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"ChangeConnectionID\", reflect.TypeOf((*MockCryptoSetup)(nil).ChangeConnectionID), arg0)\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (d *Datapath) processNetUDPPacket(udpPacket *packet.Packet, context *pucontext.PUContext, conn *connection.UDPConnection) (action interface{}, claims *tokens.ConnectionClaims, err error) {\n\n\t// Extra check, just in case the caller didn't provide a connection.\n\tif con... | {
"audio": "",
"image": "",
"text": "\n\n\t\t// Process the synack header and claims of the other side.\n\t\taction, claims, err = d.processNetworkUDPSynAckPacket(udpPacket, context, conn)\n\t\tif err != nil {\n\t\t\tzap.L().Error(\"UDP Syn ack failed with\", zap.Error(err))\n\t\t\treturn nil, nil, err\n\t\t}\n\n... | {
"audio": "",
"image": "",
"text": "\t// If this ack packet is from client, Did we see an Application Syn packet before?\n\tconn, err = d.appOrigConnectionTracker.GetReset(hash, 0)\n\tif err == nil {\n\t\tif uerr := updateTimer(d.appOrigConnectionTracker, hash, conn.(*connection.TCPConnection)); uerr != nil {\n\... |
{
"audio": "",
"image": "",
"text": "func (d *Datapath) ProcessApplicationUDPPacket(p *packet.Packet) (conn *connection.UDPConnection, err error) {\n\n\tif d.packetLogs {\n\t\tzap.L().Debug(\"Processing application UDP packet \",\n\t\t\tzap.String(\"flow\", p.L4FlowHash()),\n\t\t)\n\t\tdefer zap.L().Debug(\"Finis... | {
"audio": "",
"image": "",
"text": "\n\tswitch conn.GetState() {\n\tcase connection.UDPStart:\n\t\t// Queue the packet. We will send it after we authorize the session.\n\t\tif err = conn.QueuePackets(p); err != nil {\n\t\t\t// unable to queue packets, perhaps queue is full. if start\n\t\t\t// machine is still in... | {
"audio": "",
"image": "",
"text": " beginning.\n\tif conn.GetState() == connection.UDPReceiverSendSynAck {\n\t\tconn.SynAckStop()\n\t}\n\n\t// Only start the retransmission timer once. Not on every packet.\n\tif err := d.writeWithRetransmit(udpPacket.GetBuffer(0), conn, conn.SynAckChannel()); err != nil {\n\t\t... |
{
"audio": "",
"image": "",
"text": "func (d *Datapath) triggerNegotiation(udpPacket *packet.Packet, context *pucontext.PUContext, conn *connection.UDPConnection) (err error) {\n\n\tudpOptions := packet.CreateUDPAuthMarker(packet.UDPSynMask)\n\n\tudpData, err := d.tokenAccessor.CreateSynPacketToken(context, &conn... | {
"audio": "",
"image": "",
"text": " transmit syn packet\")\n\t}\n\n\t// Populate the caches to track the connection\n\thash := udpPacket.L4FlowHash()\n\td.udpAppOrigConnectionTracker.AddOrUpdate(hash, conn)\n\td.udpSourcePortConnectionCache.AddOrUpdate(newPacket.SourcePortHash(packet.PacketTypeApplication), con... | {
"audio": "",
"image": "",
"text": " beginning.\n\tif conn.GetState() == connection.UDPReceiverSendSynAck {\n\t\tconn.SynAckStop()\n\t}\n\n\t// Only start the retransmission timer once. Not on every packet.\n\tif err := d.writeWithRetransmit(udpPacket.GetBuffer(0), conn, conn.SynAckChannel()); err != nil {\n\t\t... |
{
"audio": "",
"image": "",
"text": "func (d *Datapath) sendUDPSynAckPacket(udpPacket *packet.Packet, context *pucontext.PUContext, conn *connection.UDPConnection) (err error) {\n\n\t// Create UDP Option\n\tudpOptions := packet.CreateUDPAuthMarker(packet.UDPSynAckMask)\n\n\tudpData, err := d.tokenAccessor.CreateS... | {
"audio": "",
"image": "",
"text": " beginning.\n\tif conn.GetState() == connection.UDPReceiverSendSynAck {\n\t\tconn.SynAckStop()\n\t}\n\n\t// Only start the retransmission timer once. Not on every packet.\n\tif err := d.writeWithRetransmit(udpPacket.GetBuffer(0), conn, conn.SynAckChannel()); err != nil {\n\t\t... | {
"audio": "",
"image": "",
"text": "\t// If this ack packet is from client, Did we see an Application Syn packet before?\n\tconn, err = d.appOrigConnectionTracker.GetReset(hash, 0)\n\tif err == nil {\n\t\tif uerr := updateTimer(d.appOrigConnectionTracker, hash, conn.(*connection.TCPConnection)); uerr != nil {\n\... |
{
"audio": "",
"image": "",
"text": "func (d *Datapath) processNetworkUDPSynPacket(context *pucontext.PUContext, conn *connection.UDPConnection, udpPacket *packet.Packet) (action interface{}, claims *tokens.ConnectionClaims, err error) {\n\n\tclaims, err = d.tokenAccessor.ParsePacketToken(&conn.Auth, udpPacket.Re... | {
"audio": "",
"image": "",
"text": "\n\treport, pkt := context.SearchRcvRules(claims.T)\n\tif pkt.Action.Rejected() {\n\t\td.reportUDPRejectedFlow(udpPacket, conn, txLabel, context.ManagementID(), context, collector.PolicyDrop, report, pkt, false)\n\t\treturn nil, nil, fmt.Errorf(\"connection rejected because of... | {
"audio": "",
"image": "",
"text": "\t// If this ack packet is from client, Did we see an Application Syn packet before?\n\tconn, err = d.appOrigConnectionTracker.GetReset(hash, 0)\n\tif err == nil {\n\t\tif uerr := updateTimer(d.appOrigConnectionTracker, hash, conn.(*connection.TCPConnection)); uerr != nil {\n\... |
{
"audio": "",
"image": "",
"text": "func (d *Datapath) sendUDPFinPacket(udpPacket *packet.Packet) (err error) {\n\n\t// Create UDP Option\n\tudpOptions := packet.CreateUDPAuthMarker(packet.UDPFinAckMask)\n\n\tudpPacket.CreateReverseFlowPacket(udpPacket.SourceAddress(), udpPacket.SourcePort())\n\n\t// Attach the ... | {
"audio": "",
"image": "",
"text": "\t// no need for retransmits here.\n\terr = d.udpSocketWriter.WriteSocket(udpPacket.GetBuffer(0))\n\tif err != nil {\n\t\tzap.L().Debug(\"Unable to send fin packet on raw socket\", zap.Error(err))\n\t\treturn err\n\t}\n\n\treturn nil\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " beginning.\n\tif conn.GetState() == connection.UDPReceiverSendSynAck {\n\t\tconn.SynAckStop()\n\t}\n\n\t// Only start the retransmission timer once. Not on every packet.\n\tif err := d.writeWithRetransmit(udpPacket.GetBuffer(0), conn, conn.SynAckChannel()); err != nil {\n\t\t... |
{
"audio": "",
"image": "",
"text": "func (d *Datapath) processUDPFinPacket(udpPacket *packet.Packet) (err error) { // nolint\n\n\t// add it to the udp fin cache. If we have already received the fin packet\n\t// for this flow. There is no need to change the connmark label again.\n\tif d.udpFinPacketTracker.AddOrU... | {
"audio": "",
"image": "",
"text": "\t}\n\n\tif err := d.udpSourcePortConnectionCache.Remove(udpPacket.SourcePortHash(packet.PacketTypeNetwork)); err != nil {\n\t\tzap.L().Debug(\"Failed to clean cache udpsourcePortConnectionCache\", zap.Error(err))\n\t}\n\n\tzap.L().Debug(\"Updating the connmark label\", zap.St... | {
"audio": "",
"image": "",
"text": " beginning.\n\tif conn.GetState() == connection.UDPReceiverSendSynAck {\n\t\tconn.SynAckStop()\n\t}\n\n\t// Only start the retransmission timer once. Not on every packet.\n\tif err := d.writeWithRetransmit(udpPacket.GetBuffer(0), conn, conn.SynAckChannel()); err != nil {\n\t\t... |
{
"audio": "",
"image": "",
"text": "func newRemoteEnforcer(\n\tctx context.Context,\n\tcancel context.CancelFunc,\n\tservice packetprocessor.PacketProcessor,\n\trpcHandle rpcwrapper.RPCServer,\n\tsecret string,\n\tstatsClient statsclient.StatsClient,\n\tcollector statscollector.Collector,\n\tdebugClient debugcli... | {
"audio": "",
"image": "",
"text": " != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\tif debugClient == nil {\n\t\tdebugClient, err = debugclient.NewDebugClient(collector)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\tprocMountPoint := os.Getenv(constants.EnvMountPoint)\n\tif procMountPoint == \"\" ... | {
"audio": "",
"image": "",
"text": "\tcollector.unaryInterceptors = append(collector.unaryInterceptors, u)\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (s *RemoteEnforcer) Enforce(req rpcwrapper.Request, resp *rpcwrapper.Response) error {\n\n\tif !s.rpcHandle.CheckValidity(&req, s.rpcSecret) {\n\t\tresp.Status = \"enforce message auth failed\"\n\t\treturn fmt.Errorf(resp.Status)\n\t}\n\n\tcmdLock.Lock()\n\tdefer cmdLock.... | {
"audio": "",
"image": "",
"text": "\n\t}\n\n\tpuInfo := &policy.PUInfo{\n\t\tContextID: payload.ContextID,\n\t\tPolicy: plc,\n\t\tRuntime: policy.NewPURuntimeWithDefaults(),\n\t}\n\n\tif s.enforcer == nil || s.supervisor == nil {\n\t\tresp.Status = \"enforcer not initialized - cannot enforce\"\n\t\treturn ... | {
"audio": "",
"image": "",
"text": "\tdefer resp.Body.Close()\n\n\tif resp.StatusCode < http.StatusOK || resp.StatusCode >= http.StatusBadRequest {\n\t\treturn fmt.Errorf(\"received error status code: %v\", resp.StatusCode)\n\t}\n\n\treturn nil\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (s *RemoteEnforcer) Unenforce(req rpcwrapper.Request, resp *rpcwrapper.Response) error {\n\n\tif !s.rpcHandle.CheckValidity(&req, s.rpcSecret) {\n\t\tresp.Status = \"unenforce message auth failed\"\n\t\treturn fmt.Errorf(resp.Status)\n\t}\n\n\tcmdLock.Lock()\n\tdefer cmdL... | {
"audio": "",
"image": "",
"text": "\n\t\treturn fmt.Errorf(resp.Status)\n\t}\n\n\tvar err error\n\n\t// If any error happens, cleanup everything on exit so that we can recover\n\t// by launcing a new remote.\n\tdefer func() {\n\t\tif err != nil {\n\t\t\ts.cleanup()\n\t\t}\n\t}()\n\n\tif err = s.supervisor.Unsup... | {
"audio": "",
"image": "",
"text": "\tdefer resp.Body.Close()\n\n\tif resp.StatusCode < http.StatusOK || resp.StatusCode >= http.StatusBadRequest {\n\t\treturn fmt.Errorf(\"received error status code: %v\", resp.StatusCode)\n\t}\n\n\treturn nil\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (s *RemoteEnforcer) SetTargetNetworks(req rpcwrapper.Request, resp *rpcwrapper.Response) error {\n\n\tvar err error\n\tif !s.rpcHandle.CheckValidity(&req, s.rpcSecret) {\n\t\tresp.Status = \"SetTargetNetworks message auth failed\" //nolint\n\t\treturn fmt.Errorf(resp.Stat... | {
"audio": "",
"image": "",
"text": " by launcing a new remote.\n\tdefer func() {\n\t\tif err != nil {\n\t\t\ts.cleanup()\n\t\t}\n\t}()\n\n\tif err = s.enforcer.SetTargetNetworks(payload.Configuration); err != nil {\n\t\treturn err\n\t}\n\n\terr = s.supervisor.SetTargetNetworks(payload.Configuration)\n\n\treturn ... | {
"audio": "",
"image": "",
"text": "\tdefer resp.Body.Close()\n\n\tif resp.StatusCode < http.StatusOK || resp.StatusCode >= http.StatusBadRequest {\n\t\treturn fmt.Errorf(\"received error status code: %v\", resp.StatusCode)\n\t}\n\n\treturn nil\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (s *RemoteEnforcer) EnforcerExit(req rpcwrapper.Request, resp *rpcwrapper.Response) error {",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\n\n\ts.cleanup()\n\n\ts.exit <- true\n\n\treturn nil\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\t}\n\treturn func(req *http.Request, ctx *ProxyCtx) bool {\n\t\t_, ok := hostSet[req.URL.Host]\n\t\treturn ok\n\t}\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (s *RemoteEnforcer) UpdateSecrets(req rpcwrapper.Request, resp *rpcwrapper.Response) error {\n\tvar err error\n\tif !s.rpcHandle.CheckValidity(&req, s.rpcSecret) {\n\t\tresp.Status = \"updatesecrets auth failed\"\n\t\treturn fmt.Errorf(resp.Status)\n\t}\n\n\tcmdLock.Lock(... | {
"audio": "",
"image": "",
"text": " func() {\n\t\tif err != nil {\n\t\t\ts.cleanup()\n\t\t}\n\t}()\n\n\tpayload := req.Payload.(rpcwrapper.UpdateSecretsPayload)\n\ts.secrets, err = secrets.NewSecrets(payload.Secrets)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\terr = s.enforcer.UpdateSecrets(s.secrets)\n\n\tret... | {
"audio": "",
"image": "",
"text": "\tdefer resp.Body.Close()\n\n\tif resp.StatusCode < http.StatusOK || resp.StatusCode >= http.StatusBadRequest {\n\t\treturn fmt.Errorf(\"received error status code: %v\", resp.StatusCode)\n\t}\n\n\treturn nil\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (s *RemoteEnforcer) EnableIPTablesPacketTracing(req rpcwrapper.Request, resp *rpcwrapper.Response) error {\n\n\tif !s.rpcHandle.CheckValidity(&req, s.rpcSecret) {\n\t\tresp.Status = \"enable iptable packet tracing auth failed\"\n\t\treturn fmt.Errorf(resp.Status)\n\t}\n\n... | {
"audio": "",
"image": "",
"text": " := s.supervisor.EnableIPTablesPacketTracing(context.Background(), payload.ContextID, payload.Interval); err != nil {\n\t\tresp.Status = err.Error()\n\t\treturn err\n\t}\n\n\tresp.Status = \"\"\n\treturn nil\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\tdefer resp.Body.Close()\n\n\tif resp.StatusCode < http.StatusOK || resp.StatusCode >= http.StatusBadRequest {\n\t\treturn fmt.Errorf(\"received error status code: %v\", resp.StatusCode)\n\t}\n\n\treturn nil\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (s *RemoteEnforcer) setupEnforcer(payload *rpcwrapper.InitRequestPayload) error {\n\n\tvar err error\n\n\ts.secrets, err = secrets.NewSecrets(payload.Secrets)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif s.enforcer, err = createEnforcer(\n\t\tpayload.MutualAuth,\n\t\tp... | {
"audio": "",
"image": "",
"text": "\n\t\tconstants.RemoteContainer,\n\t\ts.procMountPoint,\n\t\tpayload.ExternalIPCacheTimeout,\n\t\tpayload.PacketLogs,\n\t\tpayload.Configuration,\n\t); err != nil || s.enforcer == nil {\n\t\treturn fmt.Errorf(\"Error while initializing remote enforcer, %s\", err)\n\t}\n\n\tret... | {
"audio": "",
"image": "",
"text": " {\n\to.Payload = payload\n\treturn o\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (s *RemoteEnforcer) cleanup() {\n\n\tif s.supervisor != nil {\n\t\tif err := s.supervisor.CleanUp(); err != nil {\n\t\t\tzap.L().Error(\"unable to clean supervisor state\", zap.Error(err))\n\t\t}\n\t}\n\n\tif s.enforcer != nil {\n\t\tif err := s.enforcer.CleanUp(); err !=... | {
"audio": "",
"image": "",
"text": " clean enforcer state\", zap.Error(err))\n\t\t}\n\t}\n\n\tif s.service != nil {\n\t\tif err := s.service.Stop(); err != nil {\n\t\t\tzap.L().Error(\"unable to clean service state\", zap.Error(err))\n\t\t}\n\t}\n\n\ts.cancel()\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " err := extractRulesFromTemplate(tmpl, cfg)\n\tif err != nil {\n\t\tzap.L().Warn(\"unable to extract rules\", zap.Error(err))\n\t}\n\treturn rules\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func LaunchRemoteEnforcer(service packetprocessor.PacketProcessor) error {\n\n\t// Before doing anything validate that we are in the right namespace.\n\tif err := validateNamespace(); err != nil {\n\t\treturn err\n\t}\n\n\tctx, cancelMainCtx := context.WithCancel(context.Backg... | {
"audio": "",
"image": "",
"text": "\tflag := unix.SIGHUP\n\tif err := unix.Prctl(unix.PR_SET_PDEATHSIG, uintptr(flag), 0, 0, 0); err != nil {\n\t\treturn err\n\t}\n\n\trpcHandle := rpcwrapper.NewRPCServer()\n\tre, err := newRemoteEnforcer(ctx, cancelMainCtx, service, rpcHandle, secret, nil, nil, nil)\n\tif err ... | {
"audio": "",
"image": "",
"text": " := os.Getenv(envVar); val != \"\" {\n\t\treturn &val\n\t}\n\treturn def\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func getCEnvVariable(name string) string {\n\n\tval := C.getenv(C.CString(name))",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\n\tif val == nil {\n\t\treturn \"\"\n\t}\n\n\treturn C.GoString(val)\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " string {\n\tif legacyName, ok := systemNameMap[c.Name]; ok {\n\t\treturn legacyName\n\t}\n\treturn c.Name\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func NewAPICache(rules []*policy.HTTPRule, id string, external bool) *APICache {\n\ta := &APICache{\n\t\tmethodRoots: map[string]*node{},\n\t\tID: id,\n\t\tExternal: external,\n\t}\n\n\tfor _, rule := range rules {\n\t\tsc := &scopeRule{\n\t\t\trule: rule,\n\t\t}\n... | {
"audio": "",
"image": "",
"text": "\n\t\t\t\ta.methodRoots[method] = &node{}\n\t\t\t}\n\t\t\tfor _, uri := range rule.URIs {\n\t\t\t\tinsert(a.methodRoots[method], uri, sc)\n\t\t\t}\n\t\t}\n\t}\n\n\treturn a\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\t\t\t\treturn false\n\t\t\t\t}\n\t\t\t}\n\t\t\tfor _, row := range op.Rows {\n\t\t\t\tfor column := range row {\n\t\t\t\t\tif _, ok := table.Columns[column]; !ok {\n\t\t\t\t\t\treturn false\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tfor _, column := range op.Columns {\n\t\t\t\ti... |
{
"audio": "",
"image": "",
"text": "func (c *APICache) FindRule(verb, uri string) (bool, *policy.HTTPRule) {\n\tfound, rule := c.Find(verb, uri)\n\tif rule == nil {\n\t\treturn found, nil\n\t}\n\tif policyRule, ok",
"video": ""
} | {
"audio": "",
"image": "",
"text": " := rule.(*scopeRule); ok {\n\t\treturn found, policyRule.rule\n\t}\n\treturn false, nil\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\n\tif uri.Port() == \"\" {\n\t\turi.Host = fmt.Sprintf(\"%s:%d\", uri.Host, defaultPort)\n\t}\n\treturn uri.String(), nil\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (c *APICache) FindAndMatchScope(verb, uri string, attributes []string) (bool, bool) {\n\tfound, rule := c.Find(verb, uri)\n\tif !found || rule == nil {\n\t\treturn false, false\n\t}\n\tpolicyRule, ok := rule.(*scopeRule)\n\tif !ok {\n\t",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\treturn false, false\n\t}\n\tif policyRule.rule.Public {\n\t\treturn true, true\n\t}\n\treturn c.MatchClaims(policyRule.rule.ClaimMatchingRules, attributes), false\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\n\t\tif rule.exact {\n\t\t\tif word == rule.suffix {\n\t\t\t\treturn rule.replacement\n\t\t\t}\n\t\t} else {\n\t\t\tif strings.HasSuffix(word, rule.suffix) {\n\t\t\t\treturn replaceLast(word, rule.suffix, rule.replacement)\n\t\t\t}\n\t\t}\n\t}\n\treturn word\n}",
"video": "... |
{
"audio": "",
"image": "",
"text": "func (c *APICache) MatchClaims(rules [][]string, claims []string) bool {\n\n\tclaimsMap := map[string]struct{}{}\n\tfor _, claim := range claims {\n\t\tclaimsMap[claim] = struct{}{}\n\t}\n\n\tvar matched int\n\tfor _, clause := range rules {\n\t",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\tmatched = len(clause)\n\t\tfor _, claim := range clause {\n\t\t\tif _, ok := claimsMap[claim]; ok {\n\t\t\t\tmatched--\n\t\t\t}\n\t\t\tif matched == 0 {\n\t\t\t\treturn true\n\t\t\t}\n\t\t}\n\t}\n\treturn false\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\t\tres[nodeID] = struct{}{}\n\t}\n\tfor _, skip := range skips {\n\t\tfor nodeID := range skip {\n\t\t\tres[nodeID] = struct{}{}\n\t\t}\n\t}\n\n\treturn res\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (c *APICache) Find(verb, uri string) (bool, interface{}) {\n\troot, ok := c.methodRoots[verb]\n\tif !ok {",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\n\t\treturn false, nil\n\t}\n\treturn search(root, uri)\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\tdefer c.Unlock()\n\n\tfor id := range c.cache {\n\t\tif _, ok := liveContainers[id]; !ok {\n\t\t\tdelete(c.cache, id)\n\t\t}\n\t}\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func parse(s string) (string, string) {\n\tif s == \"/\" {\n\t\treturn s, \"\"\n",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\t}\n\tfor i := 1; i < len(s); i++ {\n\t\tif s[i] == '/' {\n\t\t\treturn s[0:i], s[i:]\n\t\t}\n\t}\n\n\treturn s, \"\"\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " string {\n\tif v := s.GetString(key); v != \"\" {\n\t\treturn v\n\t}\n\n\treturn defaultValue\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func insert(n *node, api string, data interface{}) {\n\tif len(api) == 0 {\n\t\tn.data = data\n\t\tn.leaf = true\n\t\treturn\n\t}\n\n\tprefix, suffix := parse(api)\n\n\t// root node or terminal node\n\tif prefix == \"/\" {\n\t\tn.data = data\n\t\tn.leaf = true\n\t\treturn\n\t}... | {
"audio": "",
"image": "",
"text": " there is no child, add the new child.\n\tnext, ok := n.children[prefix]\n\tif !ok {\n\t\tnext = &node{}\n\t\tn.children[prefix] = next\n\t}\n\n\tinsert(next, suffix, data)\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " as the search makes progress\n\t\twatch = n.mutateCh\n\n\t\t// Consume the search prefix\n\t\tif bytes.HasPrefix(search, n.prefix) {\n\t\t\tsearch = search[len(n.prefix):]\n\n\t\t} else if bytes.HasPrefix(n.prefix, search) {\n\t\t\ti.node = n\n\t\t\treturn\n\t\t} else {\n\t\t... |
{
"audio": "",
"image": "",
"text": "func getPausePUID(extensions policy.ExtendedMap) string {\n\n\tif extensions == nil {\n\t\treturn \"\"\n\t}\n\n\tif puid,",
"video": ""
} | {
"audio": "",
"image": "",
"text": " ok := extensions.Get(constants.DockerHostPUID); ok {\n\t\tzap.L().Debug(\"puid of pause container is\", zap.String(\"puid\", puid))\n\t\treturn puid\n\t}\n\n\treturn \"\"\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " append(s.extensions, extensions...)\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func policyExtensions(runtime policy.RuntimeReader) (extensions policy.ExtendedMap) {\n\n\tif runtime == nil {\n\t\treturn nil\n\t}\n\n\tif runtime.Options().PolicyExtensions == nil {\n\t\treturn nil\n\t}\n\n\tif extensions, ok :=",
"video": ""
} | {
"audio": "",
"image": "",
"text": " runtime.Options().PolicyExtensions.(policy.ExtendedMap); ok {\n\t\treturn extensions\n\t}\n\treturn nil\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " {\n\tswitch label {\n\tcase \"status.phase\":\n\t\treturn label, value, nil\n\tdefault:\n\t\treturn runtime.DefaultMetaV1FieldSelectorConversion(label, value)\n\t}\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func isHostNetworkContainer(runtime policy.RuntimeReader) bool {\n\n\treturn",
"video": ""
} | {
"audio": "",
"image": "",
"text": " runtime.PUType() == common.LinuxProcessPU || (getPausePUID(policyExtensions(runtime)) != \"\")\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " bool {\n\treturn func(err error) bool {\n\t\treturn Cause(err) == cause\n\t}\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func isKubernetesContainer(labels map[string]string) bool {\n\n\tif _,",
"video": ""
} | {
"audio": "",
"image": "",
"text": " ok := labels[constants.K8sPodNamespace]; ok {\n\t\treturn true\n\t}\n\treturn false\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " bool {\n\treturn func(err error) bool {\n\t\treturn Cause(err) == cause\n\t}\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func kubePodIdentifier(labels map[string]string) string {\n\n\tif !isKubernetesContainer(labels) {\n\t\treturn \"\"\n\t}\n\tpodName := \"\"\n\tpodNamespace := \"\"\n\n\tpodNamespace, ok := labels[constants.K8sPodNamespace]\n\tif",
"video": ""
} | {
"audio": "",
"image": "",
"text": " !ok {\n\t\tpodNamespace = \"\"\n\t}\n\n\tpodName, ok = labels[constants.K8sPodName]\n\tif !ok {\n\t\tpodName = \"\"\n\t}\n\n\tif podName == \"\" || podNamespace == \"\" {\n\t\tzap.L().Warn(\"K8s pod does not have podname/podnamespace labels\")\n\t\treturn \"\"\n\t}\n\n\tretur... | {
"audio": "",
"image": "",
"text": " := p[key]; ok {\n\t\treturn v\n\t}\n\treturn \"\"\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func NewPolicyDB() (m *PolicyDB) {\n\n\tm = &PolicyDB{\n\t\tnumberOfPolicies: 0,\n\t\tequalPrefixes: map[string]intList{},\n\t\tequalMapTable: map[string]map[string][]*ForwardingPolicy{},\n\t\tequalIDMapTable: map[string][]*ForwardingPolicy{},\n\... | {
"audio": "",
"image": "",
"text": " map[string]map[string][]*ForwardingPolicy{},\n\t\tnotStarTable: map[string][]*ForwardingPolicy{},\n\t\tdefaultNotExistsPolicy: nil,\n\t}\n\n\treturn m\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\tah.timer = time.AfterFunc(timeout, func() {\n\t\tm.ackLock.Lock()\n\t\tdelete(m.ackHandlers, seqNo)\n\t\tm.ackLock.Unlock()\n\t})\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (m *PolicyDB) tagSplit(tag string, k *string, v *string) error {\n\tl := len(tag)\n\tif l < 3 {\n\t\treturn fmt.Errorf(\"Invalid tag: invalid length '%s'\", tag)\n\t}\n\n\tif tag[0] == '=' {\n\t\treturn fmt.Errorf(\"Invalid tag: missing key '%s'\", tag)\n\t}\n\n\tfor i :=... | {
"audio": "",
"image": "",
"text": "\t\treturn fmt.Errorf(\"Invalid tag: missing value '%s'\", tag)\n\t\t\t}\n\t\t\t*k = tag[:i]\n\t\t\t*v = tag[i+1:]\n\t\t\treturn nil\n\t\t}\n\t}\n\n\treturn fmt.Errorf(\"Invalid tag: missing equal symbol '%s'\", tag)\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\t\t\tprefix: token.prefix,\n\t\t\t}\n\t\t\tif !yaml_parser_append_tag_directive(parser, value, false, token.start_mark) {\n\t\t\t\treturn false\n\t\t\t}\n\t\t\ttag_directives = append(tag_directives, value)\n\t\t}\n\n\t\tskip_token(parser)\n\t\ttoken = peek_token(parser)\n\t\... |
{
"audio": "",
"image": "",
"text": "func (m *PolicyDB) Search(tags *policy.TagStore) (int, interface{}) {\n\n\tcount := make([]int, m.numberOfPolicies+1)\n\n\tskip := make([]bool, m.numberOfPolicies+1)\n\n\t// Disable all policies that fail the not key exists\n\tcopiedTags := tags.GetSlice()\n\tvar k, v string\n... | {
"audio": "",
"image": "",
"text": "\t\t\tif i <= len(v) {\n\t\t\t\tif index, action := searchInMapTable(m.equalMapTable[k][v[:i]], count, skip); index >= 0 {\n\t\t\t\t\treturn index, action\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Parse all of the policies that have a key that matches the incoming tag key\n\t\t// a... | {
"audio": "",
"image": "",
"text": " {\n\t\tfor _, layout := range timeLayout {\n\t\t\tif t, err := time.Parse(layout, date); err == nil {\n\t\t\t\tm.Date = t\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\n\tm.Variables = parsedMap\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (m *PolicyDB) PrintPolicyDB() {\n\n\tzap.L().Debug(\"Print Policy DB: equal table\")\n\n\tfor key, values := range m.equalMapTable {\n\t\tfor value, policies := range values {\n\t\t\tzap.L().Debug(\"Print Policy DB\",\n\t\t\t\tzap.String(\"policies\", fmt.Sprintf(\"%#v\",... | {
"audio": "",
"image": "",
"text": "\t\t\t\tzap.String(\"key\", key),\n\t\t\t)\n\t\t}\n\t}\n\n\tzap.L().Debug(\"Print Policy DB - not equal table\")\n\n\tfor key, values := range m.notEqualMapTable {\n\t\tfor value, policies := range values {\n\t\t\tzap.L().Debug(\"Print Policy DB\",\n\t\t\t\tzap.String(\"polici... | {
"audio": "",
"image": "",
"text": " PIDs of the user are gone, we can delete the user context.\n\tif err := u.config.Policy.HandlePUEvent(ctx, userID, common.EventStop, runtime); err != nil {\n\t\tzap.L().Warn(\"Failed to stop trireme PU \",\n\t\t\tzap.String(\"puID\", puID),\n\t\t\tzap.Error(err),\n\t\t)\n\t}\... |
{
"audio": "",
"image": "",
"text": "func (i *Instance) cgroupChainRules(cfg *ACLInfo) [][]string {\n\n\t// Rules for older distros (eg RH 6.9/Ubuntu 14.04), due to absence of\n\t// cgroup match modules, source ports are used to trap outgoing traffic.\n\tif i.isLegacyKernel && (cfg.PUType == common.HostNetworkPU... | {
"audio": "",
"image": "",
"text": "\n\t\t\treturn cfg.UDPPorts != \"0\"\n\t\t},\n\t\t\"isTCPPorts\": func() bool {\n\t\t\treturn cfg.TCPPorts != \"0\"\n\t\t},\n\t\t\"isHostPU\": func() bool {\n\t\t\treturn cfg.AppSection == HostModeOutput && cfg.NetSection == HostModeInput\n\t\t},\n\t}).Parse(cgroupCaptureTempl... | {
"audio": "",
"image": "",
"text": " func(cfg *config) {\n\t\tcfg.runtimeCfg = c\n\t}\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (i *Instance) containerChainRules(cfg *ACLInfo) [][]string {\n\n\ttmpl := template.Must(template.New(containerChainTemplate).Parse(containerChainTemplate))\n",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\n\trules, err := extractRulesFromTemplate(tmpl, cfg)\n\tif err != nil {\n\t\tzap.L().Warn(\"unable to extract rules\", zap.Error(err))\n\t}\n\n\treturn append(rules, i.proxyRules(cfg)...)\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\ttempl := template.Must(template.New(\"\").Delims(engine.delims.Left, engine.delims.Right).Funcs(engine.FuncMap).ParseFiles(files...))\n\tengine.SetHTMLTemplate(templ)\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (i *Instance) proxyRules(cfg *ACLInfo) [][]string {\n\n\ttmpl := template.Must(template.New(proxyChainTemplate).Funcs(template.FuncMap{\n\t\t\"isCgroupSet\": func() bool {\n\t\t\treturn cfg.CgroupMark != \"\"\n\t\t},\n\t}).Parse(proxyChainTemplate))\n\n\trules,",
"video... | {
"audio": "",
"image": "",
"text": " err := extractRulesFromTemplate(tmpl, cfg)\n\tif err != nil {\n\t\tzap.L().Warn(\"unable to extract rules\", zap.Error(err))\n\t}\n\treturn rules\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " Goify,\n\t\t\"gotyperef\": GoTypeRef,\n\t\t\"add\": Add,\n\t\t\"finalizeCode\": f.Code,\n\t}\n\tf.assignmentT, err = template.New(\"assignment\").Funcs(fm).Parse(assignmentTmpl)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tf.arrayAssignmentT, err = template.New(\"a... |
{
"audio": "",
"image": "",
"text": "func (i *Instance) trapRules(cfg *ACLInfo, isHostPU bool) [][]string {\n\n\ttmpl := template.Must(template.New(packetCaptureTemplate).Funcs(template.FuncMap{\n\t\t\"needDnsRules\": func() bool {\n\t\t\treturn i.mode == constants.Sidecar || isHostPU || i.isLegacyKernel\n\t\t},\... | {
"audio": "",
"image": "",
"text": "\treturn cfg.UID != \"\"\n\t\t},\n\t}).Parse(packetCaptureTemplate))\n\n\trules, err := extractRulesFromTemplate(tmpl, cfg)\n\tif err != nil {\n\t\tzap.L().Warn(\"unable to extract rules\", zap.Error(err))\n\t}\n\n\treturn rules\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " func(i int) bool {\n\t\treturn !results.vertices[i].less(results.config, result)\n\t})\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (i *Instance) addContainerChain(appChain string, netChain string) error {\n\n\tif err := i.ipt.NewChain(i.appPacketIPTableContext, appChain); err != nil {\n\t\treturn fmt.Errorf(\"unable to add chain",
"video": ""
} | {
"audio": "",
"image": "",
"text": " %s of context %s: %s\", appChain, i.appPacketIPTableContext, err)\n\t}\n\n\tif err := i.ipt.NewChain(i.netPacketIPTableContext, netChain); err != nil {\n\t\treturn fmt.Errorf(\"unable to add netchain %s of context %s: %s\", netChain, i.netPacketIPTableContext, err)\n\t}\n\n\t... | {
"audio": "",
"image": "",
"text": " \"Delete\":\n\t\t\t\tif err = i.ipt.Delete(cr[0], cr[1], cr[2:]...); err == nil {\n\t\t\t\t\tbreak L\n\t\t\t\t}\n\n\t\t\tdefault:\n\t\t\t\treturn errors.New(\"invalid method type\")\n\t\t\t}\n\t\t}\n\t\tif err != nil && methodType != \"Delete\" {\n\t\t\treturn fmt.Errorf(\"un... |
{
"audio": "",
"image": "",
"text": "func (i *Instance) processRulesFromList(rulelist [][]string, methodType string) error {\n\tvar err error\n\tfor _, cr := range rulelist {\n\t\t// HACK: Adding a retry loop to avoid iptables error of \"invalid argument\"\n\t\t// Once in a while iptables\n\tL:\n\t\tfor retry := ... | {
"audio": "",
"image": "",
"text": " \"Delete\":\n\t\t\t\tif err = i.ipt.Delete(cr[0], cr[1], cr[2:]...); err == nil {\n\t\t\t\t\tbreak L\n\t\t\t\t}\n\n\t\t\tdefault:\n\t\t\t\treturn errors.New(\"invalid method type\")\n\t\t\t}\n\t\t}\n\t\tif err != nil && methodType != \"Delete\" {\n\t\t\treturn fmt.Errorf(\"un... | {
"audio": "",
"image": "",
"text": " err != nil {\n\t\t\treturn esResp, err\n\t\t}\n\t}\n\n\tif req.api == \"_bulk\" && esResp.Errors {\n\t\tfor _, item := range esResp.Items {\n\t\t\tfor _, i := range item {\n\t\t\t\tif i.Error != \"\" {\n\t\t\t\t\treturn esResp, &SearchError{i.Error, i.Status}\n\t\t\t\t}\n\t\t... |
{
"audio": "",
"image": "",
"text": "func (i *Instance) addPacketTrap(cfg *ACLInfo, isHostPU bool) error {\n\n",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\treturn i.processRulesFromList(i.trapRules(cfg, isHostPU), \"Append\")\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " func(i int) bool {\n\t\treturn !results.vertices[i].less(results.config, result)\n\t})\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (i *Instance) programExtensionsRules(rule *aclIPset, chain, proto, ipMatchDirection string) error {\n\n\trulesspec := []string{\n\t\t\"-p\", proto,\n\t\t\"-m\", \"set\", \"--match-set\", rule.ipset, ipMatchDirection,\n\t\t\"--match\", \"multiport\", \"--dports\", strings.... | {
"audio": "",
"image": "",
"text": " err)\n\t\t}\n\n\t\trulesspec = append(rulesspec, args...)\n\n\t\tif err := i.ipt.Append(i.appPacketIPTableContext, chain, rulesspec...); err != nil {\n\t\t\treturn fmt.Errorf(\"unable to program extension rules: %v\", err)\n\t\t}\n\t}\n\n\treturn nil\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\n\t\tif rule.exact {\n\t\t\tif word == rule.suffix {\n\t\t\t\treturn rule.replacement\n\t\t\t}\n\t\t} else {\n\t\t\tif strings.HasSuffix(word, rule.suffix) {\n\t\t\t\treturn replaceLast(word, rule.suffix, rule.replacement)\n\t\t\t}\n\t\t}\n\t}\n\treturn word\n}",
"video": "... |
{
"audio": "",
"image": "",
"text": "func (i *Instance) sortACLsInBuckets(contextID, chain string, reverseChain string, rules []aclIPset, isAppACLs bool) *rulesInfo {\n\n\trulesBucket := &rulesInfo{\n\t\tRejectObserveApply: [][]string{},\n\t\tRejectNotObserved: [][]string{},\n\t\tRejectObserveContinue: [][... | {
"audio": "",
"image": "",
"text": "\t\t\trulesBucket.ReverseRules = append(rulesBucket.ReverseRules, r...)\n\n\t\t\tif testReject(rule.policy) && testObserveApply(rule.policy) {\n\t\t\t\trulesBucket.RejectObserveApply = append(rulesBucket.RejectObserveApply, acls...)\n\t\t\t}\n\n\t\t\tif testReject(rule.policy)... | {
"audio": "",
"image": "",
"text": "\tcontinue\n\t\t}\n\t\tif !allowsConsolidation(existingRule) && !allowsConsolidation(rule) {\n\t\t\tif !strings.EqualFold(to.String(existingRule.DestinationAddressPrefix), to.String(rule.DestinationAddressPrefix)) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t}\n\t\tif existingRule.Access... |
{
"audio": "",
"image": "",
"text": "func (i *Instance) addExternalACLs(contextID string, chain string, reverseChain string, rules []aclIPset, isAppAcls bool) error {\n\n\trulesBucket := i.sortACLsInBuckets(contextID, chain, reverseChain, rules, isAppAcls)\n\n\ttmpl := template.Must(template.New(acls).Funcs(templ... | {
"audio": "",
"image": "",
"text": "\t\"joinRule\": func(rule []string) string {\n\t\t\treturn strings.Join(rule, \" \")\n\t\t},\n\t}).Parse(acls))\n\n\taclRules, err := extractRulesFromTemplate(tmpl, *rulesBucket)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"unable to extract rules from template: %s\", err)\n\t}... | {
"audio": "",
"image": "",
"text": "\ttempl := template.Must(template.New(\"\").Delims(engine.delims.Left, engine.delims.Right).Funcs(engine.FuncMap).ParseFiles(files...))\n\tengine.SetHTMLTemplate(templ)\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (i *Instance) deleteChainRules(cfg *ACLInfo) error {\n\n\tif i.mode != constants.LocalServer {\n\t\treturn i.processRulesFromList(i.containerChainRules(cfg), \"Delete\")\n\t}\n\n\tif cfg.UID != \"\"",
"video": ""
} | {
"audio": "",
"image": "",
"text": " {\n\t\treturn i.processRulesFromList(i.uidChainRules(cfg), \"Delete\")\n\t}\n\n\treturn i.processRulesFromList(i.cgroupChainRules(cfg), \"Delete\")\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " {\n\t\td = cfg.Dialer\n\t}\n\tn := ReachableDefaultNetwork\n\tif cfg.Network != \"\" {\n\t\tn = cfg.Network\n\t}\n\tr := &ReachableChecker{\n\t\tdialer: d,\n\t\ttimeout: t,\n\t\tnetwork: n,\n\t\turl: cfg.URL,\n\t\tdatadog: cfg.DatadogClient,\n\t\ttags: cfg.DatadogTags... |
{
"audio": "",
"image": "",
"text": "func (i *Instance) deletePUChains(appChain, netChain string) error {\n\n\tif err := i.ipt.ClearChain(i.appPacketIPTableContext, appChain); err != nil {\n\t\tzap.L().Warn(\"Failed to clear the container ack packets chain\",\n\t\t\tzap.String(\"appChain\", appChain),\n\t\t\tzap.... | {
"audio": "",
"image": "",
"text": " to clear the container net packets chain\",\n\t\t\tzap.String(\"netChain\", netChain),\n\t\t\tzap.String(\"context\", i.netPacketIPTableContext),\n\t\t\tzap.Error(err),\n\t\t)\n\t}\n\n\tif err := i.ipt.DeleteChain(i.netPacketIPTableContext, netChain); err != nil {\n\t\tzap.L(... | {
"audio": "",
"image": "",
"text": " PIDs of the user are gone, we can delete the user context.\n\tif err := u.config.Policy.HandlePUEvent(ctx, userID, common.EventStop, runtime); err != nil {\n\t\tzap.L().Warn(\"Failed to stop trireme PU \",\n\t\t\tzap.String(\"puID\", puID),\n\t\t\tzap.Error(err),\n\t\t)\n\t}\... |
{
"audio": "",
"image": "",
"text": "func (i *Instance) setGlobalRules() error {\n\n\tcfg, err := i.newACLInfo(0, \"\", nil, 0)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\ttmpl := template.Must(template.New(globalRules).Funcs(template.FuncMap{\n\t\t\"isLocalServer\": func() bool {\n\t\t\treturn i.mode == constan... | {
"audio": "",
"image": "",
"text": " \"addrtype\", \"--dst-type\", \"LOCAL\",\n\t\t\"-m\", \"set\", \"!\", \"--match-set\", excludedNetworkSet, \"src\",\n\t\t\"-j\", natProxyInputChain)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"unable to add default allow for marked packets at net: %s\", err)\n\t}\n\n\terr = i... | {
"audio": "",
"image": "",
"text": " err := extractRulesFromTemplate(tmpl, cfg)\n\tif err != nil {\n\t\tzap.L().Warn(\"unable to extract rules\", zap.Error(err))\n\t}\n\treturn rules\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (i *Instance) cleanACLSection(context, chainPrefix string) {\n\n\trules, err := i.ipt.ListChains(context)\n\tif err != nil {\n\t\tzap.L().Warn(\"Failed to list chains\",\n\t\t\tzap.String(\"context\", context),\n\t\t\tzap.Error(err),\n\t\t)\n\t}\n\n\tfor _, rule := range ... | {
"audio": "",
"image": "",
"text": "\n\t\t\t\t\tzap.Error(err),\n\t\t\t\t)\n\t\t\t}\n\t\t\tif err := i.ipt.DeleteChain(context, rule); err != nil {\n\t\t\t\tzap.L().Warn(\"Can not delete the chain\",\n\t\t\t\t\tzap.String(\"context\", context),\n\t\t\t\t\tzap.String(\"section\", rule),\n\t\t\t\t\tzap.Error(err),... | {
"audio": "",
"image": "",
"text": " PIDs of the user are gone, we can delete the user context.\n\tif err := u.config.Policy.HandlePUEvent(ctx, userID, common.EventStop, runtime); err != nil {\n\t\tzap.L().Warn(\"Failed to stop trireme PU \",\n\t\t\tzap.String(\"puID\", puID),\n\t\t\tzap.Error(err),\n\t\t)\n\t}\... |
{
"audio": "",
"image": "",
"text": "func NewMockRuntimeReader(ctrl *gomock.Controller) *MockRuntimeReader {\n\tmock := &MockRuntimeReader{ctrl: ctrl}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\n\tmock.recorder = &MockRuntimeReaderMockRecorder{mock}\n\treturn mock\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " {\n\tmock := &MockDockerMetadataClient{ctrl: ctrl}\n\tmock.recorder = &MockDockerMetadataClientMockRecorder{mock}\n\treturn mock\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (m *MockRuntimeReader) Pid() int {\n\tret := m.ctrl.Call(m, \"Pid\")\n",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\tret0, _ := ret[0].(int)\n\treturn ret0\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"GetAckFrame\", arg0)\n\tret0, _ := ret[0].(*wire.AckFrame)\n\treturn ret0\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (m *MockRuntimeReader) Tag(arg0 string) (string, bool) {\n\tret :=",
"video": ""
} | {
"audio": "",
"image": "",
"text": " m.ctrl.Call(m, \"Tag\", arg0)\n\tret0, _ := ret[0].(string)\n\tret1, _ := ret[1].(bool)\n\treturn ret0, ret1\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\n\t\tret.AddTag(\"checked\")\n\t} else {\n\t\tv := val.Field(fieldNo).Bool()\n\t\tif v {\n\t\t\tret.AddTag(\"checked\")\n\t\t}\n\t}\n\treturn ret\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (mr *MockRuntimeReaderMockRecorder) Tag(arg0 interface{}) *gomock.Call {",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"Tag\", reflect.TypeOf((*MockRuntimeReader)(nil).Tag), arg0)\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\n\t\treturn nil, ErrInvalidParams()\n\t}\n\n\tmr.m.RLock()\n\tmd, ok := mr.r[r.Method]\n\tmr.m.RUnlock()\n\tif !ok {\n\t\treturn nil, ErrMethodNotFound()\n\t}\n\n\treturn md.Handler, nil\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (m *MockRuntimeReader) Tags() *policy.TagStore {\n",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\tret := m.ctrl.Call(m, \"Tags\")\n\tret0, _ := ret[0].(*policy.TagStore)\n\treturn ret0\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\t\t\"nobody\",\n\t\tfalse,\n\t\tfunc(e Export) UserMapping { return e.MapRoot },\n\t\tfunc(e Export, m UserMapping) { e.MapRoot = m })\n\n\treturn api.ExportUpdate(ctx, c.API, nex)\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (m *MockRuntimeReader) Options() policy.OptionsType {",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\n\tret := m.ctrl.Call(m, \"Options\")\n\tret0, _ := ret[0].(policy.OptionsType)\n\treturn ret0\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " {\n\treturn func(options *eventOptions) {\n\t\toptions.relatedActivityID = activityID\n\t}\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (m *MockRuntimeReader) IPAddresses() policy.ExtendedMap {",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\n\tret := m.ctrl.Call(m, \"IPAddresses\")\n\tret0, _ := ret[0].(policy.ExtendedMap)\n\treturn ret0\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\t\t\"nobody\",\n\t\tfalse,\n\t\tfunc(e Export) UserMapping { return e.MapRoot },\n\t\tfunc(e Export, m UserMapping) { e.MapRoot = m })\n\n\treturn api.ExportUpdate(ctx, c.API, nex)\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (m *MockRuntimeReader) PUType() common.PUType {\n\tret := m.ctrl.Call(m, \"PUType\")\n",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\tret0, _ := ret[0].(common.PUType)\n\treturn ret0\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"GetAckFrame\", arg0)\n\tret0, _ := ret[0].(*wire.AckFrame)\n\treturn ret0\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (mr *MockRuntimeReaderMockRecorder) PUType() *gomock.Call {\n\treturn",
"video": ""
} | {
"audio": "",
"image": "",
"text": " mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"PUType\", reflect.TypeOf((*MockRuntimeReader)(nil).PUType))\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\n\t\treturn nil, ErrInvalidParams()\n\t}\n\n\tmr.m.RLock()\n\tmd, ok := mr.r[r.Method]\n\tmr.m.RUnlock()\n\tif !ok {\n\t\treturn nil, ErrMethodNotFound()\n\t}\n\n\treturn md.Handler, nil\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (m *MockRuntimeReader) SetServices(services",
"video": ""
} | {
"audio": "",
"image": "",
"text": " []common.Service) {\n\tm.ctrl.Call(m, \"SetServices\", services)\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\tah.timer = time.AfterFunc(timeout, func() {\n\t\tm.ackLock.Lock()\n\t\tdelete(m.ackHandlers, seqNo)\n\t\tm.ackLock.Unlock()\n\t})\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (mr *MockRuntimeReaderMockRecorder) SetServices(services interface{}) *gomock.Call {\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock,",
"video": ""
} | {
"audio": "",
"image": "",
"text": " \"SetServices\", reflect.TypeOf((*MockRuntimeReader)(nil).SetServices), services)\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"ChangeConnectionID\", reflect.TypeOf((*MockCryptoSetup)(nil).ChangeConnectionID), arg0)\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (m *MockRuntimeReader) PortMap() map[nat.Port][]string {\n\tret := m.ctrl.Call(m, \"PortMap\")\n\tret0, _ :=",
"video": ""
} | {
"audio": "",
"image": "",
"text": " ret[0].(map[nat.Port][]string)\n\treturn ret0\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " {\n\tm.ctrl.T.Helper()\n\tret := m.ctrl.Call(m, \"GetAckFrame\", arg0)\n\tret0, _ := ret[0].(*wire.AckFrame)\n\treturn ret0\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func NewMockResolver(ctrl *gomock.Controller) *MockResolver {\n\tmock := &MockResolver{ctrl: ctrl}\n",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\tmock.recorder = &MockResolverMockRecorder{mock}\n\treturn mock\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " {\n\tmock := &MockDockerMetadataClient{ctrl: ctrl}\n\tmock.recorder = &MockDockerMetadataClientMockRecorder{mock}\n\treturn mock\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (m *MockResolver) HandlePUEvent(ctx context.Context, puID string, event common.Event, runtime",
"video": ""
} | {
"audio": "",
"image": "",
"text": " policy.RuntimeReader) error {\n\tret := m.ctrl.Call(m, \"HandlePUEvent\", ctx, puID, event, runtime)\n\tret0, _ := ret[0].(error)\n\treturn ret0\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " a.baseToken.token,\n\t\tlifetime: lifetime,\n\t\trefreshCb: func(ctx context.Context, prev *internal.Token) (*internal.Token, error) {\n\t\t\treturn a.baseToken.renewToken(ctx, prev, nil)\n\t\t},\n\t})\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (mr *MockResolverMockRecorder) HandlePUEvent(ctx, puID, event, runtime interface{}) *gomock.Call {\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"HandlePUEvent\",",
"video": ""
} | {
"audio": "",
"image": "",
"text": " reflect.TypeOf((*MockResolver)(nil).HandlePUEvent), ctx, puID, event, runtime)\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\n\treturn mr.mock.ctrl.RecordCallWithMethodType(mr.mock, \"ChangeConnectionID\", reflect.TypeOf((*MockCryptoSetup)(nil).ChangeConnectionID), arg0)\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (e *ErrToken) Code() string {\n\n\tswitch e.message {\n\tcase errCompressedTagMismatch:\n\t\treturn collector.CompressedTagMismatch\n\tcase errDatapathVersionMismatch:\n",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\t\treturn collector.DatapathVersionMismatch\n\tdefault:\n\t\treturn collector.InvalidToken\n\t}\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\tif e.Code != \"\" {\n\t\treturn e.Code\n\t}\n\n\tif e.Err != nil {\n\t\treturn ErrorCode(e.Err)\n\t}\n\n\treturn EInternal\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func CodeFromErr(err error) string {\n\n\terrToken, ok := err.(*ErrToken)",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\n\tif !ok {\n\t\treturn collector.InvalidToken\n\t}\n\n\treturn errToken.Code()\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\n\tif t, ok := err.(TApplicationException); ok {\n\t\treturn NewTApplicationException(t.TypeId(), prepend+t.Error())\n\t}\n\n\treturn errors.New(prepend + err.Error())\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (a *nfLog) Run(ctx context.Context) {\n\ta.Lock()\n\ta.srcNflogHandle, _ = nflog.BindAndListenForLogs([]uint16{a.ipv4groupSource}, 64, a.sourceNFLogsHanlder, a.nflogErrorHandler)\n\ta.dstNflogHandle, _ = nflog.BindAndListenForLogs([]uint16{a.ipv4groupDest}, 64, a.destNFLo... | {
"audio": "",
"image": "",
"text": "\ta.Unlock()\n\n\tgo func() {\n\t\t<-ctx.Done()\n\t\ta.Lock()\n\t\ta.srcNflogHandle.NFlogClose()\n\t\ta.dstNflogHandle.NFlogClose()\n\t\ta.Unlock()\n\n\t}()\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " a.baseToken.token,\n\t\tlifetime: lifetime,\n\t\trefreshCb: func(ctx context.Context, prev *internal.Token) (*internal.Token, error) {\n\t\t\treturn a.baseToken.renewToken(ctx, prev, nil)\n\t\t},\n\t})\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func newAppConnectionState(nativeID, serviceID string, p *pucontext.PUContext, r *http.Request, originalDestination *net.TCPAddr) *connectionState {\n\n\tsourceIP := \"0.0.0.0/0\"\n\tsourcePort := 0\n\tif sourceAddress, err := net.ResolveTCPAddr(\"tcp\", r.RemoteAddr); err == ... | {
"audio": "",
"image": "",
"text": " &collector.EndPoint{\n\t\t\t\tType: collector.EnpointTypePU,\n\t\t\t\tID: p.ManagementID(),\n\t\t\t\tIP: sourceIP,\n\t\t\t\tPort: uint16(sourcePort),\n\t\t\t\tHTTPMethod: r.Method,\n\t\t\t\tURI: r.Method + \" \" + r.RequestURI,\n\t\t\t},\n\t... | {
"audio": "",
"image": "",
"text": "\t\t// TODO v6 needs to be handled.\n\t\tif len(ep.Gateway()) > 0 {\n\t\t\treturn false\n\t\t}\n\t\tfor _, r := range ep.StaticRoutes() {\n\t\t\tif r.Destination != nil && r.Destination.String() == \"0.0.0.0/0\" {\n\t\t\t\treturn false\n\t\t\t}\n\t\t}\n\t\tneedGW = true\n\t}\n... |
{
"audio": "",
"image": "",
"text": "func newNetworkConnectionState(nativeID string, pctx *serviceregistry.PortContext, r *http.Request, source, dest *net.TCPAddr) *connectionState {\n\treturn &connectionState{\n\t\tstats: &collector.FlowRecord{\n\t\t\tContextID: nativeID,\n\t\t\tDestination: &collector.EndPoint{... | {
"audio": "",
"image": "",
"text": "\t\tType: collector.EnpointTypePU,\n\t\t\t\tIP: dest.IP.String(),\n\t\t\t\tPort: uint16(dest.Port),\n\t\t\t},\n\t\t\tSource: &collector.EndPoint{\n\t\t\t\tType: collector.EndPointTypeExternalIP,\n\t\t\t\tIP: source.IP.String(),\n\t\t\t\tID: collector.De... | {
"audio": "",
"image": "",
"text": " += \"/\"\n\t}\n\n\tif len(r.Namespace) != 0 {\n\t\ts += r.Namespace + \"/\"\n\t}\n\treturn s + name\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func KubernetesMetadataExtractor(event *common.EventInfo) (*policy.PURuntime, error) {\n\n\tif event.NS == \"\" {\n\t\treturn nil, errors.New(\"namespace path is required when using cni\")\n\t}\n\n\truntimeTags := policy.NewTagStore()\n\tfor _, tag := range event.Tags {\n\t\tp... | {
"audio": "",
"image": "",
"text": "\treturn nil, fmt.Errorf(\"invalid tag: %s\", tag)\n\t\t}\n\t\truntimeTags.AppendKeyValue(\"@usr:\"+parts[0], parts[1])\n\t}\n\n\truntimeIps := policy.ExtendedMap{\"bridge\": \"0.0.0.0/0\"}\n\n\treturn policy.NewPURuntime(event.Name, 1, \"\", runtimeTags, runtimeIps, common.Li... | {
"audio": "",
"image": "",
"text": "\n\t\t}\n\t}\n\n\tif event.EventType == common.EventStop || event.EventType == common.EventDestroy {\n\t\tregStop := regexp.MustCompile(\"^/trireme/[a-zA-Z0-9_]{1,11}$\")\n\t\tif event.Cgroup != \"\" && !regStop.Match([]byte(event.Cgroup)) {\n\t\t\treturn fmt.Errorf(\"Cgroup i... |
{
"audio": "",
"image": "",
"text": "func CleanAllTriremeACLs() error {\n\tipt, err := iptablesctrl.NewInstance(fqconfig.NewFilterQueueWithDefaults(), constants.LocalServer, &runtime.Configuration{})\n\tif err != nil {\n\t",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\treturn fmt.Errorf(\"unable to initialize cleaning iptables controller: %s\", err)\n\t}\n\n\treturn ipt.CleanUp()\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " nil {\n\t\treturn error\n\t}\n\tfile, error := os.Create(filename)\n\tif error != nil {\n\t\treturn error\n\t}\n\t_, err := file.WriteString(content)\n\treturn err\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (f ActionType) ActionString() string {\n\tif f.Accepted() && !f.Rejected() {\n\t\treturn actionAccept\n\t}\n\n\tif",
"video": ""
} | {
"audio": "",
"image": "",
"text": " !f.Accepted() && f.Rejected() {\n\t\treturn actionReject\n\t}\n\n\treturn actionPassthrough\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": "\n\t\treturn errDirectoryHasBlocks\n\n\tcase !f.Deleted && !f.IsInvalid() && f.Type == FileInfoTypeFile && len(f.Blocks) == 0:\n\t\t// Non-deleted, non-invalid files should have at least one block\n\t\treturn errFileHasNoBlocks\n\t}\n\treturn nil\n}",
"video": ""
} |
{
"audio": "",
"image": "",
"text": "func (f *FlowPolicy) LogPrefix(contextID string) string {\n\tprefix := contextID + \":\" + f.PolicyID + \":\" +",
"video": ""
} | {
"audio": "",
"image": "",
"text": " f.ServiceID + f.EncodedActionString()\n\treturn prefix\n}",
"video": ""
} | {
"audio": "",
"image": "",
"text": " fileKey(pkg + \":\" + instance + \":\" + file)\n}",
"video": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.