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

+13 -2
View File
@@ -32,10 +32,12 @@ const zoneSummarySelect = "SELECT r.`zone`, COUNT(*), " +
"ORDER BY s.`name` <> '', s.`id` LIMIT 1) FROM {records} r "
func (s recordStore) ListZones(ctx context.Context) ([]zoneSummary, error) {
defer traceStore(ctx, "recordStore.ListZones")()
return s.queryZones(ctx, s.t.sql(zoneSummarySelect+"GROUP BY r.`zone` ORDER BY r.`zone`"))
}
func (s recordStore) ListZonesOfUser(ctx context.Context, userID int64) ([]zoneSummary, error) {
defer traceStore(ctx, "recordStore.ListZonesOfUser")()
return s.queryZones(ctx, s.t.sql(zoneSummarySelect+
"WHERE r.`zone` IN (SELECT d.`zone` FROM {delegations} d WHERE d.`user_id` = ?) GROUP BY r.`zone` ORDER BY r.`zone`"), userID)
}
@@ -61,6 +63,7 @@ func (s recordStore) queryZones(ctx context.Context, query string, args ...any)
}
func (s recordStore) ZoneExists(ctx context.Context, zone string) (bool, error) {
defer traceStore(ctx, "recordStore.ZoneExists")()
var one int
err := s.q.QueryRowContext(ctx, s.t.sql("SELECT 1 FROM {records} WHERE `zone` = ? LIMIT 1"), zone).Scan(&one)
if errors.Is(err, sql.ErrNoRows) {
@@ -73,10 +76,12 @@ func (s recordStore) ZoneExists(ctx context.Context, zone string) (bool, error)
}
func (s recordStore) ZoneRows(ctx context.Context, zone string) ([]recordRow, error) {
defer traceStore(ctx, "recordStore.ZoneRows")()
return s.queryRecords(ctx, s.t.sql("SELECT "+recordColumns+" FROM {records} WHERE `zone` = ? ORDER BY `id`"), zone)
}
func (s recordStore) ZoneRowsForUpdate(ctx context.Context, zone string) ([]recordRow, error) {
defer traceStore(ctx, "recordStore.ZoneRowsForUpdate")()
return s.queryRecords(ctx, s.t.sql("SELECT "+recordColumns+" FROM {records} WHERE `zone` = ? ORDER BY `id` FOR UPDATE"), zone)
}
@@ -101,10 +106,12 @@ func (s recordStore) queryRecords(ctx context.Context, query string, args ...any
}
func (s recordStore) RecordByID(ctx context.Context, id int64) (recordRow, error) {
defer traceStore(ctx, "recordStore.RecordByID")()
return s.queryRecord(ctx, s.t.sql("SELECT "+recordColumns+" FROM {records} WHERE `id` = ?"), id)
}
func (s recordStore) RecordByIDForUpdate(ctx context.Context, id int64) (recordRow, error) {
defer traceStore(ctx, "recordStore.RecordByIDForUpdate")()
return s.queryRecord(ctx, s.t.sql("SELECT "+recordColumns+" FROM {records} WHERE `id` = ? FOR UPDATE"), id)
}
@@ -121,7 +128,8 @@ func (s recordStore) queryRecord(ctx context.Context, query string, id int64) (r
}
func (s recordStore) InsertRecord(ctx context.Context, r recordRow) (int64, error) {
res, err := s.q.ExecContext(ctx,
defer traceStore(ctx, "recordStore.InsertRecord")()
res, err := s.q.ExecContext(privateSQLArgs(ctx, 4),
s.t.sql("INSERT INTO {records} (`zone`, `name`, `ttl`, `content`, `record_type`) VALUES (?, ?, ?, ?, ?)"),
r.Zone, r.Name, r.TTL, r.Content, r.RecordType)
if err != nil {
@@ -135,7 +143,8 @@ func (s recordStore) InsertRecord(ctx context.Context, r recordRow) (int64, erro
}
func (s recordStore) UpdateRecord(ctx context.Context, r recordRow) error {
_, err := s.q.ExecContext(ctx,
defer traceStore(ctx, "recordStore.UpdateRecord")()
_, err := s.q.ExecContext(privateSQLArgs(ctx, 4),
s.t.sql("UPDATE {records} SET `zone` = ?, `name` = ?, `ttl` = ?, `content` = ?, `record_type` = ? WHERE `id` = ?"),
r.Zone, r.Name, r.TTL, r.Content, r.RecordType, r.ID)
if err != nil {
@@ -145,6 +154,7 @@ func (s recordStore) UpdateRecord(ctx context.Context, r recordRow) error {
}
func (s recordStore) DeleteRecord(ctx context.Context, id int64) (bool, error) {
defer traceStore(ctx, "recordStore.DeleteRecord")()
res, err := s.q.ExecContext(ctx, s.t.sql("DELETE FROM {records} WHERE `id` = ?"), id)
if err != nil {
return false, fmt.Errorf("delete record: %w", err)
@@ -157,6 +167,7 @@ func (s recordStore) DeleteRecord(ctx context.Context, id int64) (bool, error) {
}
func (s recordStore) DeleteZoneRecords(ctx context.Context, zone string) (int64, error) {
defer traceStore(ctx, "recordStore.DeleteZoneRecords")()
res, err := s.q.ExecContext(ctx, s.t.sql("DELETE FROM {records} WHERE `zone` = ?"), zone)
if err != nil {
return 0, fmt.Errorf("delete zone records: %w", err)