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:
1 parent
5f17aab6ca
commit
53444bec7a
40 files changed
+2332
-254
No files matched your search
@@ -37,7 +37,6 @@ const usageText = `usage:
|
||||
const (
|
||||
healthcheckTimeout = 3 * time.Second
|
||||
defaultAuditRows = 20
|
||||
maxAuditRows = 1000000
|
||||
maxPasswordLineBytes = 4096
|
||||
cliTimeLayout = "2006-01-02T15:04:05Z"
|
||||
)
|
||||
@@ -108,6 +107,7 @@ func (a *app) runDatabaseCommand(ctx context.Context, args []string) (err error)
|
||||
return err
|
||||
}
|
||||
log := newLogger(a.stderr, cfg.LogLevel)
|
||||
ctx = withTraceLogger(ctx, log)
|
||||
defer traceFunc(ctx, log, "app.runDatabaseCommand")()
|
||||
var cmd cliCommand
|
||||
switch args[0] {
|
||||
@@ -350,7 +350,7 @@ func (a *app) parseAuditCommand(args []string) (cliCommand, error) {
|
||||
if len(args) > 1 {
|
||||
return cliCommand{}, usageError("audit takes at most one count")
|
||||
}
|
||||
n := defaultAuditRows
|
||||
n := int64(defaultAuditRows)
|
||||
if len(args) == 1 {
|
||||
v, err := parseAuditCount(args[0])
|
||||
if err != nil {
|
||||
@@ -363,12 +363,12 @@ func (a *app) parseAuditCommand(args []string) (cliCommand, error) {
|
||||
}}, nil
|
||||
}
|
||||
|
||||
func parseAuditCount(s string) (int, error) {
|
||||
if s == "" || len(s) > 7 || strings.Trim(s, "0123456789") != "" {
|
||||
func parseAuditCount(s string) (int64, error) {
|
||||
if s == "" || strings.Trim(s, "0123456789") != "" {
|
||||
return 0, errors.New("invalid count")
|
||||
}
|
||||
n, err := strconv.Atoi(s)
|
||||
if err != nil || n < 1 || n > maxAuditRows {
|
||||
n, err := strconv.ParseInt(s, 10, 64)
|
||||
if err != nil || n < 1 {
|
||||
return 0, errors.New("invalid count")
|
||||
}
|
||||
return n, nil
|
||||
@@ -377,7 +377,7 @@ func parseAuditCount(s string) (int, error) {
|
||||
type cliReadBackend interface {
|
||||
ListZones(ctx context.Context) ([]zoneSummary, error)
|
||||
ZoneRows(ctx context.Context, zone string) ([]recordRow, error)
|
||||
LatestAudit(ctx context.Context, n int) ([]auditRow, error)
|
||||
LatestAudit(ctx context.Context, n int64) ([]auditRow, error)
|
||||
}
|
||||
|
||||
type sqlReadBackend struct {
|
||||
@@ -454,7 +454,7 @@ func (a *app) checkZones(ctx context.Context, b cliReadBackend, zone string) err
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *app) runAudit(ctx context.Context, db *sql.DB, t tableNames, log *slog.Logger, n int) error {
|
||||
func (a *app) runAudit(ctx context.Context, db *sql.DB, t tableNames, log *slog.Logger, n int64) error {
|
||||
return a.printAudit(ctx, a.newReadBackend(db, t), n)
|
||||
}
|
||||
|
||||
@@ -489,7 +489,7 @@ func auditRows(entries []auditRow) [][]string {
|
||||
return rows
|
||||
}
|
||||
|
||||
func (a *app) printAudit(ctx context.Context, b cliReadBackend, n int) error {
|
||||
func (a *app) printAudit(ctx context.Context, b cliReadBackend, n int64) error {
|
||||
entries, err := b.LatestAudit(ctx, n)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -700,7 +700,7 @@ func (a *app) userRole(ctx context.Context, b cliUserBackend, log *slog.Logger,
|
||||
if u.Role == role {
|
||||
return nil
|
||||
}
|
||||
if u.Role == roleAdmin && len(admins) <= 1 {
|
||||
if leavesNoActiveAdmin(u, admins) {
|
||||
return errLastActiveAdmin
|
||||
}
|
||||
if err := tx.SetRole(ctx, u.ID, role, now); err != nil {
|
||||
@@ -732,7 +732,7 @@ func (a *app) userDelete(ctx context.Context, b cliUserBackend, log *slog.Logger
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if u.Role == roleAdmin && len(admins) <= 1 {
|
||||
if leavesNoActiveAdmin(u, admins) {
|
||||
return errLastActiveAdmin
|
||||
}
|
||||
if err := tx.MarkDeleted(ctx, u.ID, now); err != nil {
|
||||
|
||||
Reference in new issue
Block a user