Skip to content

Commit

Permalink
[MISC] Address errors from linter updates (#1308)
Browse files Browse the repository at this point in the history
  • Loading branch information
nightah committed Sep 4, 2020
1 parent 9d7f64c commit 3c86192
Show file tree
Hide file tree
Showing 9 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion cmd/authelia/main.go
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion internal/authentication/ldap_user_provider.go
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion internal/commands/certificates.go
Expand Up @@ -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{}
Expand Down
4 changes: 2 additions & 2 deletions internal/configuration/validator/authentication.go
Expand Up @@ -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`"))
Expand Down Expand Up @@ -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"))
Expand Down
2 changes: 1 addition & 1 deletion internal/configuration/validator/configuration.go
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion internal/configuration/validator/keys_test.go
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion internal/handlers/handler_firstfactor.go
Expand Up @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion internal/storage/errors.go
Expand Up @@ -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")
)
2 changes: 1 addition & 1 deletion internal/utils/strings.go
Expand Up @@ -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)
Expand Down

0 comments on commit 3c86192

Please sign in to comment.