[MISC] Address errors from linter updates (#1308)

pull/1307/head
Amir Zarrinkafsh 2020-09-04 13:20:17 +10:00 committed by GitHub
parent 9d7f64c834
commit 3c861922a6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 10 additions and 10 deletions

View File

@ -24,7 +24,7 @@ import (
var configPathFlag string
//nolint:gocyclo // TODO: Consider refactoring/simplifying, time permitting
//nolint:gocyclo // TODO: Consider refactoring/simplifying, time permitting.
func startServer() {
config, errs := configuration.Read(configPathFlag)

View File

@ -49,7 +49,7 @@ func (p *LDAPUserProvider) connect(userDN string, password string) (LDAPConnecti
logging.Logger().Trace("LDAP client starts a TLS session")
conn, err := p.connectionFactory.DialTLS("tcp", url.Host, &tls.Config{
InsecureSkipVerify: p.configuration.SkipVerify, //nolint:gosec // This is a configurable option, is desirable in some situations and is off by default
InsecureSkipVerify: p.configuration.SkipVerify, //nolint:gosec // This is a configurable option, is desirable in some situations and is off by default.
})
if err != nil {
return nil, err

View File

@ -63,7 +63,7 @@ func publicKey(priv interface{}) interface{} {
}
}
//nolint:gocyclo // TODO: Consider refactoring/simplifying, time permitting
//nolint:gocyclo // TODO: Consider refactoring/simplifying, time permitting.
func generateSelfSignedCertificate(cmd *cobra.Command, args []string) {
// implementation retrieved from https://golang.org/src/crypto/tls/generate_cert.go
var priv interface{}

View File

@ -10,7 +10,7 @@ import (
"github.com/authelia/authelia/internal/utils"
)
//nolint:gocyclo // TODO: Consider refactoring/simplifying, time permitting
//nolint:gocyclo // TODO: Consider refactoring/simplifying, time permitting.
func validateFileAuthenticationBackend(configuration *schema.FileAuthenticationBackendConfiguration, validator *schema.StructValidator) {
if configuration.Path == "" {
validator.Push(errors.New("Please provide a `path` for the users database in `authentication_backend`"))
@ -98,7 +98,7 @@ func validateLdapURL(ldapURL string, validator *schema.StructValidator) string {
return u.String()
}
//nolint:gocyclo // TODO: Consider refactoring/simplifying, time permitting
//nolint:gocyclo // TODO: Consider refactoring/simplifying, time permitting.
func validateLdapAuthenticationBackend(configuration *schema.LDAPAuthenticationBackendConfiguration, validator *schema.StructValidator) {
if configuration.URL == "" {
validator.Push(errors.New("Please provide a URL to the LDAP server"))

View File

@ -11,7 +11,7 @@ var defaultPort = 8080
var defaultLogLevel = "info"
// ValidateConfiguration and adapt the configuration read from file.
//nolint:gocyclo // This function is likely to always have lots of if/else statements, as long as we keep the flow clean it should be understandable
//nolint:gocyclo // This function is likely to always have lots of if/else statements, as long as we keep the flow clean it should be understandable.
func ValidateConfiguration(configuration *schema.Configuration, validator *schema.StructValidator) {
if configuration.Host == "" {
configuration.Host = "0.0.0.0"

View File

@ -33,7 +33,7 @@ func TestShouldNotValidateBadKeys(t *testing.T) {
}
func TestAllSpecificErrorKeys(t *testing.T) {
var configKeys []string //nolint:prealloc // This is because the test is dynamic based on the keys that exist in the map
var configKeys []string //nolint:prealloc // This is because the test is dynamic based on the keys that exist in the map.
var uniqueValues []string

View File

@ -31,7 +31,7 @@ func movingAverageIteration(value time.Duration, successful bool, movingAverageC
}
func calculateActualDelay(ctx *middlewares.AutheliaCtx, execDuration time.Duration, avgExecDurationMs float64, successful *bool) float64 {
randomDelayMs := float64(rand.Int63n(msMaximumRandomDelay))
randomDelayMs := float64(rand.Int63n(msMaximumRandomDelay)) //nolint:gosec // TODO: Consider use of crypto/rand, this should be benchmarked and measured first.
totalDelayMs := math.Max(avgExecDurationMs, msMinimumDelay1FA) + randomDelayMs
actualDelayMs := math.Max(totalDelayMs-float64(execDuration.Milliseconds()), 1.0)
ctx.Logger.Tracef("attempt successful: %t, exec duration: %d, avg execution duration: %d, random delay ms: %d, total delay ms: %d, actual delay ms: %d", *successful, execDuration.Milliseconds(), int64(avgExecDurationMs), int64(randomDelayMs), int64(totalDelayMs), int64(actualDelayMs))

View File

@ -6,6 +6,6 @@ var (
// ErrNoU2FDeviceHandle error thrown when no U2F device handle has been found in DB.
ErrNoU2FDeviceHandle = errors.New("No U2F device handle found")
// ErrNoTOTPSecret error thrown when no TOTP secret has been found in DB
// ErrNoTOTPSecret error thrown when no TOTP secret has been found in DB.
ErrNoTOTPSecret = errors.New("No TOTP secret registered")
)

View File

@ -86,7 +86,7 @@ func RandomString(n int, characters []rune) (randomString string) {
b := make([]rune, n)
for i := range b {
b[i] = characters[rand.Intn(len(characters))]
b[i] = characters[rand.Intn(len(characters))] //nolint:gosec // Likely isn't necessary to use the more expensive crypto/rand for this utility func.
}
return string(b)