Skip to content
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

fix(db/types): add check before owner decrypt #1166

Merged
merged 2 commits into from
Aug 26, 2024
Merged
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
12 changes: 9 additions & 3 deletions database/types/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,15 @@
}

// decrypt owner
err = r.Owner.Decrypt(key)
if err != nil {
return err
// Note: In UpdateRepo() (database/repo/update.go), the incoming API repo object
// is cast to a database repo object. The owner object isn't set in this process
// resulting in a zero value for the owner object. A check is performed here
// before decrypting to prevent "unable to decrypt repo..." errors.
if r.Owner.ID.Valid {
err = r.Owner.Decrypt(key)
if err != nil {
return err
}
}

return nil
Expand Down Expand Up @@ -327,7 +333,7 @@
Topics: pq.StringArray(r.GetTopics()),
BuildLimit: sql.NullInt64{Int64: r.GetBuildLimit(), Valid: true},
Timeout: sql.NullInt64{Int64: r.GetTimeout(), Valid: true},
Counter: sql.NullInt32{Int32: int32(r.GetCounter()), Valid: true},

Check failure on line 336 in database/types/repo.go

View workflow job for this annotation

GitHub Actions / golangci

[golangci] database/types/repo.go#L336

G115: integer overflow conversion int -> int32 (gosec)
Raw output
database/types/repo.go:336:43: G115: integer overflow conversion int -> int32 (gosec)
		Counter:      sql.NullInt32{Int32: int32(r.GetCounter()), Valid: true},
		                                        ^

Check failure on line 336 in database/types/repo.go

View workflow job for this annotation

GitHub Actions / full-review

G115: integer overflow conversion int -> int32 (gosec)
Visibility: sql.NullString{String: r.GetVisibility(), Valid: true},
Private: sql.NullBool{Bool: r.GetPrivate(), Valid: true},
Trusted: sql.NullBool{Bool: r.GetTrusted(), Valid: true},
Expand Down
Loading