kubenetworks/kubevpn

View on GitHub

Showing 333 of 526 total issues

Avoid deeply nested control flow statements.
Open

                        if err != nil {
                            log.Errorf("Failed to add hosts(%s) to hosts: %v", entryList2String(appendHosts), err)
                        }
Severity: Major
Found in pkg/dns/dns.go - About 45 mins to fix

    Function ParseProxyInfo has 7 return statements (exceeds 4 allowed).
    Open

    func ParseProxyInfo(conn net.Conn) (id stack.TransportEndpointID, err error) {
        var n int
        var port = make([]byte, 2)
    
        // local port
    Severity: Major
    Found in pkg/core/gvisortcpforwarder.go - About 45 mins to fix

      Function transportTun has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      func transportTun(ctx context.Context, tunInbound <-chan *DataElem, tunOutbound chan<- *DataElem, packetConn net.PacketConn, routeMapUDP *RouteMap, routeMapTCP *sync.Map) error {
      Severity: Minor
      Found in pkg/core/tunhandler.go - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                                if err != nil {
                                    log.Errorf("Failed to remove hosts(%s) to hosts: %v", entryList2String(list), err)
                                }
        Severity: Major
        Found in pkg/dns/dns.go - About 45 mins to fix

          Method Config.CancelDNS has 7 return statements (exceeds 4 allowed).
          Open

          func (c *Config) CancelDNS() {
              if cancel != nil {
                  cancel()
              }
              dir := "/etc/resolver"
          Severity: Major
          Found in pkg/dns/dns_unix.go - About 45 mins to fix

            Method CloneOptions.InitClient has 6 return statements (exceeds 4 allowed).
            Open

            func (d *CloneOptions) InitClient(f cmdutil.Factory) (err error) {
                d.factory = f
                if d.config, err = d.factory.ToRESTConfig(); err != nil {
                    return
                }
            Severity: Major
            Found in pkg/handler/clone.go - About 40 mins to fix

              Method CloneOptions.setVolume has 6 return statements (exceeds 4 allowed).
              Open

              func (d *CloneOptions) setVolume(u *unstructured.Unstructured) error {
              
                  const TokenVolumeMountPath = "/var/run/secrets/kubernetes.io/serviceaccount"
              
                  type VolumeMountContainerPair struct {
              Severity: Major
              Found in pkg/handler/clone.go - About 40 mins to fix

                Function GetManifest has 6 return statements (exceeds 4 allowed).
                Open

                func GetManifest(httpCli *http.Client, os string, arch string) (version string, url string, err error) {
                    var resp *http.Response
                    var errs []error
                    for _, a := range address {
                        resp, err = httpCli.Get(a)
                Severity: Major
                Found in pkg/util/upgrade.go - About 40 mins to fix

                  Function CmdRemove has 6 return statements (exceeds 4 allowed).
                  Open

                  func CmdRemove(f cmdutil.Factory) *cobra.Command {
                      var cmd = &cobra.Command{
                          Use:   "remove",
                          Short: "Remove clone resource",
                          Long: templates.LongDesc(i18n.T(`
                  Severity: Major
                  Found in cmd/kubevpn/cmds/remove.go - About 40 mins to fix

                    Function UnzipKubeVPNIntoFile has 6 return statements (exceeds 4 allowed).
                    Open

                    func UnzipKubeVPNIntoFile(zipFile, filename string) error {
                        archive, err := zip.OpenReader(zipFile)
                        if err != nil {
                            return err
                        }
                    Severity: Major
                    Found in pkg/util/upgrade.go - About 40 mins to fix

                      Function CmdDaemon has 6 return statements (exceeds 4 allowed).
                      Open

                      func CmdDaemon(_ cmdutil.Factory) *cobra.Command {
                          var opt = &daemon.SvrOption{}
                          cmd := &cobra.Command{
                              Use:   "daemon",
                              Short: i18n.T("Startup kubevpn daemon server"),
                      Severity: Major
                      Found in cmd/kubevpn/cmds/daemon.go - About 40 mins to fix

                        Method ConnectOptions.portForward has 6 return statements (exceeds 4 allowed).
                        Open

                        func (c *ConnectOptions) portForward(ctx context.Context, portPair []string) error {
                            firstCtx, firstCancelFunc := context.WithCancel(ctx)
                            defer firstCancelFunc()
                            var errChan = make(chan error, 1)
                            go func() {
                        Severity: Major
                        Found in pkg/handler/connect.go - About 40 mins to fix

                          Function CmdLeave has 6 return statements (exceeds 4 allowed).
                          Open

                          func CmdLeave(f cmdutil.Factory) *cobra.Command {
                              var leaveCmd = &cobra.Command{
                                  Use:   "leave",
                                  Short: i18n.T("Leave proxy resource"),
                                  Long: templates.LongDesc(i18n.T(`
                          Severity: Major
                          Found in cmd/kubevpn/cmds/leave.go - About 40 mins to fix

                            Function CmdLogs has 6 return statements (exceeds 4 allowed).
                            Open

                            func CmdLogs(f cmdutil.Factory) *cobra.Command {
                                req := &rpc.LogRequest{}
                                cmd := &cobra.Command{
                                    Use:   "logs",
                                    Short: i18n.T("Log kubevpn daemon grpc server"),
                            Severity: Major
                            Found in cmd/kubevpn/cmds/logs.go - About 40 mins to fix

                              Function DownloadFileWithName has 6 return statements (exceeds 4 allowed).
                              Open

                              func DownloadFileWithName(uri, name string) (string, error) {
                                  resp, err := getWithRetry(uri)
                                  if err != nil {
                                      return "", err
                                  }
                              Severity: Major
                              Found in pkg/util/krew/sha256.go - About 40 mins to fix

                                Function CmdAlias has 6 return statements (exceeds 4 allowed).
                                Open

                                func CmdAlias(f cmdutil.Factory) *cobra.Command {
                                    var localFile, remoteAddr string
                                    cmd := &cobra.Command{
                                        Use:   "alias",
                                        Short: i18n.T("Config file alias to execute command simply"),
                                Severity: Major
                                Found in cmd/kubevpn/cmds/alias.go - About 40 mins to fix

                                  Method ConnectOptions.GetIPFromContext has 6 return statements (exceeds 4 allowed).
                                  Open

                                  func (c *ConnectOptions) GetIPFromContext(ctx context.Context) error {
                                      md, ok := metadata.FromIncomingContext(ctx)
                                      if !ok {
                                          return fmt.Errorf("can not get IOP from context")
                                      }
                                  Severity: Major
                                  Found in pkg/handler/connect.go - About 40 mins to fix

                                    Method ConnectOptions.startLocalTunServe has 6 return statements (exceeds 4 allowed).
                                    Open

                                    func (c *ConnectOptions) startLocalTunServe(ctx context.Context, forwardAddress string, lite bool) (err error) {
                                        log.Debugf("IPv4: %s, IPv6: %s", c.localTunIPv4.IP.String(), c.localTunIPv6.IP.String())
                                    
                                        var cidrList []*net.IPNet
                                        if !lite {
                                    Severity: Major
                                    Found in pkg/handler/connect.go - About 40 mins to fix

                                      Function InitFactory has 6 return statements (exceeds 4 allowed).
                                      Open

                                      func InitFactory(kubeconfigBytes string, ns string) cmdutil.Factory {
                                          configFlags := genericclioptions.NewConfigFlags(true).WithDeprecatedPasswordFlag()
                                          configFlags.WrapConfigFn = func(c *rest.Config) *rest.Config {
                                              if path, ok := os.LookupEnv(config.EnvSSHJump); ok {
                                                  bytes, err := os.ReadFile(path)
                                      Severity: Major
                                      Found in pkg/util/ns.go - About 40 mins to fix

                                        Function DownloadFileWithName has 6 return statements (exceeds 4 allowed).
                                        Open

                                        func DownloadFileWithName(uri, name string) (string, error) {
                                            resp, err := getWithRetry(uri)
                                            if err != nil {
                                                return "", err
                                            }
                                        Severity: Major
                                        Found in pkg/util/file.go - About 40 mins to fix
                                          Severity
                                          Category
                                          Status
                                          Source
                                          Language