Skip to content

Commit d9fae8e

Browse files
committed
cleanup warnings, mostly from gostaticcheck
1 parent b1e6a81 commit d9fae8e

File tree

25 files changed

+124
-184
lines changed

25 files changed

+124
-184
lines changed

go.mod

Lines changed: 20 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,50 @@
11
module github.com/vouch/vouch-proxy
22

3-
go 1.23
3+
go 1.23.0
4+
5+
toolchain go1.23.2
46

57
require (
8+
github.com/go-viper/mapstructure/v2 v2.4.0
69
github.com/golang-jwt/jwt v3.2.2+incompatible
7-
github.com/google/go-cmp v0.6.0
8-
github.com/gorilla/sessions v1.2.2
10+
github.com/google/go-cmp v0.7.0
11+
github.com/gorilla/sessions v1.4.0
912
github.com/julienschmidt/httprouter v1.3.0
1013
github.com/karupanerura/go-mock-http-response v0.0.0-20171201120521-7c242a447d45
1114
github.com/kelseyhightower/envconfig v1.4.0
12-
github.com/mitchellh/mapstructure v1.5.0
1315
github.com/nirasan/go-oauth-pkce-code-verifier v0.0.0-20220510032225-4f9f17eaec4c
1416
github.com/patrickmn/go-cache v2.1.0+incompatible
15-
github.com/spf13/viper v1.18.2
16-
github.com/stretchr/testify v1.9.0
17+
github.com/spf13/viper v1.20.1
18+
github.com/stretchr/testify v1.10.0
1719
github.com/theckman/go-securerandom v0.1.1
1820
github.com/tsenart/vegeta v12.7.0+incompatible
1921
go.uber.org/zap v1.27.0
20-
golang.org/x/net v0.22.0
21-
golang.org/x/oauth2 v0.18.0
22+
golang.org/x/net v0.42.0
23+
golang.org/x/oauth2 v0.30.0
2224
)
2325

2426
require (
25-
cloud.google.com/go/compute v1.25.1 // indirect
26-
cloud.google.com/go/compute/metadata v0.2.3 // indirect
27+
cloud.google.com/go/compute/metadata v0.7.0 // indirect
2728
github.com/bmizerany/perks v0.0.0-20141205001514-d9a9656a3a4b // indirect
2829
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
2930
github.com/dgryski/go-gk v0.0.0-20200319235926-a69029f61654 // indirect
30-
github.com/fsnotify/fsnotify v1.7.0 // indirect
31-
github.com/golang/protobuf v1.5.4 // indirect
31+
github.com/fsnotify/fsnotify v1.9.0 // indirect
3232
github.com/gorilla/securecookie v1.1.2 // indirect
33-
github.com/hashicorp/hcl v1.0.0 // indirect
3433
github.com/influxdata/tdigest v0.0.1 // indirect
3534
github.com/josharian/intern v1.0.0 // indirect
36-
github.com/magiconair/properties v1.8.7 // indirect
3735
github.com/mailru/easyjson v0.7.7 // indirect
38-
github.com/pelletier/go-toml/v2 v2.2.0 // indirect
36+
github.com/pelletier/go-toml/v2 v2.2.4 // indirect
3937
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
40-
github.com/sagikazarmark/locafero v0.4.0 // indirect
41-
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
38+
github.com/sagikazarmark/locafero v0.9.0 // indirect
4239
github.com/sourcegraph/conc v0.3.0 // indirect
43-
github.com/spf13/afero v1.11.0 // indirect
44-
github.com/spf13/cast v1.6.0 // indirect
45-
github.com/spf13/pflag v1.0.5 // indirect
40+
github.com/spf13/afero v1.14.0 // indirect
41+
github.com/spf13/cast v1.9.2 // indirect
42+
github.com/spf13/pflag v1.0.7 // indirect
4643
github.com/streadway/quantile v0.0.0-20150917103942-b0c588724d25 // indirect
4744
github.com/subosito/gotenv v1.6.0 // indirect
4845
go.uber.org/multierr v1.11.0 // indirect
49-
golang.org/x/exp v0.0.0-20240318143956-a85f2c67cd81 // indirect
50-
golang.org/x/sys v0.18.0 // indirect
51-
golang.org/x/text v0.14.0 // indirect
52-
google.golang.org/appengine v1.6.8 // indirect
53-
google.golang.org/protobuf v1.33.0 // indirect
54-
gopkg.in/ini.v1 v1.67.0 // indirect
46+
golang.org/x/exp v0.0.0-20250718183923-645b1fa84792 // indirect
47+
golang.org/x/sys v0.34.0 // indirect
48+
golang.org/x/text v0.27.0 // indirect
5549
gopkg.in/yaml.v3 v3.0.1 // indirect
5650
)

