Skip to content

chore: fix gosec warnings via ignore annotations in comments #1770

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion internal/api/verify.go
Original file line number Diff line number Diff line change
Expand Up @@ -718,7 +718,7 @@ func isOtpValid(actual, expected string, sentAt *time.Time, otpExp uint) bool {
}

func isOtpExpired(sentAt *time.Time, otpExp uint) bool {
return time.Now().After(sentAt.Add(time.Second * time.Duration(otpExp)))
return time.Now().After(sentAt.Add(time.Second * time.Duration(otpExp))) // #nosec G115
}

// isPhoneOtpVerification checks if the verification came from a phone otp
Expand Down
4 changes: 2 additions & 2 deletions internal/crypto/crypto.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ func (es *EncryptedString) Decrypt(id string, decryptionKeys map[string]string)
return nil, err
}

decrypted, err := cipher.Open(nil, es.Nonce, es.Data, nil)
decrypted, err := cipher.Open(nil, es.Nonce, es.Data, nil) // #nosec G407
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -203,7 +203,7 @@ func NewEncryptedString(id string, data []byte, keyID string, keyBase64URL strin
panic(err)
}

es.Data = cipher.Seal(nil, es.Nonce, data, nil)
es.Data = cipher.Seal(nil, es.Nonce, data, nil) // #nosec G407

return &es, nil
}
6 changes: 3 additions & 3 deletions internal/crypto/password.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ func compareHashAndPasswordArgon2(ctx context.Context, hash, password string) er
attribute.Int64("t", int64(input.time)),
attribute.Int("p", int(input.threads)),
attribute.Int("len", len(input.rawHash)),
}
} // #nosec G115

var match bool
var derivedKey []byte
Expand All @@ -157,10 +157,10 @@ func compareHashAndPasswordArgon2(ctx context.Context, hash, password string) er

switch input.alg {
case "argon2i":
derivedKey = argon2.Key([]byte(password), input.salt, uint32(input.time), uint32(input.memory)*1024, uint8(input.threads), uint32(len(input.rawHash)))
derivedKey = argon2.Key([]byte(password), input.salt, uint32(input.time), uint32(input.memory)*1024, uint8(input.threads), uint32(len(input.rawHash))) // #nosec G115

case "argon2id":
derivedKey = argon2.IDKey([]byte(password), input.salt, uint32(input.time), uint32(input.memory)*1024, uint8(input.threads), uint32(len(input.rawHash)))
derivedKey = argon2.IDKey([]byte(password), input.salt, uint32(input.time), uint32(input.memory)*1024, uint8(input.threads), uint32(len(input.rawHash))) // #nosec G115
}

match = subtle.ConstantTimeCompare(derivedKey, input.rawHash) == 0
Expand Down
4 changes: 2 additions & 2 deletions internal/models/audit_log_entry.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,8 @@ func FindAuditLogEntries(tx *storage.Connection, filterColumns []string, filterV
logs := []*AuditLogEntry{}
var err error
if pageParams != nil {
err = q.Paginate(int(pageParams.Page), int(pageParams.PerPage)).All(&logs)
pageParams.Count = uint64(q.Paginator.TotalEntriesSize)
err = q.Paginate(int(pageParams.Page), int(pageParams.PerPage)).All(&logs) // #nosec G115
pageParams.Count = uint64(q.Paginator.TotalEntriesSize) // #nosec G115
} else {
err = q.All(&logs)
}
Expand Down
5 changes: 3 additions & 2 deletions internal/models/cleanup.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ package models
import (
"context"
"fmt"
"sync/atomic"

"github.com/sirupsen/logrus"
"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/metric"
"sync/atomic"

"go.opentelemetry.io/otel/attribute"

Expand Down Expand Up @@ -111,7 +112,7 @@ func (c *Cleanup) Clean(db *storage.Connection) (int, error) {
defer span.SetAttributes(attribute.Int64("gotrue.cleanup.affected_rows", int64(affectedRows)))

if err := db.WithContext(ctx).Transaction(func(tx *storage.Connection) error {
nextIndex := atomic.AddUint32(&c.cleanupNext, 1) % uint32(len(c.cleanupStatements))
nextIndex := atomic.AddUint32(&c.cleanupNext, 1) % uint32(len(c.cleanupStatements)) // #nosec G115
statement := c.cleanupStatements[nextIndex]

count, terr := tx.RawQuery(statement).ExecWithCount()
Expand Down
4 changes: 2 additions & 2 deletions internal/models/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -683,8 +683,8 @@ func FindUsersInAudience(tx *storage.Connection, aud string, pageParams *Paginat

var err error
if pageParams != nil {
err = q.Paginate(int(pageParams.Page), int(pageParams.PerPage)).All(&users)
pageParams.Count = uint64(q.Paginator.TotalEntriesSize)
err = q.Paginate(int(pageParams.Page), int(pageParams.PerPage)).All(&users) // #nosec G115
pageParams.Count = uint64(q.Paginator.TotalEntriesSize) // #nosec G115
} else {
err = q.All(&users)
}
Expand Down
Loading