Skip to content

Commit

Permalink
update golangci-lint to v1.24 on github workflow (#40)
Browse files Browse the repository at this point in the history
* update golangci-lint to v1.24 on github workflow

* fix lint errors
  • Loading branch information
cesnietor committed Apr 6, 2020
1 parent 9ca4daa commit 775874c
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 32 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/go.yml
Expand Up @@ -31,7 +31,7 @@ jobs:
GO111MODULE: on
GOOS: linux
run: |
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.21.0
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.24.0
$(go env GOPATH)/bin/golangci-lint run --timeout=5m --config ./.golangci.yml
go mod vendor
go test -v -race ./...
Expand Down
4 changes: 2 additions & 2 deletions cmd/mcs/server.go
Expand Up @@ -104,7 +104,7 @@ func startServer(ctx *cli.Context) error {
server.Port = ctx.Int("port")

restapi.Hostname = ctx.String("host")
restapi.Port = fmt.Sprintf("%v",ctx.Int("port"))
restapi.Port = fmt.Sprintf("%v", ctx.Int("port"))

tlsCertificatePath := ctx.String("tls-certificate")
tlsCertificateKeyPath := ctx.String("tls-key")
Expand All @@ -118,7 +118,7 @@ func startServer(ctx *cli.Context) error {
server.TLSPort = ctx.Int("tls-port")
server.TLSHost = ctx.String("tls-host")
// Need to store tls-port, tls-host un config variables so secure.middleware can read from there
restapi.TLSPort = fmt.Sprintf("%v",ctx.Int("tls-port"))
restapi.TLSPort = fmt.Sprintf("%v", ctx.Int("tls-port"))
restapi.TLSHostname = ctx.String("tls-host")
restapi.TLSRedirect = "on"
}
Expand Down
10 changes: 4 additions & 6 deletions restapi/config.go
Expand Up @@ -99,9 +99,8 @@ func getSecureAllowedHosts() []string {
allowedHosts := env.Get(McsSecureAllowedHosts, "")
if allowedHosts != "" {
return strings.Split(allowedHosts, ",")
} else {
return []string{}
}
return []string{}
}

// AllowedHostsAreRegex determines, if the provided AllowedHosts slice contains valid regular expressions. Default is false.
Expand All @@ -120,8 +119,8 @@ func getSecureContentTypeNonSniff() bool {
}

// If BrowserXssFilter is true, adds the X-XSS-Protection header with the value `1; mode=block`. Default is true.
func getSecureBrowserXssFilter() bool {
return strings.ToLower(env.Get(McsSecureBrowserXssFilter, "on")) == "on"
func getSecureBrowserXSSFilter() bool {
return strings.ToLower(env.Get(McsSecureBrowserXSSFilter, "on")) == "on"
}

// ContentSecurityPolicy allows the Content-Security-Policy header value to be set with a custom value. Default is "".
Expand All @@ -141,9 +140,8 @@ func getSecureHostsProxyHeaders() []string {
allowedHosts := env.Get(McsSecureHostsProxyHeaders, "")
if allowedHosts != "" {
return strings.Split(allowedHosts, ",")
} else {
return []string{}
}
return []string{}
}

// If SSLRedirect is set to true, then only allow HTTPS requests. Default is true.
Expand Down
40 changes: 20 additions & 20 deletions restapi/configure_mcs.go
Expand Up @@ -126,27 +126,27 @@ func setupGlobalMiddleware(handler http.Handler) http.Handler {
// Secure middleware, this middleware wrap all the previous handlers and add
// HTTP security headers
secureOptions := secure.Options{
AllowedHosts: getSecureAllowedHosts(),
AllowedHostsAreRegex: getSecureAllowedHostsAreRegex(),
HostsProxyHeaders: getSecureHostsProxyHeaders(),
SSLRedirect: getSSLRedirect(),
SSLHost: getSecureSSLHost(),
STSSeconds: getSecureSTSSeconds(),
STSIncludeSubdomains: getSecureSTSIncludeSubdomains(),
STSPreload: getSecureSTSPreload(),
SSLTemporaryRedirect: getSecureSSLTemporaryRedirect(),
SSLHostFunc: nil,
ForceSTSHeader: getSecureForceSTSHeader(),
FrameDeny: getSecureFrameDeny(),
ContentTypeNosniff: getSecureContentTypeNonSniff(),
BrowserXssFilter: getSecureBrowserXssFilter(),
ContentSecurityPolicy: getSecureContentSecurityPolicy(),
AllowedHosts: getSecureAllowedHosts(),
AllowedHostsAreRegex: getSecureAllowedHostsAreRegex(),
HostsProxyHeaders: getSecureHostsProxyHeaders(),
SSLRedirect: getSSLRedirect(),
SSLHost: getSecureSSLHost(),
STSSeconds: getSecureSTSSeconds(),
STSIncludeSubdomains: getSecureSTSIncludeSubdomains(),
STSPreload: getSecureSTSPreload(),
SSLTemporaryRedirect: getSecureSSLTemporaryRedirect(),
SSLHostFunc: nil,
ForceSTSHeader: getSecureForceSTSHeader(),
FrameDeny: getSecureFrameDeny(),
ContentTypeNosniff: getSecureContentTypeNonSniff(),
BrowserXssFilter: getSecureBrowserXSSFilter(),
ContentSecurityPolicy: getSecureContentSecurityPolicy(),
ContentSecurityPolicyReportOnly: getSecureContentSecurityPolicyReportOnly(),
PublicKey: getSecurePublicKey(),
ReferrerPolicy: getSecureReferrerPolicy(),
FeaturePolicy: getSecureFeaturePolicy(),
ExpectCTHeader: getSecureExpectCTHeader(),
IsDevelopment: !getProductionMode(),
PublicKey: getSecurePublicKey(),
ReferrerPolicy: getSecureReferrerPolicy(),
FeaturePolicy: getSecureFeaturePolicy(),
ExpectCTHeader: getSecureExpectCTHeader(),
IsDevelopment: !getProductionMode(),
}
secureMiddleware := secure.New(secureOptions)
app := secureMiddleware.Handler(next)
Expand Down
2 changes: 1 addition & 1 deletion restapi/consts.go
Expand Up @@ -31,7 +31,7 @@ const (
McsSecureAllowedHostsAreRegex = "MCS_SECURE_ALLOWED_HOSTS_ARE_REGEX"
McsSecureFrameDeny = "MCS_SECURE_FRAME_DENY"
McsSecureContentTypeNoSniff = "MCS_SECURE_CONTENT_TYPE_NO_SNIFF"
McsSecureBrowserXssFilter = "MCS_SECURE_BROWSER_XSS_FILTER"
McsSecureBrowserXSSFilter = "MCS_SECURE_BROWSER_XSS_FILTER"
McsSecureContentSecurityPolicy = "MCS_SECURE_CONTENT_SECURITY_POLICY"
McsSecureContentSecurityPolicyReportOnly = "MCS_SECURE_CONTENT_SECURITY_POLICY_REPORT_ONLY"
McsSecureHostsProxyHeaders = "MCS_SECURE_HOSTS_PROXY_HEADERS"
Expand Down
2 changes: 1 addition & 1 deletion restapi/user_buckets_events_test.go
Expand Up @@ -23,8 +23,8 @@ import (
"errors"

"github.com/go-openapi/swag"
"github.com/minio/mcs/models"
"github.com/minio/mc/pkg/probe"
"github.com/minio/mcs/models"
"github.com/minio/minio-go/v6"
"github.com/stretchr/testify/assert"
)
Expand Down
2 changes: 1 addition & 1 deletion restapi/user_login.go
Expand Up @@ -26,10 +26,10 @@ import (

"github.com/go-openapi/runtime/middleware"
"github.com/go-openapi/swag"
mcCmd "github.com/minio/mc/cmd"
"github.com/minio/mcs/models"
"github.com/minio/mcs/restapi/operations"
"github.com/minio/mcs/restapi/operations/user_api"
mcCmd "github.com/minio/mc/cmd"
)

// Wraps the code at mc/cmd
Expand Down

0 comments on commit 775874c

Please sign in to comment.