oauth2-proxy/oauth2-proxy

View on GitHub

Showing 40 of 54 total issues

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 Validate has a Cognitive Complexity of 23 (exceeds 20 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 45 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 registerFlags has 7 return statements (exceeds 4 allowed).
    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: Major
    Found in pkg/apis/options/load.go - About 45 mins to fix

      Method ProviderData.buildSessionFromClaims has 6 return statements (exceeds 4 allowed).
      Open

      func (p *ProviderData) buildSessionFromClaims(rawIDToken, accessToken string) (*sessions.SessionState, error) {
          ss := &sessions.SessionState{}
      
          if rawIDToken == "" {
              return ss, nil
      Severity: Major
      Found in providers/provider_data.go - About 40 mins to fix

        Method LoginGovProvider.Redeem has 6 return statements (exceeds 4 allowed).
        Open

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

          Method server.setupTLSListener has 6 return statements (exceeds 4 allowed).
          Open

          func (s *server) setupTLSListener(opts Opts) error {
              if opts.SecureBindAddress == "" || opts.SecureBindAddress == "-" {
                  // No HTTPS listener required
                  return nil
              }
          Severity: Major
          Found in pkg/http/server.go - About 40 mins to fix

            Method OAuthProxy.ErrorPage has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

            func (p *OAuthProxy) ErrorPage(rw http.ResponseWriter, req *http.Request, code int, appError string, messages ...interface{}) {
            Severity: Minor
            Found in oauthproxy.go - About 35 mins to fix

              Function PrintAuthf has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

              func PrintAuthf(username string, req *http.Request, status AuthStatus, format string, a ...interface{}) {
              Severity: Minor
              Found in pkg/logger/logger.go - About 35 mins to fix

                Method SessionStore.makeCookie has 5 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                func (s *SessionStore) makeCookie(req *http.Request, name string, value string, expiration time.Duration, now time.Time) *http.Cookie {
                Severity: Minor
                Found in pkg/sessions/cookie/session_store.go - About 35 mins to fix

                  Method Logger.PrintAuthf has 5 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                  func (l *Logger) PrintAuthf(username string, req *http.Request, status AuthStatus, format string, a ...interface{}) {
                  Severity: Minor
                  Found in pkg/logger/logger.go - About 35 mins to fix

                    Method OAuthProxy.doOAuthStart has 5 return statements (exceeds 4 allowed).
                    Open

                    func (p *OAuthProxy) doOAuthStart(rw http.ResponseWriter, req *http.Request, overrides url.Values) {
                        extraParams := p.provider.Data().LoginURLParams(overrides)
                        prepareNoCache(rw)
                    
                        var (
                    Severity: Major
                    Found in oauthproxy.go - About 35 mins to fix

                      Method server.startServer has 5 return statements (exceeds 4 allowed).
                      Open

                      func (s *server) startServer(ctx context.Context, listener net.Listener) error {
                          srv := &http.Server{Handler: s.handler, ReadHeaderTimeout: time.Minute}
                          g, groupCtx := errgroup.WithContext(ctx)
                      
                          g.Go(func() error {
                      Severity: Major
                      Found in pkg/http/server.go - About 35 mins to fix

                        Function checkNonce has 5 return statements (exceeds 4 allowed).
                        Open

                        func checkNonce(idToken string, p *LoginGovProvider) (err error) {
                            token, err := jwt.ParseWithClaims(idToken, &loginGovCustomClaims{}, func(_ *jwt.Token) (interface{}, error) {
                                var pubkeys jose.JSONWebKeySet
                                rerr := requests.New(p.PubJWKURL.String()).Do().UnmarshalInto(&pubkeys)
                                if rerr != nil {
                        Severity: Major
                        Found in providers/logingov.go - About 35 mins to fix

                          Function NewProxy has 5 return statements (exceeds 4 allowed).
                          Open

                          func NewProxy(upstreams options.UpstreamConfig, sigData *options.SignatureData, writer pagewriter.Writer) (http.Handler, error) {
                              m := &multiUpstreamProxy{
                                  serveMux: mux.NewRouter(),
                              }
                          
                          
                          Severity: Major
                          Found in pkg/upstream/proxy.go - About 35 mins to fix

                            Function claimsFromIDToken has 5 return statements (exceeds 4 allowed).
                            Open

                            func claimsFromIDToken(idToken string) (*claims, error) {
                            
                                // id_token is a base64 encode ID token payload
                                // https://developers.google.com/accounts/docs/OAuth2Login#obtainuserinfo
                                jwt := strings.Split(idToken, ".")
                            Severity: Major
                            Found in providers/google.go - About 35 mins to fix

                              Method claimExtractor.GetClaim has 5 return statements (exceeds 4 allowed).
                              Open

                              func (c *claimExtractor) GetClaim(claim string) (interface{}, bool, error) {
                                  if claim == "" {
                                      return nil, false, nil
                                  }
                              
                              
                              Severity: Major
                              Found in pkg/providers/util/claim_extractor.go - About 35 mins to fix

                                Method server.Start has 5 return statements (exceeds 4 allowed).
                                Open

                                func (s *server) Start(ctx context.Context) error {
                                    g, groupCtx := errgroup.WithContext(ctx)
                                
                                    if s.listener != nil {
                                        g.Go(func() error {
                                Severity: Major
                                Found in pkg/http/server.go - About 35 mins to fix

                                  Method LoginGovProvider.configure has 5 return statements (exceeds 4 allowed).
                                  Open

                                  func (p *LoginGovProvider) configure(opts options.LoginGovOptions) error {
                                      pubJWKURL, err := url.Parse(opts.PubJWKURL)
                                      if err != nil {
                                          return fmt.Errorf("could not parse Public JWK URL: %v", err)
                                      }
                                  Severity: Major
                                  Found in providers/logingov.go - About 35 mins to fix

                                    Function NewOAuthProxy has a Cognitive Complexity of 22 (exceeds 20 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: Minor
                                    Found in oauthproxy.go - About 35 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 GoogleProvider.Redeem has 5 return statements (exceeds 4 allowed).
                                    Open

                                    func (p *GoogleProvider) Redeem(ctx context.Context, redirectURL, code, codeVerifier string) (*sessions.SessionState, error) {
                                        if code == "" {
                                            return nil, ErrMissingCode
                                        }
                                        clientSecret, err := p.GetClientSecret()
                                    Severity: Major
                                    Found in providers/google.go - About 35 mins to fix
                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language