go.sum

Lines changed: 34 additions & 91 deletions
Large diffs are not rendered by default.

handlers/auth_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ func TestCallbackHandlerDocumentRoot(t *testing.T) {
5050
// grab the state from the session cookie to
5151
session, err := sessstore.Get(reqLogin, cfg.Cfg.Session.Name)
5252
state := session.Values["state"].(string)
53+
if err != nil {
54+
t.Fatal(err)
55+
}
5356

5457
// now mimic an IdP returning the state variable back to us
5558
reqAuth, err := http.NewRequest("GET", cfg.Cfg.DocumentRoot+"/auth?state="+state, nil)

handlers/handlers_test.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import (
1717
"testing"
1818

1919
"github.com/stretchr/testify/assert"
20-
"golang.org/x/oauth2"
2120

2221
"github.com/vouch/vouch-proxy/pkg/cfg"
2322
"github.com/vouch/vouch-proxy/pkg/cookie"
@@ -27,9 +26,9 @@ import (
2726
"github.com/vouch/vouch-proxy/pkg/structs"
2827
)
2928

30-
var (
31-
token = &oauth2.Token{AccessToken: "123"}
32-
)
29+
// var (
30+
// token = &oauth2.Token{AccessToken: "123"}
31+
// )
3332

3433
// setUp load config file and then call Configure() for dependent packages
3534
func setUp(configFile string) {

handlers/login.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import (
2929
)
3030

3131
// see https://github.com/vouch/vouch-proxy/issues/282
32-
var errTooManyRedirects = errors.New("Too many unsuccessful authorization attempts for the requested URL")
32+
var errTooManyRedirects = errors.New("too many unsuccessful authorization attempts for the requested URL")
3333

3434
const failCountLimit = 6
3535

@@ -204,7 +204,7 @@ func getValidRequestedURL(r *http.Request) (string, error) {
204204
}
205205

206206
if err != nil {
207-
return "", fmt.Errorf("Not a valid login URL: %w %s", errInvalidURL, err)
207+
return "", fmt.Errorf("not a valid login URL: %w %s", errInvalidURL, err)
208208
}
209209

210210
if u == nil || u.String() == "" {
@@ -301,10 +301,9 @@ func appendCodeChallenge(session sessions.Session) {
301301
switch strings.ToUpper(cfg.GenOAuth.CodeChallengeMethod) {
302302
case "S256":
303303
codeChallenge = CodeVerifier.CodeChallengeS256()
304-
break
305304
case "PLAIN":
306-
codeChallenge = CodeVerifier.CodeChallengePlain()
307305
// TODO support plain text code challenge
306+
//codeChallenge = CodeVerifier.CodeChallengePlain()
308307
log.Fatal("plain code challenge method is not supported")
309308
return
310309
default:

pkg/capturewriter/capturewriter.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@ import (
2222
// and then pull it out later for logging
2323
// https://play.golang.org/p/wPHaX9DH-Ik
2424

25-
var logger *zap.SugaredLogger
25+
// var logger *zap.SugaredLogger
2626
var log *zap.Logger
2727

2828
// Configure see main.go configure()
2929
func Configure() {
30-
logger = cfg.Logging.Logger
30+
// logger = cfg.Logging.Logger
3131
log = cfg.Logging.FastLogger
3232
}
3333

pkg/cfg/cfg.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ import (
1616
"errors"
1717
"flag"
1818
"fmt"
19+
"io"
1920
"io/fs"
20-
"io/ioutil"
2121
"net/http"
2222
"os"
2323
"os/user"
@@ -26,9 +26,9 @@ import (
2626
"reflect"
2727
"strings"
2828

29+
"github.com/go-viper/mapstructure/v2"
2930
"github.com/golang-jwt/jwt"
3031
"github.com/kelseyhightower/envconfig"
31-
"github.com/go-viper/mapstructure/v2"
3232
"github.com/spf13/viper"
3333
securerandom "github.com/theckman/go-securerandom"
3434
"go.uber.org/zap"
@@ -633,7 +633,7 @@ func DecryptionKey() (interface{}, error) {
633633
return nil, fmt.Errorf("error opening Key %s: %s", Cfg.JWT.PublicKeyFile, err)
634634
}
635635

636-
keyBytes, err := ioutil.ReadAll(f)
636+
keyBytes, err := io.ReadAll(f)
637637
if err != nil {
638638
return nil, fmt.Errorf("error reading Key: %s", err)
639639
}
@@ -666,7 +666,7 @@ func SigningKey() (interface{}, error) {
666666
return nil, fmt.Errorf("error opening RSA Key %s: %s", Cfg.JWT.PrivateKeyFile, err)
667667
}
668668

669-
keyBytes, err := ioutil.ReadAll(f)
669+
keyBytes, err := io.ReadAll(f)
670670
if err != nil {
671671
return nil, fmt.Errorf("error reading Key: %s", err)
672672
}

pkg/cfg/jwt.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ OR CONDITIONS OF ANY KIND, either express or implied.
1111
package cfg
1212

1313
import (
14-
"io/ioutil"
14+
"os"
1515

1616
securerandom "github.com/theckman/go-securerandom"
1717
)
1818

1919
func getOrGenerateJWTSecret() string {
20-
b, err := ioutil.ReadFile(secretFile)
20+
b, err := os.ReadFile(secretFile)
2121
if err == nil {
2222
log.Info("jwt.secret read from " + secretFile)
2323
} else {
@@ -33,7 +33,7 @@ func getOrGenerateJWTSecret() string {
3333
log.Fatal(err)
3434
}
3535
b = []byte(rstr)
36-
err = ioutil.WriteFile(secretFile, b, 0600)
36+
err = os.WriteFile(secretFile, b, 0600)
3737
if err != nil {
3838
log.Error(err)
3939
logSysInfo()

pkg/cfg/logging.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ OR CONDITIONS OF ANY KIND, either express or implied.
1111
package cfg
1212

1313
import (
14-
"fmt"
1514
"os"
1615
"strconv"
1716

@@ -106,7 +105,7 @@ func (logging) configure() {
106105
// then we weren't configured via command line, check the config file
107106
if !viper.IsSet(Branding.LCName + ".logLevel") {
108107
// then we weren't configured via the config file, set the default
109-
Cfg.LogLevel = fmt.Sprintf("%s", Logging.DefaultLogLevel)
108+
Cfg.LogLevel = Logging.DefaultLogLevel.String()
110109
}
111110

112111
if Cfg.LogLevel != Logging.AtomicLogLevel.Level().String() {

pkg/cookie/cookie.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ func SameSite() http.SameSite {
186186
case "strict":
187187
sameSite = http.SameSiteStrictMode
188188
case "none":
189-
if cfg.Cfg.Cookie.Secure == false {
189+
if !cfg.Cfg.Cookie.Secure {
190190
log.Error("SameSite cookie attribute with sameSite=none should also be specified with secure=true.")
191191
}
192192
sameSite = http.SameSiteNoneMode

0 commit comments

Comments
 (0)