test(ui): avoid a literal em dash in the em dash check

- test(ui): avoid a literal em dash in the em dash check
- fix(cli): accept any positive int64 audit count and share the last active admin rule
- fix(api): limit audit before_id to 2^53-1
- fix(api): audit unmatched api requests, bound every request body and record audit write failures
- fix(ui): recheck the account in the login transaction and require existing zones on zone pages
- fix(api): recheck the acting admin and the stored password hash in change transactions
- fix(db): keep committed outcomes on lock release failure, narrow the records contract and trace sql statements
- fix(db): make the initial migration restartable and verify the application schema
- fix(auth): never move last_seen_at backwards on concurrent session touches
- test(api): cover lock release failure after commit and handler tracing without secrets
- fix(test): redact credentials from mysql setup errors
- fix(audit): retain addressed objects on admin refusals
- test(db): cover migration restarts and records contract ranges in mysql
- test(api): verify account races and audit rollback in mysql
- fix(auth): reject password changes after account deletion
- docs: document unknown api audit entries
- fix(audit): bound failure retries and redact sensitive sql parameters
- fix(test): isolate docker resources and cover image cli commands
- test(auth): expect unauthorized after an account deletion race
- fix(db): verify application column widths and foreign keys
This commit is contained in:
bryanpedini committed 2026-11-19 15:46:12 +01:00
1 parent 5f17aab6ca
commit 53444bec7a
40 files changed
+2332 -254

No files matched your search

+7
View File
@@ -35,6 +35,7 @@ func newDelegationStore(q dbtx, t tableNames) delegationStore {
}
func (s delegationStore) GrantDelegation(ctx context.Context, zone string, userID, createdBy int64, now time.Time) (bool, error) {
defer traceStore(ctx, "delegationStore.GrantDelegation")()
_, err := s.q.ExecContext(ctx,
s.t.sql("INSERT INTO {delegations} (`zone`, `user_id`, `created_at`, `created_by`) VALUES (?, ?, ?, ?)"),
zone, userID, dbTime(now), createdBy)
@@ -48,6 +49,7 @@ func (s delegationStore) GrantDelegation(ctx context.Context, zone string, userI
}
func (s delegationStore) RevokeDelegation(ctx context.Context, zone string, userID int64) (bool, error) {
defer traceStore(ctx, "delegationStore.RevokeDelegation")()
res, err := s.q.ExecContext(ctx, s.t.sql("DELETE FROM {delegations} WHERE `zone` = ? AND `user_id` = ?"), zone, userID)
if err != nil {
return false, fmt.Errorf("revoke delegation: %w", err)
@@ -60,6 +62,7 @@ func (s delegationStore) RevokeDelegation(ctx context.Context, zone string, user
}
func (s delegationStore) ZoneUsers(ctx context.Context, zone string) ([]userRow, error) {
defer traceStore(ctx, "delegationStore.ZoneUsers")()
rows, err := s.q.QueryContext(ctx,
s.t.sql("SELECT "+userColumns+" FROM {delegations} d JOIN {users} u ON u.`id` = d.`user_id` "+
"WHERE d.`zone` = ? AND u.`role` = 'user' AND u.`deleted_at` IS NULL ORDER BY u.`username`"), zone)
@@ -70,6 +73,7 @@ func (s delegationStore) ZoneUsers(ctx context.Context, zone string) ([]userRow,
}
func (s delegationStore) UserZones(ctx context.Context, userID int64) ([]userZone, error) {
defer traceStore(ctx, "delegationStore.UserZones")()
rows, err := s.q.QueryContext(ctx,
s.t.sql("SELECT d.`zone`, d.`created_at`, EXISTS (SELECT 1 FROM {records} r WHERE r.`zone` = d.`zone`) "+
"FROM {delegations} d WHERE d.`user_id` = ? ORDER BY d.`zone`"), userID)
@@ -93,6 +97,7 @@ func (s delegationStore) UserZones(ctx context.Context, userID int64) ([]userZon
}
func (s delegationStore) DeleteZoneDelegations(ctx context.Context, zone string) ([]delegationRow, error) {
defer traceStore(ctx, "delegationStore.DeleteZoneDelegations")()
rows, err := s.q.QueryContext(ctx,
s.t.sql("SELECT d.`zone`, d.`user_id`, u.`username`, d.`created_at`, d.`created_by` FROM {delegations} d "+
"JOIN {users} u ON u.`id` = d.`user_id` WHERE d.`zone` = ? ORDER BY u.`username` FOR UPDATE OF d"), zone)
@@ -136,9 +141,11 @@ func (s delegationStore) hasDelegation(ctx context.Context, query, zone string,
}
func (s delegationStore) HasDelegation(ctx context.Context, zone string, userID int64) (bool, error) {
defer traceStore(ctx, "delegationStore.HasDelegation")()
return s.hasDelegation(ctx, "SELECT 1 FROM {delegations} WHERE `zone` = ? AND `user_id` = ?", zone, userID)
}
func (s delegationStore) HasDelegationForShare(ctx context.Context, zone string, userID int64) (bool, error) {
defer traceStore(ctx, "delegationStore.HasDelegationForShare")()
return s.hasDelegation(ctx, "SELECT 1 FROM {delegations} WHERE `zone` = ? AND `user_id` = ? FOR SHARE", zone, userID)
}