update golangci-lint to v1.24 on github workflow (#40)

* update golangci-lint to v1.24 on github workflow

* fix lint errors
This commit is contained in:
César Nieto
2020-04-06 16:04:18 -07:00
committed by GitHub
parent 9ca4daa906
commit 775874cf86
7 changed files with 30 additions and 32 deletions

View File

@@ -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 ./...

View File

@@ -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")
@@ -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"
}

View File

@@ -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.
@@ -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 "".
@@ -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.

View File

@@ -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)

View File

@@ -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"

View File

@@ -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"
)

View File

@@ -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