oauth2-proxy/oauth2-proxy

View on GitHub

Showing 40 of 54 total issues

File oauthproxy.go has 992 lines of code (exceeds 500 allowed). Consider refactoring.
Open

package main

import (
    "context"
    "embed"
Severity: Major
Found in oauthproxy.go - About 1 day to fix

    File legacy_options.go has 665 lines of code (exceeds 500 allowed). Consider refactoring.
    Open

    package options
    
    import (
        "fmt"
        "net/url"
    Severity: Minor
    Found in pkg/apis/options/legacy_options.go - About 5 hrs to fix

      OAuthProxy has 30 methods (exceeds 20 allowed). Consider refactoring.
      Open

      type OAuthProxy struct {
          CookieOptions *options.Cookie
          Validator     func(string) bool
      
          SignInPath string
      Severity: Minor
      Found in oauthproxy.go - About 3 hrs to fix

        Function NewOAuthProxy has 116 lines of code (exceeds 50 allowed). Consider refactoring.
        Open

        func NewOAuthProxy(opts *options.Options, validator func(string) bool) (*OAuthProxy, error) {
            sessionStore, err := sessions.NewSessionStore(&opts.Session, &opts.Cookie)
            if err != nil {
                return nil, fmt.Errorf("error initialising session store: %v", err)
            }
        Severity: Major
        Found in oauthproxy.go - About 3 hrs to fix

          Method LegacyProvider.convert has 109 lines of code (exceeds 50 allowed). Consider refactoring.
          Open

          func (l *LegacyProvider) convert() (Providers, error) {
              providers := Providers{}
          
              provider := Provider{
                  ClientID:                 l.ClientID,
          Severity: Major
          Found in pkg/apis/options/legacy_options.go - About 3 hrs to fix

            Method BitbucketProvider.GetEmailAddress has 83 lines of code (exceeds 50 allowed). Consider refactoring.
            Open

            func (p *BitbucketProvider) GetEmailAddress(ctx context.Context, s *sessions.SessionState) (string, error) {
            
                var emails struct {
                    Values []struct {
                        Email   string `json:"email"`
            Severity: Major
            Found in providers/bitbucket.go - About 2 hrs to fix

              Function newProviderDataFromConfig has 73 lines of code (exceeds 50 allowed). Consider refactoring.
              Open

              func newProviderDataFromConfig(providerConfig options.Provider) (*ProviderData, error) {
                  p := &ProviderData{
                      Scope:            providerConfig.Scope,
                      ClientID:         providerConfig.ClientID,
                      ClientSecret:     providerConfig.ClientSecret,
              Severity: Minor
              Found in providers/providers.go - About 1 hr to fix

                Function Validate has 71 lines of code (exceeds 50 allowed). Consider refactoring.
                Open

                func Validate(o *options.Options) error {
                    msgs := validateCookie(o.Cookie)
                    msgs = append(msgs, validateSessionCookieMinimal(o)...)
                    msgs = append(msgs, validateRedisSessionStore(o)...)
                    msgs = append(msgs, prefixValues("injectRequestHeaders: ", validateHeaders(o.InjectRequestHeaders)...)...)
                Severity: Minor
                Found in pkg/validation/options.go - About 1 hr to fix

                  Method OAuthProxy.OAuthCallback has 70 lines of code (exceeds 50 allowed). Consider refactoring.
                  Open

                  func (p *OAuthProxy) OAuthCallback(rw http.ResponseWriter, req *http.Request) {
                      remoteAddr := ip.GetClientString(p.realClientIPParser, req, true)
                  
                      // finish the oauth cycle
                      err := req.ParseForm()
                  Severity: Minor
                  Found in oauthproxy.go - About 1 hr to fix

                    Method LoginGovProvider.Redeem has 55 lines of code (exceeds 50 allowed). Consider refactoring.
                    Open

                    func (p *LoginGovProvider) Redeem(ctx context.Context, _, code, codeVerifier string) (*sessions.SessionState, error) {
                        if code == "" {
                            return nil, ErrMissingCode
                        }
                    
                    
                    Severity: Minor
                    Found in providers/logingov.go - About 1 hr to fix

                      Function NewOAuthProxy has 12 return statements (exceeds 4 allowed).
                      Open

                      func NewOAuthProxy(opts *options.Options, validator func(string) bool) (*OAuthProxy, error) {
                          sessionStore, err := sessions.NewSessionStore(&opts.Session, &opts.Cookie)
                          if err != nil {
                              return nil, fmt.Errorf("error initialising session store: %v", err)
                          }
                      Severity: Major
                      Found in oauthproxy.go - About 1 hr to fix

                        Function registerFlags has a Cognitive Complexity of 25 (exceeds 20 allowed). Consider refactoring.
                        Open

                        func registerFlags(v *viper.Viper, prefix string, flagSet *pflag.FlagSet, options interface{}) error {
                            val := reflect.ValueOf(options)
                            var typ reflect.Type
                            if val.Kind() == reflect.Ptr {
                                typ = val.Elem().Type()
                        Severity: Minor
                        Found in pkg/apis/options/load.go - About 1 hr to fix

                        Cognitive Complexity

                        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                        A method's cognitive complexity is based on a few simple rules:

                        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                        • Code is considered more complex for each "break in the linear flow of the code"
                        • Code is considered more complex when "flow breaking structures are nested"

                        Further reading

                        Method OAuthProxy.OAuthCallback has 9 return statements (exceeds 4 allowed).
                        Open

                        func (p *OAuthProxy) OAuthCallback(rw http.ResponseWriter, req *http.Request) {
                            remoteAddr := ip.GetClientString(p.realClientIPParser, req, true)
                        
                            // finish the oauth cycle
                            err := req.ParseForm()
                        Severity: Major
                        Found in oauthproxy.go - About 55 mins to fix

                          Method BitbucketProvider.GetEmailAddress has a Cognitive Complexity of 24 (exceeds 20 allowed). Consider refactoring.
                          Open

                          func (p *BitbucketProvider) GetEmailAddress(ctx context.Context, s *sessions.SessionState) (string, error) {
                          
                              var emails struct {
                                  Values []struct {
                                      Email   string `json:"email"`
                          Severity: Minor
                          Found in providers/bitbucket.go - About 55 mins to fix

                          Cognitive Complexity

                          Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                          A method's cognitive complexity is based on a few simple rules:

                          • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                          • Code is considered more complex for each "break in the linear flow of the code"
                          • Code is considered more complex when "flow breaking structures are nested"

                          Further reading

                          Function newClaimInjector has a Cognitive Complexity of 24 (exceeds 20 allowed). Consider refactoring.
                          Open

                          func newClaimInjector(name string, source *options.ClaimSource) (valueInjector, error) {
                              switch {
                              case source.BasicAuthPassword != nil:
                                  password, err := util.GetSecretValue(source.BasicAuthPassword)
                                  if err != nil {
                          Severity: Minor
                          Found in pkg/header/injector.go - About 55 mins to fix

                          Cognitive Complexity

                          Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                          A method's cognitive complexity is based on a few simple rules:

                          • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                          • Code is considered more complex for each "break in the linear flow of the code"
                          • Code is considered more complex when "flow breaking structures are nested"

                          Further reading

                          Method storedSessionLoader.refreshSessionIfNeeded has 8 return statements (exceeds 4 allowed).
                          Open

                          func (s *storedSessionLoader) refreshSessionIfNeeded(rw http.ResponseWriter, req *http.Request, session *sessionsapi.SessionState) error {
                              if !needsRefresh(s.refreshPeriod, session) {
                                  // Refresh is disabled or the session is not old enough, do nothing
                                  return nil
                              }
                          Severity: Major
                          Found in pkg/middleware/stored_session.go - About 50 mins to fix

                            Method BitbucketProvider.GetEmailAddress has 7 return statements (exceeds 4 allowed).
                            Open

                            func (p *BitbucketProvider) GetEmailAddress(ctx context.Context, s *sessions.SessionState) (string, error) {
                            
                                var emails struct {
                                    Values []struct {
                                        Email   string `json:"email"`
                            Severity: Major
                            Found in providers/bitbucket.go - About 45 mins to fix

                              Method Logger.PrintReq has 6 arguments (exceeds 4 allowed). Consider refactoring.
                              Open

                              func (l *Logger) PrintReq(username, upstream string, req *http.Request, url url.URL, ts time.Time, status int, size int) {
                              Severity: Minor
                              Found in pkg/logger/logger.go - About 45 mins to fix

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

                                func PrintReq(username, upstream string, req *http.Request, url url.URL, ts time.Time, status int, size int) {
                                Severity: Minor
                                Found in pkg/logger/logger.go - About 45 mins to fix

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

                                  func MakeCookieFromOptions(req *http.Request, name string, value string, opts *options.Cookie, expiration time.Duration, now time.Time) *http.Cookie {
                                  Severity: Minor
                                  Found in pkg/cookies/cookies.go - About 45 mins to fix
                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language