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:
@@ -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.
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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"
|
||||
)
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user