code
stringlengths
12
2.05k
label_name
stringclasses
5 values
label
int64
0
4
func isRepositoryGitPath(path string) bool { return strings.HasSuffix(path, ".git") || strings.Contains(path, ".git"+string(os.PathSeparator)) || // Windows treats ".git." the same as ".git" strings.HasSuffix(path, ".git.") || strings.Contains(path, ".git."+string(os.PathSeparator)) }
Base
1
func (m *Nil) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { preIndex := iNdEx var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowThetest } if iNdEx >= l { return io.ErrUnexpectedEOF } b := dAtA[iNdEx] iNdEx++ wire |= uint64(b&0x7F) << shift if b < 0x80 { break } } fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { return fmt.Errorf("proto: Nil: wiretype end group for non-group") } if fieldNum <= 0 { return fmt.Errorf("proto: Nil: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { default: iNdEx = preIndex skippy, err := skipThetest(dAtA[iNdEx:]) if err != nil { return err } if skippy < 0 { return ErrInvalidLengthThetest } if (iNdEx + skippy) < 0 { return ErrInvalidLengthThetest } if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF } m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) iNdEx += skippy } } if iNdEx > l { return io.ErrUnexpectedEOF } return nil }
Variant
0
func (m *ADeepBranch) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { preIndex := iNdEx var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowThetest } if iNdEx >= l { return io.ErrUnexpectedEOF } b := dAtA[iNdEx] iNdEx++ wire |= uint64(b&0x7F) << shift if b < 0x80 { break } } fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { return fmt.Errorf("proto: ADeepBranch: wiretype end group for non-group") } if fieldNum <= 0 { return fmt.Errorf("proto: ADeepBranch: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 2: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Down", wireType) } var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowThetest } if iNdEx >= l { return io.ErrUnexpectedEOF } b := dAtA[iNdEx] iNdEx++ msglen |= int(b&0x7F) << shift if b < 0x80 { break } } if msglen < 0 { return ErrInvalidLengthThetest } postIndex := iNdEx + msglen if postIndex < 0 { return ErrInvalidLengthThetest } if postIndex > l { return io.ErrUnexpectedEOF } if err := m.Down.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipThetest(dAtA[iNdEx:]) if err != nil { return err } if skippy < 0 { return ErrInvalidLengthThetest } if (iNdEx + skippy) < 0 { return ErrInvalidLengthThetest } if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF } m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) iNdEx += skippy } } if iNdEx > l { return io.ErrUnexpectedEOF } return nil }
Variant
0
func (x *ListStorageRequest) Reset() { *x = ListStorageRequest{} if protoimpl.UnsafeEnabled { mi := &file_console_proto_msgTypes[30] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } }
Base
1
func (f *Fosite) writeJsonError(rw http.ResponseWriter, err error) { rw.Header().Set("Content-Type", "application/json;charset=UTF-8") rw.Header().Set("Cache-Control", "no-store") rw.Header().Set("Pragma", "no-cache") rfcerr := ErrorToRFC6749Error(err) if !f.SendDebugMessagesToClients { rfcerr = rfcerr.Sanitize() } js, err := json.Marshal(rfcerr) if err != nil { if f.SendDebugMessagesToClients { errorMessage := EscapeJSONString(err.Error()) http.Error(rw, fmt.Sprintf(`{"error":"server_error","error_description":"%s"}`, errorMessage), http.StatusInternalServerError) } else { http.Error(rw, `{"error":"server_error"}`, http.StatusInternalServerError) } return } rw.WriteHeader(rfcerr.Code) rw.Write(js) }
Class
2
func (*RuntimeInfo) Descriptor() ([]byte, []int) { return file_console_proto_rawDescGZIP(), []int{41} }
Base
1
func mountCgroupV1(m *configs.Mount, c *mountConfig) error { binds, err := getCgroupMounts(m) if err != nil { return err } var merged []string for _, b := range binds { ss := filepath.Base(b.Destination) if strings.Contains(ss, ",") { merged = append(merged, ss) } } tmpfs := &configs.Mount{ Source: "tmpfs", Device: "tmpfs", Destination: m.Destination, Flags: defaultMountFlags, Data: "mode=755", PropagationFlags: m.PropagationFlags, } if err := mountToRootfs(tmpfs, c); err != nil { return err } for _, b := range binds { if c.cgroupns { subsystemPath := filepath.Join(c.root, b.Destination) if err := os.MkdirAll(subsystemPath, 0755); err != nil { return err } flags := defaultMountFlags if m.Flags&unix.MS_RDONLY != 0 { flags = flags | unix.MS_RDONLY } cgroupmount := &configs.Mount{ Source: "cgroup", Device: "cgroup", // this is actually fstype Destination: subsystemPath, Flags: flags, Data: filepath.Base(subsystemPath), } if err := mountNewCgroup(cgroupmount); err != nil { return err } } else { if err := mountToRootfs(b, c); err != nil { return err } } } for _, mc := range merged { for _, ss := range strings.Split(mc, ",") { // symlink(2) is very dumb, it will just shove the path into // the link and doesn't do any checks or relative path // conversion. Also, don't error out if the cgroup already exists. if err := os.Symlink(mc, filepath.Join(c.root, m.Destination, ss)); err != nil && !os.IsExist(err) { return err } } } return nil }
Class
2
func (s *ConsoleServer) Authenticate(ctx context.Context, in *console.AuthenticateRequest) (*console.ConsoleSession, error) { role := console.UserRole_USER_ROLE_UNKNOWN var uname string var email string switch in.Username { case s.config.GetConsole().Username: if in.Password == s.config.GetConsole().Password { role = console.UserRole_USER_ROLE_ADMIN uname = in.Username } default: var err error uname, email, role, err = s.lookupConsoleUser(ctx, in.Username, in.Password) if err != nil { return nil, err } } if role == console.UserRole_USER_ROLE_UNKNOWN { return nil, status.Error(codes.Unauthenticated, "Invalid credentials.") } token := jwt.NewWithClaims(jwt.SigningMethodHS256, &ConsoleTokenClaims{ ExpiresAt: time.Now().UTC().Add(time.Duration(s.config.GetConsole().TokenExpirySec) * time.Second).Unix(), Username: uname, Email: email, Role: role, Cookie: s.cookie, }) key := []byte(s.config.GetConsole().SigningKey) signedToken, _ := token.SignedString(key) return &console.ConsoleSession{Token: signedToken}, nil }
Base
1
func TestIsReqAuthenticated(t *testing.T) { path, err := newTestConfig(globalMinioDefaultRegion) if err != nil { t.Fatalf("unable initialize config file, %s", err) } defer os.RemoveAll(path) creds, err := auth.CreateCredentials("myuser", "mypassword") if err != nil { t.Fatalf("unable create credential, %s", err) } globalServerConfig.SetCredential(creds) // List of test cases for validating http request authentication. testCases := []struct { req *http.Request s3Error APIErrorCode }{ // When request is nil, internal error is returned. {nil, ErrInternalError}, // When request is unsigned, access denied is returned. {mustNewRequest("GET", "http://127.0.0.1:9000", 0, nil, t), ErrAccessDenied}, // Empty Content-Md5 header. {mustNewSignedEmptyMD5Request("PUT", "http://127.0.0.1:9000/", 5, bytes.NewReader([]byte("hello")), t), ErrInvalidDigest}, // Short Content-Md5 header. {mustNewSignedShortMD5Request("PUT", "http://127.0.0.1:9000/", 5, bytes.NewReader([]byte("hello")), t), ErrInvalidDigest}, // When request is properly signed, but has bad Content-MD5 header. {mustNewSignedBadMD5Request("PUT", "http://127.0.0.1:9000/", 5, bytes.NewReader([]byte("hello")), t), ErrBadDigest}, // When request is properly signed, error is none. {mustNewSignedRequest("GET", "http://127.0.0.1:9000", 0, nil, t), ErrNone}, } // Validates all testcases. for _, testCase := range testCases { if s3Error := isReqAuthenticated(testCase.req, globalServerConfig.GetRegion()); s3Error != testCase.s3Error { t.Fatalf("Unexpected s3error returned wanted %d, got %d", testCase.s3Error, s3Error) } } }
Variant
0
func TestAddDebug(t *testing.T) { err := ErrRevocationClientMismatch.WithDebug("debug") assert.NotEqual(t, err, ErrRevocationClientMismatch) assert.Empty(t, ErrRevocationClientMismatch.Debug) assert.NotEmpty(t, err.Debug) }
Class
2
func (cf *clientsFactory) UpdateNamespaces(ctx context.Context) error { clients, err := clientsForClusters(cf.clusters.Get()) if err != nil { cf.log.Error(err, "failed to create clients for", "clusters", cf.clusters.Get()) return err } cf.syncCaches() wg := sync.WaitGroup{} for clusterName, c := range clients { wg.Add(1) go func(clusterName string, c client.Client) { defer wg.Done() nsList := &v1.NamespaceList{} if err := c.List(ctx, nsList); err != nil { cf.log.Error(err, "failed listing namespaces", "cluster", clusterName) } cf.clustersNamespaces.Set(clusterName, nsList.Items) }(clusterName, c) } wg.Wait() return nil }
Base
1
func (i *IDTokenHandleHelper) GetAccessTokenHash(ctx context.Context, requester fosite.AccessRequester, responder fosite.AccessResponder) string { token := responder.GetAccessToken() buffer := bytes.NewBufferString(token) hash := sha256.New() hash.Write(buffer.Bytes()) hashBuf := bytes.NewBuffer(hash.Sum([]byte{})) len := hashBuf.Len() return base64.RawURLEncoding.EncodeToString(hashBuf.Bytes()[:len/2]) }
Class
2
func (x *DeleteGroupUserRequest) Reset() { *x = DeleteGroupUserRequest{} if protoimpl.UnsafeEnabled { mi := &file_console_proto_msgTypes[18] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } }
Base
1
func (m *NonByteCustomType) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { preIndex := iNdEx var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowThetest } if iNdEx >= l { return io.ErrUnexpectedEOF } b := dAtA[iNdEx] iNdEx++ wire |= uint64(b&0x7F) << shift if b < 0x80 { break } } fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { return fmt.Errorf("proto: NonByteCustomType: wiretype end group for non-group") } if fieldNum <= 0 { return fmt.Errorf("proto: NonByteCustomType: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Field1", wireType) } var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowThetest } if iNdEx >= l { return io.ErrUnexpectedEOF } b := dAtA[iNdEx] iNdEx++ msglen |= int(b&0x7F) << shift if b < 0x80 { break } } if msglen < 0 { return ErrInvalidLengthThetest } postIndex := iNdEx + msglen if postIndex < 0 { return ErrInvalidLengthThetest } if postIndex > l { return io.ErrUnexpectedEOF } if m.Field1 == nil { m.Field1 = &T{} } if err := m.Field1.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipThetest(dAtA[iNdEx:]) if err != nil { return err } if skippy < 0 { return ErrInvalidLengthThetest } if (iNdEx + skippy) < 0 { return ErrInvalidLengthThetest } if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF } m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) iNdEx += skippy } } if iNdEx > l { return io.ErrUnexpectedEOF } return nil }
Variant
0
func (x *LeaderboardRequest) Reset() { *x = LeaderboardRequest{} if protoimpl.UnsafeEnabled { mi := &file_console_proto_msgTypes[25] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } }
Base
1
func (m *UInt32Value) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { preIndex := iNdEx var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowWrappers } if iNdEx >= l { return io.ErrUnexpectedEOF } b := dAtA[iNdEx] iNdEx++ wire |= uint64(b&0x7F) << shift if b < 0x80 { break } } fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { return fmt.Errorf("proto: UInt32Value: wiretype end group for non-group") } if fieldNum <= 0 { return fmt.Errorf("proto: UInt32Value: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field Value", wireType) } m.Value = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowWrappers } if iNdEx >= l { return io.ErrUnexpectedEOF } b := dAtA[iNdEx] iNdEx++ m.Value |= uint32(b&0x7F) << shift if b < 0x80 { break } } default: iNdEx = preIndex skippy, err := skipWrappers(dAtA[iNdEx:]) if err != nil { return err } if skippy < 0 { return ErrInvalidLengthWrappers } if (iNdEx + skippy) < 0 { return ErrInvalidLengthWrappers } if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF } m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) iNdEx += skippy } } if iNdEx > l { return io.ErrUnexpectedEOF } return nil }
Variant
0
func ReadWriteProtocolTest(t *testing.T, protocolFactory ProtocolFactory) { buf := bytes.NewBuffer(make([]byte, 0, 1024)) l := HTTPClientSetupForTest(t) defer l.Close() transports := []TransportFactory{ NewMemoryBufferTransportFactory(1024), NewStreamTransportFactory(buf, buf, true), NewFramedTransportFactory(NewMemoryBufferTransportFactory(1024)), NewHTTPPostClientTransportFactory("http://" + l.Addr().String()), } doForAllTransports := func(protTest protocolTest) { for _, tf := range transports { trans := tf.GetTransport(nil) p := protocolFactory.GetProtocol(trans) protTest(t, p, trans) trans.Close() } } doForAllTransports(ReadWriteBool) doForAllTransports(ReadWriteByte) doForAllTransports(ReadWriteI16) doForAllTransports(ReadWriteI32) doForAllTransports(ReadWriteI64) doForAllTransports(ReadWriteDouble) doForAllTransports(ReadWriteFloat) doForAllTransports(ReadWriteString) doForAllTransports(ReadWriteBinary) doForAllTransports(ReadWriteStruct) // perform set of many sequenced reads and writes doForAllTransports(func(t testing.TB, p Protocol, trans Transport) { ReadWriteI64(t, p, trans) ReadWriteDouble(t, p, trans) ReadWriteFloat(t, p, trans) ReadWriteBinary(t, p, trans) ReadWriteByte(t, p, trans) ReadWriteStruct(t, p, trans) }) }
Base
1
func isReqAuthenticated(r *http.Request, region string) (s3Error APIErrorCode) { if r == nil { return ErrInternalError } if errCode := reqSignatureV4Verify(r, region); errCode != ErrNone { return errCode } payload, err := ioutil.ReadAll(r.Body) if err != nil { logger.LogIf(context.Background(), err) return ErrInternalError } // Populate back the payload. r.Body = ioutil.NopCloser(bytes.NewReader(payload)) // Verify Content-Md5, if payload is set. if clntMD5B64, ok := r.Header["Content-Md5"]; ok { if clntMD5B64[0] == "" { return ErrInvalidDigest } md5Sum, err := base64.StdEncoding.Strict().DecodeString(clntMD5B64[0]) if err != nil { return ErrInvalidDigest } if !bytes.Equal(md5Sum, getMD5Sum(payload)) { return ErrBadDigest } } if skipContentSha256Cksum(r) { return ErrNone } // Verify that X-Amz-Content-Sha256 Header == sha256(payload) // If X-Amz-Content-Sha256 header is not sent then we don't calculate/verify sha256(payload) sumHex, ok := r.Header["X-Amz-Content-Sha256"] if isRequestPresignedSignatureV4(r) { sumHex, ok = r.URL.Query()["X-Amz-Content-Sha256"] } if ok { if sumHex[0] == "" { return ErrContentSHA256Mismatch } sum, err := hex.DecodeString(sumHex[0]) if err != nil { return ErrContentSHA256Mismatch } if !bytes.Equal(sum, getSHA256Sum(payload)) { return ErrContentSHA256Mismatch } } return ErrNone }
Variant
0
func Test_buildRouteConfiguration(t *testing.T) { b := New("local-grpc", "local-http", nil, nil) virtualHosts := make([]*envoy_config_route_v3.VirtualHost, 10) routeConfig, err := b.buildRouteConfiguration("test-route-configuration", virtualHosts) require.NoError(t, err) assert.Equal(t, "test-route-configuration", routeConfig.GetName()) assert.Equal(t, virtualHosts, routeConfig.GetVirtualHosts()) assert.False(t, routeConfig.GetValidateClusters().GetValue()) }
Class
2
func (m *C) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { preIndex := iNdEx var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowExample } if iNdEx >= l { return io.ErrUnexpectedEOF } b := dAtA[iNdEx] iNdEx++ wire |= uint64(b&0x7F) << shift if b < 0x80 { break } } fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { return fmt.Errorf("proto: C: wiretype end group for non-group") } if fieldNum <= 0 { return fmt.Errorf("proto: C: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field MySize", wireType) } var v int64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowExample } if iNdEx >= l { return io.ErrUnexpectedEOF } b := dAtA[iNdEx] iNdEx++ v |= int64(b&0x7F) << shift if b < 0x80 { break } } m.MySize = &v default: iNdEx = preIndex skippy, err := skipExample(dAtA[iNdEx:]) if err != nil { return err } if skippy < 0 { return ErrInvalidLengthExample } if (iNdEx + skippy) < 0 { return ErrInvalidLengthExample } if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF } m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) iNdEx += skippy } } if iNdEx > l { return io.ErrUnexpectedEOF } return nil }
Variant
0
func (c *liveStateCache) IterateHierarchy(server string, key kube.ResourceKey, action func(child appv1.ResourceNode, appName string)) error { clusterInfo, err := c.getSyncedCluster(server) if err != nil { return err } clusterInfo.IterateHierarchy(key, func(resource *clustercache.Resource, namespaceResources map[kube.ResourceKey]*clustercache.Resource) { action(asResourceNode(resource), getApp(resource, namespaceResources)) }) return nil }
Class
2
func (x *StatusList) Reset() { *x = StatusList{} if protoimpl.UnsafeEnabled { mi := &file_console_proto_msgTypes[40] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } }
Base
1
func (c *linuxContainer) prepareCriuRestoreMounts(mounts []*configs.Mount) error { // First get a list of a all tmpfs mounts tmpfs := []string{} for _, m := range mounts { switch m.Device { case "tmpfs": tmpfs = append(tmpfs, m.Destination) } } // Now go through all mounts and create the mountpoints // if the mountpoints are not on a tmpfs, as CRIU will // restore the complete tmpfs content from its checkpoint. umounts := []string{} defer func() { for _, u := range umounts { if e := unix.Unmount(u, unix.MNT_DETACH); e != nil { if e != unix.EINVAL { // Ignore EINVAL as it means 'target is not a mount point.' // It probably has already been unmounted. logrus.Warnf("Error during cleanup unmounting of %q (%v)", u, e) } } } }() for _, m := range mounts { if !isPathInPrefixList(m.Destination, tmpfs) { if err := c.makeCriuRestoreMountpoints(m); err != nil { return err } // If the mount point is a bind mount, we need to mount // it now so that runc can create the necessary mount // points for mounts in bind mounts. // This also happens during initial container creation. // Without this CRIU restore will fail // See: https://github.com/opencontainers/runc/issues/2748 // It is also not necessary to order the mount points // because during initial container creation mounts are // set up in the order they are configured. if m.Device == "bind" { if err := unix.Mount(m.Source, m.Destination, "", unix.MS_BIND|unix.MS_REC, ""); err != nil { return errorsf.Wrapf(err, "unable to bind mount %q to %q", m.Source, m.Destination) } umounts = append(umounts, m.Destination) } } } return nil }
Class
2
func (*DeleteGroupUserRequest) Descriptor() ([]byte, []int) { return file_console_proto_rawDescGZIP(), []int{18} }
Base
1
func (cr *s3ChunkedReader) readS3ChunkHeader() { // Read the first chunk line until CRLF. var hexChunkSize, hexChunkSignature []byte hexChunkSize, hexChunkSignature, cr.err = readChunkLine(cr.reader) if cr.err != nil { return } // <hex>;token=value - converts the hex into its uint64 form. cr.n, cr.err = parseHexUint(hexChunkSize) if cr.err != nil { return } if cr.n == 0 { cr.err = io.EOF } // Save the incoming chunk signature. cr.chunkSignature = string(hexChunkSignature) }
Base
1
func handleCollectedUplink(ctx context.Context, uplinkFrame gw.UplinkFrame, rxPacket models.RXPacket) error { var uplinkIDs []uuid.UUID for _, p := range rxPacket.RXInfoSet { uplinkIDs = append(uplinkIDs, helpers.GetUplinkID(p)) } log.WithFields(log.Fields{ "uplink_ids": uplinkIDs, "mtype": rxPacket.PHYPayload.MHDR.MType, "ctx_id": ctx.Value(logging.ContextIDKey), }).Info("uplink: frame(s) collected") // update the gateway meta-data if err := gateway.UpdateMetaDataInRxInfoSet(ctx, storage.DB(), rxPacket.RXInfoSet); err != nil { log.WithError(err).Error("uplink: update gateway meta-data in rx-info set error") } // log the frame for each receiving gateway. if err := framelog.LogUplinkFrameForGateways(ctx, ns.UplinkFrameLog{ PhyPayload: uplinkFrame.PhyPayload, TxInfo: rxPacket.TXInfo, RxInfo: rxPacket.RXInfoSet, }); err != nil { log.WithFields(log.Fields{ "ctx_id": ctx.Value(logging.ContextIDKey), }).WithError(err).Error("uplink: log uplink frames for gateways error") } // handle the frame based on message-type switch rxPacket.PHYPayload.MHDR.MType { case lorawan.JoinRequest: return join.Handle(ctx, rxPacket) case lorawan.RejoinRequest: return rejoin.Handle(ctx, rxPacket) case lorawan.UnconfirmedDataUp, lorawan.ConfirmedDataUp: return data.Handle(ctx, rxPacket) case lorawan.Proprietary: return proprietary.Handle(ctx, rxPacket) default: return nil } }
Class
2
func (*Provider) Render(ctx *provider.Context, config, data string) string { result := blackfriday.Run([]byte(data)) return string(result) }
Base
1
func (m *NidOptNonByteCustomType) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { preIndex := iNdEx var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowThetest } if iNdEx >= l { return io.ErrUnexpectedEOF } b := dAtA[iNdEx] iNdEx++ wire |= uint64(b&0x7F) << shift if b < 0x80 { break } } fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { return fmt.Errorf("proto: NidOptNonByteCustomType: wiretype end group for non-group") } if fieldNum <= 0 { return fmt.Errorf("proto: NidOptNonByteCustomType: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Field1", wireType) } var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowThetest } if iNdEx >= l { return io.ErrUnexpectedEOF } b := dAtA[iNdEx] iNdEx++ msglen |= int(b&0x7F) << shift if b < 0x80 { break } } if msglen < 0 { return ErrInvalidLengthThetest } postIndex := iNdEx + msglen if postIndex < 0 { return ErrInvalidLengthThetest } if postIndex > l { return io.ErrUnexpectedEOF } if err := m.Field1.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipThetest(dAtA[iNdEx:]) if err != nil { return err } if skippy < 0 { return ErrInvalidLengthThetest } if (iNdEx + skippy) < 0 { return ErrInvalidLengthThetest } if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF } m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) iNdEx += skippy } } if iNdEx > l { return io.ErrUnexpectedEOF } return nil }
Variant
0
func (svc *Service) MacadminsData(ctx context.Context, id uint) (*fleet.MacadminsData, error) { if !svc.authz.IsAuthenticatedWith(ctx, authz_ctx.AuthnDeviceToken) { if err := svc.authz.Authorize(ctx, &fleet.Host{}, fleet.ActionList); err != nil { return nil, err } host, err := svc.ds.HostLite(ctx, id) if err != nil { return nil, ctxerr.Wrap(ctx, err, "find host for macadmins") } if err := svc.authz.Authorize(ctx, host, fleet.ActionRead); err != nil { return nil, err } } var munkiInfo *fleet.HostMunkiInfo switch version, err := svc.ds.GetMunkiVersion(ctx, id); { case err != nil && !fleet.IsNotFound(err): return nil, err case err == nil: munkiInfo = &fleet.HostMunkiInfo{Version: version} } var mdm *fleet.HostMDM switch enrolled, serverURL, installedFromDep, err := svc.ds.GetMDM(ctx, id); { case err != nil && !fleet.IsNotFound(err): return nil, err case err == nil: enrollmentStatus := "Unenrolled" if enrolled && !installedFromDep { enrollmentStatus = "Enrolled (manual)" } else if enrolled && installedFromDep { enrollmentStatus = "Enrolled (automated)" } mdm = &fleet.HostMDM{ EnrollmentStatus: enrollmentStatus, ServerURL: serverURL, } } if munkiInfo == nil && mdm == nil { return nil, nil } data := &fleet.MacadminsData{ Munki: munkiInfo, MDM: mdm, } return data, nil }
Class
2
func New( localGRPCAddress string, localHTTPAddress string, fileManager *filemgr.Manager, reproxyHandler *reproxy.Handler, ) *Builder { return &Builder{ localGRPCAddress: localGRPCAddress, localHTTPAddress: localHTTPAddress, filemgr: fileManager, reproxy: reproxyHandler, } }
Class
2
func (m *NidOptNonByteCustomType) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { preIndex := iNdEx var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowThetest } if iNdEx >= l { return io.ErrUnexpectedEOF } b := dAtA[iNdEx] iNdEx++ wire |= uint64(b&0x7F) << shift if b < 0x80 { break } } fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { return fmt.Errorf("proto: NidOptNonByteCustomType: wiretype end group for non-group") } if fieldNum <= 0 { return fmt.Errorf("proto: NidOptNonByteCustomType: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Field1", wireType) } var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowThetest } if iNdEx >= l { return io.ErrUnexpectedEOF } b := dAtA[iNdEx] iNdEx++ msglen |= int(b&0x7F) << shift if b < 0x80 { break } } if msglen < 0 { return ErrInvalidLengthThetest } postIndex := iNdEx + msglen if postIndex < 0 { return ErrInvalidLengthThetest } if postIndex > l { return io.ErrUnexpectedEOF } if err := m.Field1.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipThetest(dAtA[iNdEx:]) if err != nil { return err } if skippy < 0 { return ErrInvalidLengthThetest } if (iNdEx + skippy) < 0 { return ErrInvalidLengthThetest } if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF } m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) iNdEx += skippy } } if iNdEx > l { return io.ErrUnexpectedEOF } return nil }
Variant
0
func validateAndCreateWebhook(c *context.Context, orCtx *orgRepoContext, w *db.Webhook) { c.Data["Webhook"] = w if c.HasError() { c.Success(orCtx.TmplNew) return } field, msg, ok := validateWebhook(c.User, c.Locale, w) if !ok { c.FormErr(field) c.RenderWithErr(msg, orCtx.TmplNew, nil) return } if err := w.UpdateEvent(); err != nil { c.Error(err, "update event") return } else if err := db.CreateWebhook(w); err != nil { c.Error(err, "create webhook") return } c.Flash.Success(c.Tr("repo.settings.add_hook_success")) c.Redirect(orCtx.Link + "/settings/hooks") }
Base
1
func bindMountDeviceNode(dest string, node *devices.Device) error { f, err := os.Create(dest) if err != nil && !os.IsExist(err) { return err } if f != nil { f.Close() } return unix.Mount(node.Path, dest, "bind", unix.MS_BIND, "") }
Class
2
func (s *ConsoleServer) lookupConsoleUser(ctx context.Context, unameOrEmail, password string) (id uuid.UUID, uname string, email string, role console.UserRole, err error) { role = console.UserRole_USER_ROLE_UNKNOWN query := "SELECT id, username, email, role, password, disable_time FROM console_user WHERE username = $1 OR email = $1" var dbPassword []byte var dbDisableTime pgtype.Timestamptz err = s.db.QueryRowContext(ctx, query, unameOrEmail).Scan(&id, &uname, &email, &role, &dbPassword, &dbDisableTime) if err != nil { if err == sql.ErrNoRows { err = nil } return } // Check if it's disabled. if dbDisableTime.Status == pgtype.Present && dbDisableTime.Time.Unix() != 0 { s.logger.Info("Console user account is disabled.", zap.String("username", unameOrEmail)) err = status.Error(codes.PermissionDenied, "Invalid credentials.") return } // Check password err = bcrypt.CompareHashAndPassword(dbPassword, []byte(password)) if err != nil { err = status.Error(codes.Unauthenticated, "Invalid credentials.") return } return }
Base
1
func TestDoesPolicySignatureV2Match(t *testing.T) { obj, fsDir, err := prepareFS() if err != nil { t.Fatal(err) } defer os.RemoveAll(fsDir) if err = newTestConfig(globalMinioDefaultRegion, obj); err != nil { t.Fatal(err) } creds := globalActiveCred policy := "policy" testCases := []struct { accessKey string policy string signature string errCode APIErrorCode }{ {"invalidAccessKey", policy, calculateSignatureV2(policy, creds.SecretKey), ErrInvalidAccessKeyID}, {creds.AccessKey, policy, calculateSignatureV2("random", creds.SecretKey), ErrSignatureDoesNotMatch}, {creds.AccessKey, policy, calculateSignatureV2(policy, creds.SecretKey), ErrNone}, } for i, test := range testCases { formValues := make(http.Header) formValues.Set("Awsaccesskeyid", test.accessKey) formValues.Set("Signature", test.signature) formValues.Set("Policy", test.policy) errCode := doesPolicySignatureV2Match(formValues) if errCode != test.errCode { t.Fatalf("(%d) expected to get %s, instead got %s", i+1, niceError(test.errCode), niceError(errCode)) } } }
Class
2
func (x *DeleteWalletLedgerRequest) ProtoReflect() protoreflect.Message { mi := &file_console_proto_msgTypes[22] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) }
Base
1
func (*LeaderboardList) Descriptor() ([]byte, []int) { return file_console_proto_rawDescGZIP(), []int{24} }
Base
1
func isAdminOfTheModifiedTeams(currentUser *fleet.User, originalUserTeams, newUserTeams []fleet.UserTeam) bool { // If the user is of the right global role, then they can modify the teams if currentUser.GlobalRole != nil && (*currentUser.GlobalRole == fleet.RoleAdmin || *currentUser.GlobalRole == fleet.RoleMaintainer) { return true } // otherwise, gather the resulting teams resultingTeams := make(map[uint]string) for _, team := range newUserTeams { resultingTeams[team.ID] = team.Role } // and see which ones were removed or changed from the original teamsAffected := make(map[uint]struct{}) for _, team := range originalUserTeams { if resultingTeams[team.ID] != team.Role { teamsAffected[team.ID] = struct{}{} } } // then gather the teams the current user is admin for currentUserTeamAdmin := make(map[uint]struct{}) for _, team := range currentUser.Teams { if team.Role == fleet.RoleAdmin { currentUserTeamAdmin[team.ID] = struct{}{} } } // and let's check that the teams that were either removed or changed are also teams this user is an admin of for teamID := range teamsAffected { if _, ok := currentUserTeamAdmin[teamID]; !ok { return false } } return true }
Class
2
func (m *CustomContainer) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { preIndex := iNdEx var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowThetest } if iNdEx >= l { return io.ErrUnexpectedEOF } b := dAtA[iNdEx] iNdEx++ wire |= uint64(b&0x7F) << shift if b < 0x80 { break } } fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { return fmt.Errorf("proto: CustomContainer: wiretype end group for non-group") } if fieldNum <= 0 { return fmt.Errorf("proto: CustomContainer: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field CustomStruct", wireType) } var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowThetest } if iNdEx >= l { return io.ErrUnexpectedEOF } b := dAtA[iNdEx] iNdEx++ msglen |= int(b&0x7F) << shift if b < 0x80 { break } } if msglen < 0 { return ErrInvalidLengthThetest } postIndex := iNdEx + msglen if postIndex < 0 { return ErrInvalidLengthThetest } if postIndex > l { return io.ErrUnexpectedEOF } if err := m.CustomStruct.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipThetest(dAtA[iNdEx:]) if err != nil { return err } if skippy < 0 { return ErrInvalidLengthThetest } if (iNdEx + skippy) < 0 { return ErrInvalidLengthThetest } if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF } m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) iNdEx += skippy } } if iNdEx > l { return io.ErrUnexpectedEOF } return nil }
Variant
0
func (m *UnrecognizedWithInner_Inner) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { preIndex := iNdEx var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowThetest } if iNdEx >= l { return io.ErrUnexpectedEOF } b := dAtA[iNdEx] iNdEx++ wire |= uint64(b&0x7F) << shift if b < 0x80 { break } } fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { return fmt.Errorf("proto: Inner: wiretype end group for non-group") } if fieldNum <= 0 { return fmt.Errorf("proto: Inner: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field Field1", wireType) } var v uint32 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowThetest } if iNdEx >= l { return io.ErrUnexpectedEOF } b := dAtA[iNdEx] iNdEx++ v |= uint32(b&0x7F) << shift if b < 0x80 { break } } m.Field1 = &v default: iNdEx = preIndex skippy, err := skipThetest(dAtA[iNdEx:]) if err != nil { return err } if skippy < 0 { return ErrInvalidLengthThetest } if (iNdEx + skippy) < 0 { return ErrInvalidLengthThetest } if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF } iNdEx += skippy } } if iNdEx > l { return io.ErrUnexpectedEOF } return nil }
Variant
0
func (dag *DAG) EnsureService(meta types.NamespacedName, port intstr.IntOrString, cache *KubernetesCache) (*Service, error) { svc, svcPort, err := cache.LookupService(meta, port) if err != nil { return nil, err } if dagSvc := dag.GetService(k8s.NamespacedNameOf(svc), svcPort.Port); dagSvc != nil { return dagSvc, nil } dagSvc := &Service{ Weighted: WeightedService{ ServiceName: svc.Name, ServiceNamespace: svc.Namespace, ServicePort: svcPort, Weight: 1, }, Protocol: upstreamProtocol(svc, svcPort), MaxConnections: annotation.MaxConnections(svc), MaxPendingRequests: annotation.MaxPendingRequests(svc), MaxRequests: annotation.MaxRequests(svc), MaxRetries: annotation.MaxRetries(svc), ExternalName: externalName(svc), } return dagSvc, nil }
Class
2
func TestNewOAuth2ResourceServer(t *testing.T) { newMockResourceServer(t) }
Base
1
func TestRedactURL(t *testing.T) { cases := []struct { name string url *url.URL want string }{ { name: "non-blank Password", url: &url.URL{ Scheme: "http", Host: "host.tld", Path: "this:that", User: url.UserPassword("user", "password"), }, want: "http://user:[email protected]/this:that", }, { name: "blank Password", url: &url.URL{ Scheme: "http", Host: "host.tld", Path: "this:that", User: url.User("user"), }, want: "http://[email protected]/this:that", }, { name: "nil User", url: &url.URL{ Scheme: "http", Host: "host.tld", Path: "this:that", User: url.UserPassword("", "password"), }, want: "http://:[email protected]/this:that", }, { name: "blank Username, blank Password", url: &url.URL{ Scheme: "http", Host: "host.tld", Path: "this:that", }, want: "http://host.tld/this:that", }, { name: "empty URL", url: &url.URL{}, want: "", }, { name: "nil URL", url: nil, want: "", }, } for _, tt := range cases { t := t t.Run(tt.name, func(t *testing.T) { if g, w := RedactURL(tt.url), tt.want; g != w { t.Fatalf("got: %q\nwant: %q", g, w) } }) } }
Base
1
func (m *A) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { preIndex := iNdEx var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowA } if iNdEx >= l { return io.ErrUnexpectedEOF } b := dAtA[iNdEx] iNdEx++ wire |= uint64(b&0x7F) << shift if b < 0x80 { break } } fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { return fmt.Errorf("proto: A: wiretype end group for non-group") } if fieldNum <= 0 { return fmt.Errorf("proto: A: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field F1", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowA } if iNdEx >= l { return io.ErrUnexpectedEOF } b := dAtA[iNdEx] iNdEx++ stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } intStringLen := int(stringLen) if intStringLen < 0 { return ErrInvalidLengthA } postIndex := iNdEx + intStringLen if postIndex < 0 { return ErrInvalidLengthA } if postIndex > l { return io.ErrUnexpectedEOF } m.F1 = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipA(dAtA[iNdEx:]) if err != nil { return err } if skippy < 0 { return ErrInvalidLengthA } if (iNdEx + skippy) < 0 { return ErrInvalidLengthA } if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF } m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) iNdEx += skippy } } if iNdEx > l { return io.ErrUnexpectedEOF } return nil }
Variant
0
func (x *DeleteStorageObjectRequest) ProtoReflect() protoreflect.Message { mi := &file_console_proto_msgTypes[21] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) }
Base
1
func (x *ListPurchasesRequest) ProtoReflect() protoreflect.Message { mi := &file_console_proto_msgTypes[28] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) }
Base
1
func IsLocalHostname(hostname string, allowlist []string) bool { for _, allow := range allowlist { if hostname == allow { return false } } ips, err := net.LookupIP(hostname) if err != nil { return true } for _, ip := range ips { for _, cidr := range localCIDRs { if cidr.Contains(ip) { return true } } } return false }
Base
1
func (x *StorageCollectionsList) Reset() { *x = StorageCollectionsList{} if protoimpl.UnsafeEnabled { mi := &file_console_proto_msgTypes[34] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } }
Base
1
func (x *ListAccountsRequest) ProtoReflect() protoreflect.Message { mi := &file_console_proto_msgTypes[26] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) }
Base
1
func fixTransferEncoding(requestMethod string, header Header) ([]string, error) { raw, present := header["Transfer-Encoding"] if !present { return nil, nil } delete(header, "Transfer-Encoding") encodings := strings.Split(raw[0], ",") te := make([]string, 0, len(encodings)) // TODO: Even though we only support "identity" and "chunked" // encodings, the loop below is designed with foresight. One // invariant that must be maintained is that, if present, // chunked encoding must always come first. for _, encoding := range encodings { encoding = strings.ToLower(strings.TrimSpace(encoding)) // "identity" encoding is not recorded if encoding == "identity" { break } if encoding != "chunked" { return nil, &badStringError{"unsupported transfer encoding", encoding} } te = te[0 : len(te)+1] te[len(te)-1] = encoding } if len(te) > 1 { return nil, &badStringError{"too many transfer encodings", strings.Join(te, ",")} } if len(te) > 0 { // Chunked encoding trumps Content-Length. See RFC 2616 // Section 4.4. Currently len(te) > 0 implies chunked // encoding. delete(header, "Content-Length") return te, nil } return nil, nil }
Base
1
func (x *DeleteLeaderboardRecordRequest) ProtoReflect() protoreflect.Message { mi := &file_console_proto_msgTypes[20] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) }
Base
1
func (x *CallApiEndpointRequest) Reset() { *x = CallApiEndpointRequest{} if protoimpl.UnsafeEnabled { mi := &file_console_proto_msgTypes[12] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } }
Base
1
func (x *GetWalletLedgerRequest) ProtoReflect() protoreflect.Message { mi := &file_console_proto_msgTypes[45] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) }
Base
1
func (*UpdateAccountRequest) Descriptor() ([]byte, []int) { return file_console_proto_rawDescGZIP(), []int{36} }
Base
1
func remount(m *configs.Mount, rootfs string) error { var ( dest = m.Destination ) if !strings.HasPrefix(dest, rootfs) { dest = filepath.Join(rootfs, dest) } return unix.Mount(m.Source, dest, m.Device, uintptr(m.Flags|unix.MS_REMOUNT), "") }
Class
2
func validateAndUpdateWebhook(c *context.Context, orCtx *orgRepoContext, w *db.Webhook) { c.Data["Webhook"] = w if c.HasError() { c.Success(orCtx.TmplNew) return } field, msg, ok := validateWebhook(c.User, c.Locale, w) if !ok { c.FormErr(field) c.RenderWithErr(msg, orCtx.TmplNew, nil) return } if err := w.UpdateEvent(); err != nil { c.Error(err, "update event") return } else if err := db.UpdateWebhook(w); err != nil { c.Error(err, "update webhook") return } c.Flash.Success(c.Tr("repo.settings.update_hook_success")) c.Redirect(fmt.Sprintf("%s/settings/hooks/%d", orCtx.Link, w.ID)) }
Base
1
func (m *Foo) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { preIndex := iNdEx var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowIssue617 } if iNdEx >= l { return io.ErrUnexpectedEOF } b := dAtA[iNdEx] iNdEx++ wire |= uint64(b&0x7F) << shift if b < 0x80 { break } } fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { return fmt.Errorf("proto: Foo: wiretype end group for non-group") } if fieldNum <= 0 { return fmt.Errorf("proto: Foo: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Bar", wireType) } var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowIssue617 } if iNdEx >= l { return io.ErrUnexpectedEOF } b := dAtA[iNdEx] iNdEx++ msglen |= int(b&0x7F) << shift if b < 0x80 { break } } if msglen < 0 { return ErrInvalidLengthIssue617 } postIndex := iNdEx + msglen if postIndex < 0 { return ErrInvalidLengthIssue617 } if postIndex > l { return io.ErrUnexpectedEOF } v := &Foo_Bar{} if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } m.Details = &Foo_Bar_{v} iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipIssue617(dAtA[iNdEx:]) if err != nil { return err } if skippy < 0 { return ErrInvalidLengthIssue617 } if (iNdEx + skippy) < 0 { return ErrInvalidLengthIssue617 } if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF } m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) iNdEx += skippy } } if iNdEx > l { return io.ErrUnexpectedEOF } return nil }
Variant
0
func (svc Service) ListSoftware(ctx context.Context, opt fleet.SoftwareListOptions) ([]fleet.Software, error) { if err := svc.authz.Authorize(ctx, &fleet.Software{}, fleet.ActionRead); err != nil { return nil, err } // default sort order to hosts_count descending if opt.OrderKey == "" { opt.OrderKey = "hosts_count" opt.OrderDirection = fleet.OrderDescending } opt.WithHostCounts = true return svc.ds.ListSoftware(ctx, opt) }
Class
2
func UnpackXzTar(filename string, destination string, verbosityLevel int) (err error) { Verbose = verbosityLevel if !common.FileExists(filename) { return fmt.Errorf("file %s not found", filename) } if !common.DirExists(destination) { return fmt.Errorf("directory %s not found", destination) } filename, err = common.AbsolutePath(filename) if err != nil { return err } err = os.Chdir(destination) if err != nil { return errors.Wrapf(err, "error changing directory to %s", destination) } // #nosec G304 f, err := os.Open(filename) if err != nil { return err } defer f.Close() // Create an xz Reader r, err := xz.NewReader(f, 0) if err != nil { return err } // Create a tar Reader tr := tar.NewReader(r) return unpackTarFiles(tr) }
Base
1
func (x *UserList) Reset() { *x = UserList{} if protoimpl.UnsafeEnabled { mi := &file_console_proto_msgTypes[39] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } }
Base
1
func (*StorageList) Descriptor() ([]byte, []int) { return file_console_proto_rawDescGZIP(), []int{33} }
Base
1
func mountNewCgroup(m *configs.Mount) error { var ( data = m.Data source = m.Source ) if data == "systemd" { data = cgroups.CgroupNamePrefix + data source = "systemd" } if err := unix.Mount(source, m.Destination, m.Device, uintptr(m.Flags), data); err != nil { return err } return nil }
Class
2
func (x *MatchState) ProtoReflect() protoreflect.Message { mi := &file_console_proto_msgTypes[31] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) }
Base
1
func (m *R) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { preIndex := iNdEx var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowExample } if iNdEx >= l { return io.ErrUnexpectedEOF } b := dAtA[iNdEx] iNdEx++ wire |= uint64(b&0x7F) << shift if b < 0x80 { break } } fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { return fmt.Errorf("proto: R: wiretype end group for non-group") } if fieldNum <= 0 { return fmt.Errorf("proto: R: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field Recognized", wireType) } var v uint32 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowExample } if iNdEx >= l { return io.ErrUnexpectedEOF } b := dAtA[iNdEx] iNdEx++ v |= uint32(b&0x7F) << shift if b < 0x80 { break } } m.Recognized = &v default: iNdEx = preIndex skippy, err := skipExample(dAtA[iNdEx:]) if err != nil { return err } if skippy < 0 { return ErrInvalidLengthExample } if (iNdEx + skippy) < 0 { return ErrInvalidLengthExample } if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF } iNdEx += skippy } } if iNdEx > l { return io.ErrUnexpectedEOF } return nil }
Variant
0
func (svc *Service) OSVersions(ctx context.Context, teamID *uint, platform *string) (*fleet.OSVersions, error) { if err := svc.authz.Authorize(ctx, &fleet.Host{TeamID: teamID}, fleet.ActionList); err != nil { return nil, err } osVersions, err := svc.ds.OSVersions(ctx, teamID, platform) if err != nil { return nil, err } return osVersions, nil }
Class
2
func newSessionService() { SessionProvider = Cfg.MustValueRange("session", "PROVIDER", "memory", []string{"memory", "file", "redis", "mysql"}) SessionConfig = new(session.Config) SessionConfig.ProviderConfig = strings.Trim(Cfg.MustValue("session", "PROVIDER_CONFIG"), "\" ") SessionConfig.CookieName = Cfg.MustValue("session", "COOKIE_NAME", "i_like_gogits") SessionConfig.CookiePath = AppSubUrl SessionConfig.Secure = Cfg.MustBool("session", "COOKIE_SECURE") SessionConfig.EnableSetCookie = Cfg.MustBool("session", "ENABLE_SET_COOKIE", true) SessionConfig.Gclifetime = Cfg.MustInt64("session", "GC_INTERVAL_TIME", 86400) SessionConfig.Maxlifetime = Cfg.MustInt64("session", "SESSION_LIFE_TIME", 86400) SessionConfig.SessionIDHashFunc = Cfg.MustValueRange("session", "SESSION_ID_HASHFUNC", "sha1", []string{"sha1", "sha256", "md5"}) SessionConfig.SessionIDHashKey = Cfg.MustValue("session", "SESSION_ID_HASHKEY", string(com.RandomCreateBytes(16))) if SessionProvider == "file" { os.MkdirAll(path.Dir(SessionConfig.ProviderConfig), os.ModePerm) } log.Info("Session Service Enabled") }
Base
1
func (mbox *Mailbox) newClient() (*client.Client, error) { var imapClient *client.Client var err error if mbox.TLS { config := new(tls.Config) config.InsecureSkipVerify = mbox.IgnoreCertErrors imapClient, err = client.DialTLS(mbox.Host, config) } else { imapClient, err = client.Dial(mbox.Host) } if err != nil { return imapClient, err } err = imapClient.Login(mbox.User, mbox.Pwd) if err != nil { return imapClient, err } _, err = imapClient.Select(mbox.Folder, mbox.ReadOnly) if err != nil { return imapClient, err } return imapClient, nil }
Base
1
func (r *TokenRevocationHandler) RevokeToken(ctx context.Context, token string, tokenType fosite.TokenType, client fosite.Client) error { discoveryFuncs := []func() (request fosite.Requester, err error){ func() (request fosite.Requester, err error) { // Refresh token signature := r.RefreshTokenStrategy.RefreshTokenSignature(token) return r.TokenRevocationStorage.GetRefreshTokenSession(ctx, signature, nil) }, func() (request fosite.Requester, err error) { // Access token signature := r.AccessTokenStrategy.AccessTokenSignature(token) return r.TokenRevocationStorage.GetAccessTokenSession(ctx, signature, nil) }, } // Token type hinting if tokenType == fosite.AccessToken { discoveryFuncs[0], discoveryFuncs[1] = discoveryFuncs[1], discoveryFuncs[0] } var ar fosite.Requester var err error if ar, err = discoveryFuncs[0](); err != nil { ar, err = discoveryFuncs[1]() } if err != nil { return err } if ar.GetClient().GetID() != client.GetID() { return errors.WithStack(fosite.ErrRevocationClientMismatch) } requestID := ar.GetID() r.TokenRevocationStorage.RevokeRefreshToken(ctx, requestID) r.TokenRevocationStorage.RevokeAccessToken(ctx, requestID) return nil }
Class
2
func SearchRepositoryByName(opt SearchOption) (repos []*Repository, err error) { // Prevent SQL inject. opt.Keyword = FilterSQLInject(opt.Keyword) if len(opt.Keyword) == 0 { return repos, nil } opt.Keyword = strings.ToLower(opt.Keyword) repos = make([]*Repository, 0, opt.Limit) // Append conditions. sess := x.Limit(opt.Limit) if opt.Uid > 0 { sess.Where("owner_id=?", opt.Uid) } if !opt.Private { sess.And("is_private=false") } sess.And("lower_name like '%" + opt.Keyword + "%'").Find(&repos) return repos, err }
Base
1
func (m *TestRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { preIndex := iNdEx var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowEmpty } if iNdEx >= l { return io.ErrUnexpectedEOF } b := dAtA[iNdEx] iNdEx++ wire |= uint64(b&0x7F) << shift if b < 0x80 { break } } fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { return fmt.Errorf("proto: TestRequest: wiretype end group for non-group") } if fieldNum <= 0 { return fmt.Errorf("proto: TestRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { default: iNdEx = preIndex skippy, err := skipEmpty(dAtA[iNdEx:]) if err != nil { return err } if skippy < 0 { return ErrInvalidLengthEmpty } if (iNdEx + skippy) < 0 { return ErrInvalidLengthEmpty } if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF } m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) iNdEx += skippy } } if iNdEx > l { return io.ErrUnexpectedEOF } return nil }
Variant
0
func (cn *clusterNode) resurrect() { gRPCServer, err := comm_utils.NewGRPCServer(cn.bindAddress, cn.serverConfig) if err != nil { panic(fmt.Errorf("failed starting gRPC server: %v", err)) } cn.srv = gRPCServer orderer.RegisterClusterServer(gRPCServer.Server(), cn) go cn.srv.Start() }
Class
2
func (ctx *cbcAEAD) Open(dst, nonce, ciphertext, data []byte) ([]byte, error) { if len(ciphertext) < ctx.authtagBytes { return nil, errors.New("square/go-jose: invalid ciphertext (too short)") } offset := len(ciphertext) - ctx.authtagBytes expectedTag := ctx.computeAuthTag(data, nonce, ciphertext[:offset]) match := subtle.ConstantTimeCompare(expectedTag, ciphertext[offset:]) if match != 1 { return nil, errors.New("square/go-jose: invalid ciphertext (auth tag mismatch)") } cbc := cipher.NewCBCDecrypter(ctx.blockCipher, nonce) // Make copy of ciphertext buffer, don't want to modify in place buffer := append([]byte{}, []byte(ciphertext[:offset])...) if len(buffer)%ctx.blockCipher.BlockSize() > 0 { return nil, errors.New("square/go-jose: invalid ciphertext (invalid length)") } cbc.CryptBlocks(buffer, buffer) // Remove padding plaintext, err := unpadBuffer(buffer, ctx.blockCipher.BlockSize()) if err != nil { return nil, err } ret, out := resize(dst, len(dst)+len(plaintext)) copy(out, plaintext) return ret, nil }
Base
1
func (hs *HTTPServer) getPluginAssets(c *models.ReqContext) { pluginID := web.Params(c.Req)[":pluginId"] plugin, exists := hs.pluginStore.Plugin(c.Req.Context(), pluginID) if !exists { c.JsonApiErr(404, "Plugin not found", nil) return } requestedFile := filepath.Clean(web.Params(c.Req)["*"]) pluginFilePath := filepath.Join(plugin.PluginDir, requestedFile) if !plugin.IncludedInSignature(requestedFile) { hs.log.Warn("Access to requested plugin file will be forbidden in upcoming Grafana versions as the file "+ "is not included in the plugin signature", "file", requestedFile) } // It's safe to ignore gosec warning G304 since we already clean the requested file path and subsequently // use this with a prefix of the plugin's directory, which is set during plugin loading // nolint:gosec f, err := os.Open(pluginFilePath) if err != nil { if os.IsNotExist(err) { c.JsonApiErr(404, "Plugin file not found", err) return } c.JsonApiErr(500, "Could not open plugin file", err) return } defer func() { if err := f.Close(); err != nil { hs.log.Error("Failed to close file", "err", err) } }() fi, err := f.Stat() if err != nil { c.JsonApiErr(500, "Plugin file exists but could not open", err) return } if hs.Cfg.Env == setting.Dev { c.Resp.Header().Set("Cache-Control", "max-age=0, must-revalidate, no-cache") } else { c.Resp.Header().Set("Cache-Control", "public, max-age=3600") } http.ServeContent(c.Resp, c.Req, pluginFilePath, fi.ModTime(), f) }
Base
1
func (a *APIs) PostLogin(v *PostLoginReq) *kongchuanhujiao.Response { if v.Code != account.GetCode(v.ID) || v.Code == "" { // FIXME datahub 鉴权 return kongchuanhujiao.GenerateErrResp(1, "验证码有误") } now := time.Now() t, err := jwt.NewTokenWithClaims(jwt.SigningMethodES256, jwt.MapClaims{ "iss": config.GetJWTConf().Iss, "sub": v.ID, "exp": now.AddDate(0, 1, 0).Unix(), "nbf": now.Unix(), "iat": now.Unix(), }).SignedString(config.GetJWTConf().Key) if err != nil { logger.Error("生成 JWT Token 失败", zap.Error(err)) return kongchuanhujiao.DefaultErrResp } return &kongchuanhujiao.Response{Message: t} }
Base
1
func makeStreamDistributedQueryCampaignResultsHandler(svc kolide.Service, jwtKey string, logger kitlog.Logger) http.Handler { opt := sockjs.DefaultOptions opt.Websocket = true opt.RawWebsocket = true return sockjs.NewHandler("/api/v1/kolide/results", opt, func(session sockjs.Session) { defer session.Close(0, "none") conn := &websocket.Conn{Session: session} // Receive the auth bearer token token, err := conn.ReadAuthToken() if err != nil { logger.Log("err", err, "msg", "failed to read auth token") return } // Authenticate with the token vc, err := authViewer(context.Background(), jwtKey, token, svc) if err != nil || !vc.CanPerformActions() { logger.Log("err", err, "msg", "unauthorized viewer") conn.WriteJSONError("unauthorized") return } ctx := viewer.NewContext(context.Background(), *vc) msg, err := conn.ReadJSONMessage() if err != nil { logger.Log("err", err, "msg", "reading select_campaign JSON") conn.WriteJSONError("error reading select_campaign") return } if msg.Type != "select_campaign" { logger.Log("err", "unexpected msg type, expected select_campaign", "msg-type", msg.Type) conn.WriteJSONError("expected select_campaign") return } var info struct { CampaignID uint `json:"campaign_id"` } err = json.Unmarshal(*(msg.Data.(*json.RawMessage)), &info) if err != nil { logger.Log("err", err, "msg", "unmarshaling select_campaign data") conn.WriteJSONError("error unmarshaling select_campaign data") return } if info.CampaignID == 0 { logger.Log("err", "campaign ID not set") conn.WriteJSONError("0 is not a valid campaign ID") return } svc.StreamCampaignResults(ctx, conn, info.CampaignID) }) }
Class
2
func (x *StatusList_Status) ProtoReflect() protoreflect.Message { mi := &file_console_proto_msgTypes[49] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) }
Base
1
func mountCgroupV2(m *configs.Mount, c *mountConfig) error { dest, err := securejoin.SecureJoin(c.root, m.Destination) if err != nil { return err } if err := os.MkdirAll(dest, 0755); err != nil { return err } if err := unix.Mount(m.Source, dest, "cgroup2", uintptr(m.Flags), m.Data); err != nil { // when we are in UserNS but CgroupNS is not unshared, we cannot mount cgroup2 (#2158) if err == unix.EPERM || err == unix.EBUSY { src := fs2.UnifiedMountpoint if c.cgroupns && c.cgroup2Path != "" { // Emulate cgroupns by bind-mounting // the container cgroup path rather than // the whole /sys/fs/cgroup. src = c.cgroup2Path } err = unix.Mount(src, dest, "", uintptr(m.Flags)|unix.MS_BIND, "") if err == unix.ENOENT && c.rootlessCgroups { err = nil } return err } return err } return nil }
Class
2
func AppList(c *gin.Context) { //service.MyService.Docker().DockerContainerCommit("test2") index := c.DefaultQuery("index", "1") size := c.DefaultQuery("size", "10000") t := c.DefaultQuery("type", "rank") categoryId := c.DefaultQuery("category_id", "0") key := c.DefaultQuery("key", "") recommend, list, community := service.MyService.OAPI().GetServerList(index, size, t, categoryId, key) // for i := 0; i < len(recommend); i++ { // ct, _ := service.MyService.Docker().DockerListByImage(recommend[i].Image, recommend[i].ImageVersion) // if ct != nil { // recommend[i].State = ct.State // } // } // for i := 0; i < len(list); i++ { // ct, _ := service.MyService.Docker().DockerListByImage(list[i].Image, list[i].ImageVersion) // if ct != nil { // list[i].State = ct.State // } // } // for i := 0; i < len(community); i++ { // ct, _ := service.MyService.Docker().DockerListByImage(community[i].Image, community[i].ImageVersion) // if ct != nil { // community[i].State = ct.State // } // } data := make(map[string]interface{}, 3) data["recommend"] = recommend data["list"] = list data["community"] = community c.JSON(http.StatusOK, &model.Result{Success: oasis_err2.SUCCESS, Message: oasis_err2.GetMsg(oasis_err2.SUCCESS), Data: data}) }
Base
1
func (m *FakeMap) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { preIndex := iNdEx var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowMap } if iNdEx >= l { return io.ErrUnexpectedEOF } b := dAtA[iNdEx] iNdEx++ wire |= uint64(b&0x7F) << shift if b < 0x80 { break } } fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { return fmt.Errorf("proto: FakeMap: wiretype end group for non-group") } if fieldNum <= 0 { return fmt.Errorf("proto: FakeMap: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Entries", wireType) } var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowMap } if iNdEx >= l { return io.ErrUnexpectedEOF } b := dAtA[iNdEx] iNdEx++ msglen |= int(b&0x7F) << shift if b < 0x80 { break } } if msglen < 0 { return ErrInvalidLengthMap } postIndex := iNdEx + msglen if postIndex < 0 { return ErrInvalidLengthMap } if postIndex > l { return io.ErrUnexpectedEOF } m.Entries = append(m.Entries, &FakeMapEntry{}) if err := m.Entries[len(m.Entries)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipMap(dAtA[iNdEx:]) if err != nil { return err } if skippy < 0 { return ErrInvalidLengthMap } if (iNdEx + skippy) < 0 { return ErrInvalidLengthMap } if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF } m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) iNdEx += skippy } } if iNdEx > l { return io.ErrUnexpectedEOF } return nil }
Variant
0
func (x *DeleteLeaderboardRecordRequest) Reset() { *x = DeleteLeaderboardRecordRequest{} if protoimpl.UnsafeEnabled { mi := &file_console_proto_msgTypes[20] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } }
Base
1
func (m *Empty) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { preIndex := iNdEx var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowEmpty } if iNdEx >= l { return io.ErrUnexpectedEOF } b := dAtA[iNdEx] iNdEx++ wire |= uint64(b&0x7F) << shift if b < 0x80 { break } } fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { return fmt.Errorf("proto: Empty: wiretype end group for non-group") } if fieldNum <= 0 { return fmt.Errorf("proto: Empty: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { default: iNdEx = preIndex skippy, err := skipEmpty(dAtA[iNdEx:]) if err != nil { return err } if skippy < 0 { return ErrInvalidLengthEmpty } if (iNdEx + skippy) < 0 { return ErrInvalidLengthEmpty } if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF } m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) iNdEx += skippy } } if iNdEx > l { return io.ErrUnexpectedEOF } return nil }
Variant
0
func (EmptyEvidencePool) AddEvidenceFromConsensus(evidence types.Evidence) error { return nil }
Class
2
func TestReadWriteCompactProtocol(t *testing.T) { ReadWriteProtocolTest(t, NewCompactProtocolFactory()) // CompactProtocol is capable of reading and writing in different goroutines. ReadWriteProtocolParallelTest(t, NewCompactProtocolFactory()) transports := []Transport{ NewMemoryBuffer(), NewStreamTransportRW(bytes.NewBuffer(make([]byte, 0, 16384))), NewFramedTransport(NewMemoryBuffer()), } for _, trans := range transports { p := NewCompactProtocol(trans) ReadWriteBool(t, p, trans) p = NewCompactProtocol(trans) ReadWriteByte(t, p, trans) p = NewCompactProtocol(trans) ReadWriteI16(t, p, trans) p = NewCompactProtocol(trans) ReadWriteI32(t, p, trans) p = NewCompactProtocol(trans) ReadWriteI64(t, p, trans) p = NewCompactProtocol(trans) ReadWriteDouble(t, p, trans) p = NewCompactProtocol(trans) ReadWriteFloat(t, p, trans) p = NewCompactProtocol(trans) ReadWriteString(t, p, trans) p = NewCompactProtocol(trans) ReadWriteBinary(t, p, trans) p = NewCompactProtocol(trans) ReadWriteStruct(t, p, trans) trans.Close() } }
Base
1
func (m *Subby) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { preIndex := iNdEx var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowOne } if iNdEx >= l { return io.ErrUnexpectedEOF } b := dAtA[iNdEx] iNdEx++ wire |= uint64(b&0x7F) << shift if b < 0x80 { break } } fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { return fmt.Errorf("proto: Subby: wiretype end group for non-group") } if fieldNum <= 0 { return fmt.Errorf("proto: Subby: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Sub", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowOne } if iNdEx >= l { return io.ErrUnexpectedEOF } b := dAtA[iNdEx] iNdEx++ stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } intStringLen := int(stringLen) if intStringLen < 0 { return ErrInvalidLengthOne } postIndex := iNdEx + intStringLen if postIndex < 0 { return ErrInvalidLengthOne } if postIndex > l { return io.ErrUnexpectedEOF } s := string(dAtA[iNdEx:postIndex]) m.Sub = &s iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipOne(dAtA[iNdEx:]) if err != nil { return err } if skippy < 0 { return ErrInvalidLengthOne } if (iNdEx + skippy) < 0 { return ErrInvalidLengthOne } if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF } m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) iNdEx += skippy } } if iNdEx > l { return io.ErrUnexpectedEOF } return nil }
Variant
0
func (p *BinaryProtocol) readStringBody(size int32) (value string, err error) { if size < 0 { return "", nil } if uint64(size) > p.trans.RemainingBytes() { return "", invalidDataLength } var buf []byte if int(size) <= len(p.buffer) { buf = p.buffer[0:size] } else { buf = make([]byte, size) } _, e := io.ReadFull(p.trans, buf) return string(buf), NewProtocolException(e) }
Base
1
func (m *E) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { preIndex := iNdEx var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowExample } if iNdEx >= l { return io.ErrUnexpectedEOF } b := dAtA[iNdEx] iNdEx++ wire |= uint64(b&0x7F) << shift if b < 0x80 { break } } fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { return fmt.Errorf("proto: E: wiretype end group for non-group") } if fieldNum <= 0 { return fmt.Errorf("proto: E: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { default: if (fieldNum >= 1) && (fieldNum < 536870912) { var sizeOfWire int for { sizeOfWire++ wire >>= 7 if wire == 0 { break } } iNdEx -= sizeOfWire skippy, err := skipExample(dAtA[iNdEx:]) if err != nil { return err } if skippy < 0 { return ErrInvalidLengthExample } if (iNdEx + skippy) < 0 { return ErrInvalidLengthExample } if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF } github_com_gogo_protobuf_proto.AppendExtension(m, int32(fieldNum), dAtA[iNdEx:iNdEx+skippy]) iNdEx += skippy } else { iNdEx = preIndex skippy, err := skipExample(dAtA[iNdEx:]) if err != nil { return err } if skippy < 0 { return ErrInvalidLengthExample } if (iNdEx + skippy) < 0 { return ErrInvalidLengthExample } if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF } m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) iNdEx += skippy } } } if iNdEx > l { return io.ErrUnexpectedEOF } return nil }
Variant
0
func createDefaultConfigFileIfNotExists() error { defaultFilePath := GetDefaultConfigFilePath() if isExists(defaultFilePath) { return nil } folderPath := filepath.Dir(defaultFilePath) if !isExists(folderPath) { err := os.Mkdir(folderPath, folderPermission) if err != nil { return err } } f, err := os.Create(defaultFilePath) if err != nil { return err } return f.Close() }
Base
1
func (m *Wilson) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { preIndex := iNdEx var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowCasttype } if iNdEx >= l { return io.ErrUnexpectedEOF } b := dAtA[iNdEx] iNdEx++ wire |= uint64(b&0x7F) << shift if b < 0x80 { break } } fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { return fmt.Errorf("proto: Wilson: wiretype end group for non-group") } if fieldNum <= 0 { return fmt.Errorf("proto: Wilson: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field Int64", wireType) } var v int64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowCasttype } if iNdEx >= l { return io.ErrUnexpectedEOF } b := dAtA[iNdEx] iNdEx++ v |= int64(b&0x7F) << shift if b < 0x80 { break } } m.Int64 = &v default: iNdEx = preIndex skippy, err := skipCasttype(dAtA[iNdEx:]) if err != nil { return err } if skippy < 0 { return ErrInvalidLengthCasttype } if (iNdEx + skippy) < 0 { return ErrInvalidLengthCasttype } if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF } m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) iNdEx += skippy } } if iNdEx > l { return io.ErrUnexpectedEOF } return nil }
Variant
0
func (f *ScmpFilter) addRuleGeneric(call ScmpSyscall, action ScmpAction, exact bool, conds []ScmpCondition) error { f.lock.Lock() defer f.lock.Unlock() if !f.valid { return errBadFilter } if len(conds) == 0 { if err := f.addRuleWrapper(call, action, exact, nil); err != nil { return err } } else { // We don't support conditional filtering in library version v2.1 if !checkVersionAbove(2, 2, 1) { return VersionError{ message: "conditional filtering is not supported", minimum: "2.2.1", } } for _, cond := range conds { cmpStruct := C.make_struct_arg_cmp(C.uint(cond.Argument), cond.Op.toNative(), C.uint64_t(cond.Operand1), C.uint64_t(cond.Operand2)) defer C.free(cmpStruct) if err := f.addRuleWrapper(call, action, exact, C.scmp_cast_t(cmpStruct)); err != nil { return err } } } return nil }
Class
2
func (d *partialArray) add(key string, val *lazyNode) error { if key == "-" { *d = append(*d, val) return nil } idx, err := strconv.Atoi(key) if err != nil { return err } ary := make([]*lazyNode, len(*d)+1) cur := *d if idx < 0 { idx *= -1 if idx > len(ary) { return fmt.Errorf("Unable to access invalid index: %d", idx) } idx = len(ary) - idx } copy(ary[0:idx], cur[0:idx]) ary[idx] = val copy(ary[idx+1:], cur[idx:]) *d = ary return nil }
Base
1
func (m *Wilson) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { preIndex := iNdEx var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowCastvalue } if iNdEx >= l { return io.ErrUnexpectedEOF } b := dAtA[iNdEx] iNdEx++ wire |= uint64(b&0x7F) << shift if b < 0x80 { break } } fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { return fmt.Errorf("proto: Wilson: wiretype end group for non-group") } if fieldNum <= 0 { return fmt.Errorf("proto: Wilson: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field Int64", wireType) } var v int64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowCastvalue } if iNdEx >= l { return io.ErrUnexpectedEOF } b := dAtA[iNdEx] iNdEx++ v |= int64(b&0x7F) << shift if b < 0x80 { break } } m.Int64 = &v default: iNdEx = preIndex skippy, err := skipCastvalue(dAtA[iNdEx:]) if err != nil { return err } if skippy < 0 { return ErrInvalidLengthCastvalue } if (iNdEx + skippy) < 0 { return ErrInvalidLengthCastvalue } if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF } m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) iNdEx += skippy } } if iNdEx > l { return io.ErrUnexpectedEOF } return nil }
Variant
0
func MkdirSecure(pth string) (err error) { err = os.MkdirAll(pth, 0755) if err != nil { err = &errortypes.WriteError{ errors.Wrap(err, "utils: Failed to create directory"), } return } err = acl.Apply( pth, true, false, acl.GrantName(windows.GENERIC_ALL, "CREATOR OWNER"), acl.GrantName(windows.GENERIC_ALL, "SYSTEM"), acl.GrantName(windows.GENERIC_ALL, "Administrators"), ) if err != nil { err = &errortypes.WriteError{ errors.Wrap(err, "utils: Failed to acl directory"), } return } return }
Class
2
func (m *DroppedWithoutGetters) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { preIndex := iNdEx var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTypedeclall } if iNdEx >= l { return io.ErrUnexpectedEOF } b := dAtA[iNdEx] iNdEx++ wire |= uint64(b&0x7F) << shift if b < 0x80 { break } } fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { return fmt.Errorf("proto: DroppedWithoutGetters: wiretype end group for non-group") } if fieldNum <= 0 { return fmt.Errorf("proto: DroppedWithoutGetters: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field Height", wireType) } m.Height = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTypedeclall } if iNdEx >= l { return io.ErrUnexpectedEOF } b := dAtA[iNdEx] iNdEx++ m.Height |= int64(b&0x7F) << shift if b < 0x80 { break } } case 2: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field Width", wireType) } m.Width = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTypedeclall } if iNdEx >= l { return io.ErrUnexpectedEOF } b := dAtA[iNdEx] iNdEx++ m.Width |= int64(b&0x7F) << shift if b < 0x80 { break } } default: iNdEx = preIndex skippy, err := skipTypedeclall(dAtA[iNdEx:]) if err != nil { return err } if skippy < 0 { return ErrInvalidLengthTypedeclall } if (iNdEx + skippy) < 0 { return ErrInvalidLengthTypedeclall } if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF } iNdEx += skippy } } if iNdEx > l { return io.ErrUnexpectedEOF } return nil }
Variant
0
func (m *NinRepNonByteCustomType) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { preIndex := iNdEx var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowThetest } if iNdEx >= l { return io.ErrUnexpectedEOF } b := dAtA[iNdEx] iNdEx++ wire |= uint64(b&0x7F) << shift if b < 0x80 { break } } fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { return fmt.Errorf("proto: NinRepNonByteCustomType: wiretype end group for non-group") } if fieldNum <= 0 { return fmt.Errorf("proto: NinRepNonByteCustomType: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Field1", wireType) } var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowThetest } if iNdEx >= l { return io.ErrUnexpectedEOF } b := dAtA[iNdEx] iNdEx++ msglen |= int(b&0x7F) << shift if b < 0x80 { break } } if msglen < 0 { return ErrInvalidLengthThetest } postIndex := iNdEx + msglen if postIndex < 0 { return ErrInvalidLengthThetest } if postIndex > l { return io.ErrUnexpectedEOF } m.Field1 = append(m.Field1, T{}) if err := m.Field1[len(m.Field1)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipThetest(dAtA[iNdEx:]) if err != nil { return err } if skippy < 0 { return ErrInvalidLengthThetest } if (iNdEx + skippy) < 0 { return ErrInvalidLengthThetest } if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF } m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) iNdEx += skippy } } if iNdEx > l { return io.ErrUnexpectedEOF } return nil }
Variant
0
func (x *UpdateGroupUserStateRequest) ProtoReflect() protoreflect.Message { mi := &file_console_proto_msgTypes[19] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) } return ms } return mi.MessageOf(x) }
Base
1
func (b *Builder) buildControlPlanePathRoute(path string, protected bool) (*envoy_config_route_v3.Route, error) { r := &envoy_config_route_v3.Route{ Name: "pomerium-path-" + path, Match: &envoy_config_route_v3.RouteMatch{ PathSpecifier: &envoy_config_route_v3.RouteMatch_Path{Path: path}, }, Action: &envoy_config_route_v3.Route_Route{ Route: &envoy_config_route_v3.RouteAction{ ClusterSpecifier: &envoy_config_route_v3.RouteAction_Cluster{ Cluster: httpCluster, }, }, }, } if !protected { r.TypedPerFilterConfig = map[string]*any.Any{ "envoy.filters.http.ext_authz": disableExtAuthz, } } return r, nil }
Class
2
func (m *DeepLeaf) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { preIndex := iNdEx var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowThetest } if iNdEx >= l { return io.ErrUnexpectedEOF } b := dAtA[iNdEx] iNdEx++ wire |= uint64(b&0x7F) << shift if b < 0x80 { break } } fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { return fmt.Errorf("proto: DeepLeaf: wiretype end group for non-group") } if fieldNum <= 0 { return fmt.Errorf("proto: DeepLeaf: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Tree", wireType) } var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowThetest } if iNdEx >= l { return io.ErrUnexpectedEOF } b := dAtA[iNdEx] iNdEx++ msglen |= int(b&0x7F) << shift if b < 0x80 { break } } if msglen < 0 { return ErrInvalidLengthThetest } postIndex := iNdEx + msglen if postIndex < 0 { return ErrInvalidLengthThetest } if postIndex > l { return io.ErrUnexpectedEOF } if err := m.Tree.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipThetest(dAtA[iNdEx:]) if err != nil { return err } if skippy < 0 { return ErrInvalidLengthThetest } if (iNdEx + skippy) < 0 { return ErrInvalidLengthThetest } if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF } m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) iNdEx += skippy } } if iNdEx > l { return io.ErrUnexpectedEOF } return nil }
Variant
0
func (*WriteStorageObjectRequest) Descriptor() ([]byte, []int) { return file_console_proto_rawDescGZIP(), []int{44} }
Base
1
func (o *casaService) GetServerAppInfo(id, t string) model.ServerAppList { head := make(map[string]string) head["Authorization"] = GetToken() infoS := httper2.Get(config.ServerInfo.ServerApi+"/v2/app/info/"+id+"?t="+t, head) info := model.ServerAppList{} json2.Unmarshal([]byte(gjson.Get(infoS, "data").String()), &info) return info }
Base
1
func TestToFromBig(t *testing.T) { for i, test := range toFromBigTests { n, _ := new(big.Int).SetString(test, 16) var x p224FieldElement p224FromBig(&x, n) m := p224ToBig(&x) if n.Cmp(m) != 0 { t.Errorf("#%d: %x != %x", i, n, m) } q := p224AlternativeToBig(&x) if n.Cmp(q) != 0 { t.Errorf("#%d: %x != %x (alternative)", i, n, m) } } }
Pillar
3