Skip to content

Commit

Permalink
chore: synchronize workspaces
Browse files Browse the repository at this point in the history
  • Loading branch information
aeneasr committed Nov 6, 2024
1 parent 3a3961a commit dfdc9bb
Show file tree
Hide file tree
Showing 11 changed files with 24 additions and 11 deletions.
2 changes: 2 additions & 0 deletions cmd/clidoc/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,8 @@ func validateAllMessages(path string) error {
info := &types.Info{
Defs: make(map[*ast.Ident]types.Object),
}

//nolint:staticcheck
var pack *ast.Package
for _, p := range packs {
if p.Name == "text" {
Expand Down
1 change: 1 addition & 0 deletions cmd/hashers/argon2/calibrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ Please note that the values depend on the machine you run the hashing on. If you
case res.MaxMem > conf.localConfig.DedicatedMemory:
_, _ = progressPrinter.Printf("The required memory was %s more than the maximum allowed of %s.\n", res.MaxMem-maxMemory, conf.localConfig.DedicatedMemory)

//nolint:gosec // disable G115
conf.localConfig.Memory -= (res.MaxMem - conf.localConfig.DedicatedMemory) / bytesize.ByteSize(reqPerMin)
_, _ = progressPrinter.Printf("Decreasing memory to %s\n", conf.localConfig.Memory)
// too slow
Expand Down
1 change: 1 addition & 0 deletions courier/courier_dispatcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ func (c *courier) DispatchQueue(ctx context.Context) error {
maxRetries := c.deps.CourierConfig().CourierMessageRetries(ctx)
pullCount := c.deps.CourierConfig().CourierWorkerPullCount(ctx)

//nolint:gosec // disable G115
messages, err := c.deps.CourierPersister().NextMessages(ctx, uint8(pullCount))
if err != nil {
if errors.Is(err, ErrQueueEmpty) {
Expand Down
12 changes: 8 additions & 4 deletions driver/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -550,10 +550,14 @@ func (p *Config) HasherArgon2(ctx context.Context) *Argon2 {
// warn about usage of default values and point to the docs
// warning will require https://github.com/ory/viper/issues/19
return &Argon2{
Memory: p.GetProvider(ctx).ByteSizeF(ViperKeyHasherArgon2ConfigMemory, Argon2DefaultMemory),
Iterations: uint32(p.GetProvider(ctx).IntF(ViperKeyHasherArgon2ConfigIterations, int(Argon2DefaultIterations))),
Parallelism: uint8(p.GetProvider(ctx).IntF(ViperKeyHasherArgon2ConfigParallelism, int(Argon2DefaultParallelism))),
SaltLength: uint32(p.GetProvider(ctx).IntF(ViperKeyHasherArgon2ConfigSaltLength, int(Argon2DefaultSaltLength))),
Memory: p.GetProvider(ctx).ByteSizeF(ViperKeyHasherArgon2ConfigMemory, Argon2DefaultMemory),
//nolint:gosec // disable G115
Iterations: uint32(p.GetProvider(ctx).IntF(ViperKeyHasherArgon2ConfigIterations, int(Argon2DefaultIterations))),
//nolint:gosec // disable G115
Parallelism: uint8(p.GetProvider(ctx).IntF(ViperKeyHasherArgon2ConfigParallelism, int(Argon2DefaultParallelism))),
//nolint:gosec // disable G115
SaltLength: uint32(p.GetProvider(ctx).IntF(ViperKeyHasherArgon2ConfigSaltLength, int(Argon2DefaultSaltLength))),
//nolint:gosec // disable G115
KeyLength: uint32(p.GetProvider(ctx).IntF(ViperKeyHasherArgon2ConfigKeyLength, int(Argon2DefaultKeyLength))),
ExpectedDuration: p.GetProvider(ctx).DurationF(ViperKeyHasherArgon2ConfigExpectedDuration, Argon2DefaultDuration),
ExpectedDeviation: p.GetProvider(ctx).DurationF(ViperKeyHasherArgon2ConfigExpectedDeviation, Argon2DefaultDeviation),
Expand Down
3 changes: 2 additions & 1 deletion hash/hash_comparator.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (

//nolint:staticcheck
//lint:ignore SA1019 compatibility for imported passwords
"golang.org/x/crypto/md4" //#nosec G501 -- compatibility for imported passwords
"golang.org/x/crypto/md4" //nolint:gosec // disable G115 G501 -- compatibility for imported passwords
"golang.org/x/crypto/pbkdf2"
"golang.org/x/crypto/scrypt"

Expand Down Expand Up @@ -159,6 +159,7 @@ func CompareArgon2id(_ context.Context, password []byte, hash []byte) error {
}

// Derive the key from the other password using the same parameters.
//nolint:gosec // disable G115
otherHash := argon2.IDKey(password, salt, p.Iterations, uint32(p.Memory), p.Parallelism, p.KeyLength)

return comparePasswordHashConstantTime(hash, otherHash)
Expand Down
1 change: 1 addition & 0 deletions hash/hasher_argon2.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ func NewHasherArgon2(c Argon2Configuration) *Argon2 {
}

func toKB(mem bytesize.ByteSize) uint32 {
//nolint:gosec // disable G115
return uint32(mem / bytesize.KB)
}

Expand Down
2 changes: 1 addition & 1 deletion identity/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ func (e *CreateIdentitiesError) Find(ident *Identity) *FailedIdentity {
return nil
}
func (e *CreateIdentitiesError) ErrOrNil() error {
if e.failedIdentities == nil || len(e.failedIdentities) == 0 {
if len(e.failedIdentities) == 0 {
return nil
}
return e
Expand Down
6 changes: 3 additions & 3 deletions persistence/sql/identity/persister_identity.go
Original file line number Diff line number Diff line change
Expand Up @@ -932,7 +932,7 @@ func (p *IdentityPersister) ListIdentities(ctx context.Context, params identity.
)
}

if params.IdsFilter != nil && len(params.IdsFilter) != 0 {
if len(params.IdsFilter) > 0 {
wheres += `
AND identities.id in (?)
`
Expand Down Expand Up @@ -987,15 +987,15 @@ func (p *IdentityPersister) ListIdentities(ctx context.Context, params identity.
}
case identity.ExpandFieldVerifiableAddresses:
addrs := make([]identity.VerifiableAddress, 0)
if err := con.Where("nid = ?", nid).Where("identity_id IN (?)", identityIDs).Order("id").All(&addrs); err != nil {
if err := con.Where("identity_id IN (?)", identityIDs).Where("nid = ?", nid).Order("id").All(&addrs); err != nil {
return sqlcon.HandleError(err)
}
for _, addr := range addrs {
identitiesByID[addr.IdentityID].VerifiableAddresses = append(identitiesByID[addr.IdentityID].VerifiableAddresses, addr)
}
case identity.ExpandFieldRecoveryAddresses:
addrs := make([]identity.RecoveryAddress, 0)
if err := con.Where("nid = ?", nid).Where("identity_id IN (?)", identityIDs).Order("id").All(&addrs); err != nil {
if err := con.Where("identity_id IN (?)", identityIDs).Where("nid = ?", nid).Order("id").All(&addrs); err != nil {
return sqlcon.HandleError(err)
}
for _, addr := range addrs {
Expand Down
2 changes: 1 addition & 1 deletion selfservice/flow/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func NewFlowReplacedError(message *text.Message) *ReplacedError {
return &ReplacedError{
DefaultError: x.ErrGone.WithID(text.ErrIDSelfServiceFlowReplaced).
WithError("self-service flow replaced").
WithReasonf(message.Text),
WithReason(message.Text),
}
}

Expand Down
2 changes: 1 addition & 1 deletion selfservice/strategy/passkey/passkey_registration.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ func (s *Strategy) Register(w http.ResponseWriter, r *http.Request, regFlow *reg
herodot.ErrInternalServerError.WithReasonf("Expected WebAuthN in internal context to be an object but got: %s", err)))
}

if webAuthnSess.UserID == nil || len(webAuthnSess.UserID) == 0 {
if len(webAuthnSess.UserID) == 0 {
return s.handleRegistrationError(w, r, regFlow, params, errors.WithStack(
herodot.ErrInternalServerError.WithReasonf("Expected WebAuthN session data to contain a user ID")))
}
Expand Down
3 changes: 3 additions & 0 deletions selfservice/strategy/password/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,9 @@ func (s *DefaultPasswordValidator) Validate(ctx context.Context, identifier, pas
func (s *DefaultPasswordValidator) validate(ctx context.Context, identifier, password string) error {
passwordPolicyConfig := s.reg.Config().PasswordPolicyConfig(ctx)

//nolint:gosec // disable G115
if len(password) < int(passwordPolicyConfig.MinPasswordLength) {
//nolint:gosec // disable G115
return text.NewErrorValidationPasswordMinLength(int(passwordPolicyConfig.MinPasswordLength), len(password))
}

Expand Down Expand Up @@ -215,6 +217,7 @@ func (s *DefaultPasswordValidator) validate(ctx context.Context, identifier, pas
}
}

//nolint:gosec // disable G115
if c > int64(s.reg.Config().PasswordPolicyConfig(ctx).MaxBreaches) {
return text.NewErrorValidationPasswordTooManyBreaches(c)
}
Expand Down

0 comments on commit dfdc9bb

Please sign in to comment.