Skip to content

fix: harden JSON import/export boundaries and unify HTTP Master PIN rate limit - #1509

Merged
khaira777 merged 4 commits into
mainfrom
fm/flocafe-sec-batch1-db-masterpin
Nov 8, 2026
Merged

khaira777 merged 4 commits into
mainfrom
fm/flocafe-sec-batch1-db-masterpin

Conversation

@khaira777

@khaira777 khaira777 commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Intent

Proceed with sequential local implementation Batch 1 (Items 2, 3, and 5 of the revised security plan), subject to these decisions and acceptance criteria:

  1. Approve the JSON import boundary fix :
  • Never import supplied passwords, PINs, PIN hashes, activation state, or privileged roles.
  • Preserve historical staff references through inactive placeholders with unusable credentials. Handle credential-bearing input rows too; the current placeholder helper skips those rows.
  • Block JSON import mutation of permission overrides and authentication/authorization audit tables.
  • Preserve existing users, exported audit history, additive-import behavior, and authoritative SQLite backup restore.
  • Prove that a delegated database.manage user cannot grant permissions or strand administration through import.
  1. Approve shared HTTP Master PIN throttling and the download header fix :
  • Use one failure budget per normalized client IP across HTTP routes and password recovery. Paths, filename parameters, casing, and equivalent IP representations must not create fresh budgets.
  • Accept x-master-pin for the download route; never accept URL query credentials.
  1. Narrow export cleanup :
  • Add revoked_tokens to EXPORT_EXCLUDE_TABLES.
  • Redact the explicit Google Drive private-setting keys. Leave PostHog settings unchanged in this batch: its project token and host are intentionally exposed through renderer bootstrap (main/services/posthog.ts:368). Do not introduce blanket posthog_* redaction.
  1. Verification & Commit Gate:
  • Run focused regression suites, npm run lint, npm run build, and npm test; run browser/Electron checks for affected flows and documentation checks for changed contracts. Report fresh results, limitations, final diff, and git status.
  • Commit, push, and create the PR using /no-mistakes: yes.

What Changed

  • Hardened /api/db-tools/import so imported users rows never overwrite existing accounts or import credentials, activation state, or privileged roles (owner/manager), instead creating inactive non-privileged placeholders (cashier/server/chef) with unusable password hashes, and blocked JSON import mutations to role_permission_overrides, user_permission_overrides, authorization_audit_log, and auth_audit_log.
  • Unified HTTP Master PIN rate limiting across requireMasterPin and POST /api/auth/recover-password under a shared per-IP key (master-pin:${normalizeIpForRateLimit(ip)}) with IPv6 loopback normalization (::1 and 0:0:0:0:0:0:0:1 to 127.0.0.1), accepted x-master-pin header credentials on Master PIN routes, and enabled dotfile streaming on /api/db-tools/download temporary snapshots.
  • Excluded revoked_tokens and redacted GOOGLE_DRIVE_PRIVATE_SETTING_KEYS in /api/db-tools/export, and updated the authentication, frontend, and API documentation and regression test suites to match.

Risk Assessment

✅ Low: The changes cleanly enforce the JSON import/export security boundaries, x-master-pin header support, and shared normalized-IP Master PIN rate limiting with complete regression test coverage and updated documentation.

Testing

Ran npm run build, npm run test:master-pin, npm run test:database-tools-api, npm run docs:check, and git diff --check, then stood up the real Express API server (startServer() on http://127.0.0.1:3001) against an isolated SQLite store directory and drove all 6 end-to-end HTTP scenarios live, confirming that GET /api/db/download with x-master-pin streams a valid SQLite snapshot (SQLite format 3\0, 1,011,712 bytes) while rejecting query-string PINs with 403, JSON import neutralizes credentialed/privileged user rows and blocks permission/audit table tampering, GET /api/db/export omits revoked_tokens and redacts all 27 Google Drive private setting keys while preserving PostHog settings and audit logs, and HTTP Master PIN failures share a single 5-attempt budget per normalized client IP across routes and password recovery. Every check and live scenario passed; this is a backend/API and documentation change with no UI/visual surface change.

  • Live validation: ✅ go - 6 of 6 scenarios driven live against the product
Scenario Result Live Evidence
Delegated database.manage user imports JSON containing credential-bearing users (owner, manager, server) referenced by historical orders; imported users are created only as inactive placeholders with… ✅ pass live ~/.no-mistakes/evidence/01M6WE39BZ0B9FAKWAG7GDX8Y9/live-batch1-validation.json (scenarios.scenario1_and_2)
Adversarial: Delegated database.manage user attempts privilege escalation and admin stranding via additive and overwrite JSON imports supplying user_permission_overrides, role_permission_overrides, au… ✅ pass live ~/.no-mistakes/evidence/01M6WE39BZ0B9FAKWAG7GDX8Y9/live-batch1-validation.json (scenarios.scenario1_and_2)
Owner exports database via GET /api/db/export; revoked_tokens is excluded, all 27 GOOGLE_DRIVE_PRIVATE_SETTING_KEYS are redacted to [REDACTED], PostHog public bootstrap settings remain unredacted, and… ✅ pass live ~/.no-mistakes/evidence/01M6WE39BZ0B9FAKWAG7GDX8Y9/live-batch1-validation.json (scenarios.scenario3_export)
Owner calls GET /api/db/download with ?master_pin=1234 (rejected with 403) and then with x-master-pin: 1234 header to stream a valid 1,011,712-byte SQLite backup snapshot with attachment Content-Dispo… ✅ pass live ~/.no-mistakes/evidence/01M6WE39BZ0B9FAKWAG7GDX8Y9/live-batch1-validation.json (scenarios.scenario4_download)
Adversarial: Caller rotates across POST /api/db/backup, POST /api/db-tools/INITIALIZE/, POST /api/db-tools/backups/backup-a.db/delete, POST /api/db-tools/BACKUPS/backup-b.db/DELETE/, and POST /api/aut… ✅ pass live ~/.no-mistakes/evidence/01M6WE39BZ0B9FAKWAG7GDX8Y9/live-batch1-validation.json (scenarios.scenario5_shared_rate_limit)
Owner creates a SQLite backup via POST /api/db/backup and restores it via POST /api/db/restore; authoritative SQLite backup restore succeeds in direct mode across all 69 tables ✅ pass live ~/.no-mistakes/evidence/01M6WE39BZ0B9FAKWAG7GDX8Y9/live-batch1-validation.json (scenarios.scenario6_sqlite_restore)
Evidence: Live HTTP validation evidence across all 6 Batch 1 security scenarios
{
  "commit": "972105f2dace19e3a63f04053f7082faade4cef2",
  "server": "http://127.0.0.1:3001",
  "scenarios": {
    "scenario1_and_2": {
      "additiveImportStatus": 200,
      "additiveImportBody": {
        "success": true,
        "message": "Database imported successfully",
        "backup": "/var/folders/y_/1ltcxtwj0zd_w1dg9jv4jl580000gn/T/flo-live-batch1-iPHTP3/backups/flo-backup-2026-11-08T02-48-59-586Z-56643354.db",
        "schemaVersionMismatch": false,
        "importedSchemaVersion": 125,
        "currentSchemaVersion": 125,
        "placeholderUsersCreated": 3,
        "cleanupPending": false
      },
      "rogueLoginStatus": 401,
      "importedUsersState": [
        {
          "id": "historical-server-live",
          "email": null,
          "password": "disabled-redacted-import-historical-server-live",
          "pin": null,
          "pin_hash": null,
          "role": "server",
          "is_active": 0
        },
        {
          "id": "rogue-manager-live",
          "email": null,
          "password": "disabled-redacted-import-rogue-manager-live",
          "pin": null,
          "pin_hash": null,
          "role": "cashier",
          "is_active": 0
        },
        {
          "id": "rogue-owner-live",
          "email": null,
          "password": "disabled-redacted-import-rogue-owner-live",
          "pin": null,
          "pin_hash": null,
          "role": "cashier",
          "is_active": 0
        }
      ],
      "overwriteStrandStatus": 200,
      "overwriteStrandBody": {
        "success": true,
        "message": "Database imported successfully",
        "backup": "/var/folders/y_/1ltcxtwj0zd_w1dg9jv4jl580000gn/T/flo-live-batch1-iPHTP3/backups/flo-backup-2026-11-08T02-48-59-757Z-4e70d39f.db",
        "schemaVersionMismatch": false,
        "importedSchemaVersion": 125,
        "currentSchemaVersion": 125,
        "placeholderUsersCreated": 0,
        "cleanupPending": false
      },
      "delegatedManagerHasCustomersCleanupAfterEscalationAttempt": false,
      "delegatedManagerStillHasDatabaseManageAfterOverwrite": true,
      "hasActiveAdministratorAfterImports": true,
      "authzAuditCountUnchanged": true,
      "authAuditCountUnchanged": true
    },
    "scenario3_export": {
      "status": 200,
      "hasRevokedTokensTable": false,
      "redactedFieldsContainsRevokedTokens": true,
      "googleDriveSettingsInExport": {
        "google_drive_account_subject": "[REDACTED]",
        "google_drive_account_email": "[REDACTED]",
        "google_drive_destination_folder_id": "[REDACTED]",
        "google_drive_destination_folder_name": "[REDACTED]",
        "google_drive_folder_id": "[REDACTED]",
        "google_drive_owned_destinations": "[REDACTED]",
        "google_drive_last_backup_at": "[REDACTED]",
        "google_drive_last_backup_status": "[REDACTED]",
        "google_drive_last_automatic_backup_at": "[REDACTED]",
        "google_drive_last_attempt_at": "[REDACTED]",
        "google_drive_last_success_at": "[REDACTED]",
        "google_drive_last_success_kind": "[REDACTED]",
        "google_drive_next_retry_at": "[REDACTED]",
        "google_drive_retention_status": "[REDACTED]",
        "google_drive_retention_retry_count": "[REDACTED]",
        "google_drive_last_error_code": "[REDACTED]",
        "google_drive_pending_upload": "[REDACTED]",
        "google_drive_job": "[REDACTED]",
        "google_drive_revoke_status": "[REDACTED]",
        "google_drive_revoke_cleanup_pending": "[REDACTED]",
        "google_drive_menu_folder_id": "[REDACTED]",
        "google_drive_menu_file_id": "[REDACTED]",
        "google_drive_menu_sharing_enabled": "[REDACTED]",
        "google_drive_menu_source": "[REDACTED]",
        "google_drive_menu_updated_at": "[REDACTED]",
        "google_drive_menu_file_name": "[REDACTED]",
        "google_drive_menu_web_view_link": "[REDACTED]"
      },
      "posthogSettingsInExport": {
        "posthog_project_token": "phc_live_public_token",
        "posthog_host": "https://us.i.posthog.com"
      },
      "authorizationAuditLogRowsPreserved": 1,
      "authAuditLogRowsPreserved": 1
    },
    "scenario4_download": {
      "queryParamAttemptStatus": 403,
      "queryParamAttemptBody": {
        "error": "Invalid Master PIN"
      },
      "headerAttemptStatus": 200,
      "headerContentDisposition": "attachment; filename=flo-database-2026-11-08T02-48-59-861Z.db",
      "headerPayloadBytes": 1011712,
      "headerSqliteMagicValid": true
    },
    "scenario5_shared_rate_limit": {
      "attempt1_db_backup": 403,
      "attempt2_initialize_uppercase_slash": 403,
      "attempt3_delete_fileA": 403,
      "attempt4_delete_fileB_uppercase": 403,
      "attempt5_recover_password": {
        "status": 429,
        "body": {
          "error": "Too many incorrect Master PIN attempts. Try again later."
        }
      },
      "attempt6_download_even_with_valid_pin_while_locked_out": {
        "status": 429,
        "body": {
          "error": "Too many incorrect Master PIN attempts. Try again later."
        }
      }
    },
    "scenario6_sqlite_restore": {
      "backupCreateStatus": 200,
      "restoreStatus": 200,
      "restoreBody": {
        "success": true,
        "mode": "direct",
        "backupVersion": 125,
        "currentVersion": 125,
        "tablesRestored": 69,
        "cleanupPending": false
      }
    }
  }
}
- Outcome: 🔧 2 issues found → auto-fixed ✅ across 2 runs (36m9s)

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

🔧 **Review** - 2 issues found → auto-fixed ✅
  • ⚠️ main/routes/database.ts:450 - In POST /api/db/import, if (tableName === 'users') continue; is placed at main/routes/database.ts:479, after the if (rows.length === 0) overwrite-delete block (main/routes/database.ts:448-465), while main/routes/database.ts:450 repeats the IMPORT_BLOCKED_SECURITY_TABLES.has(tableName) check already executed at main/routes/database.ts:439. When importData.users is an empty array (users: []) and overwrite or hasVersionMismatch is true, main/routes/database.ts:458 runs DELETE FROM users, forcing mergeUserSecurityState (main/db.ts:6188-6216) to reconstruct deleted accounts via insertPreservedUser, which drops terms_accepted_at (NULL) and overwrites created_at and updated_at with now(). Skip tableName === 'users' at the top of the table loop (main/routes/database.ts:439) and remove the duplicate IMPORT_BLOCKED_SECURITY_TABLES check at main/routes/database.ts:450.
  • ⚠️ docs/architecture/authentication-and-authorization.md:297 - docs/architecture/authentication-and-authorization.md:297 states that normalizeIpForRateLimit(ip) causes equivalent loopback representations ::1, 127.0.0.1, and ::ffff:127.0.0.1 to share one 5-attempt Master PIN budget across requireMasterPin (main/middleware/master-pin.ts:7) and POST /api/auth/recover-password (main/routes/auth.ts:876, which explicitly accepts ::1, 127.0.0.1, and ::ffff:127.0.0.1 in LOCAL_SETUP_HOSTS at main/routes/auth.ts:77). However, normalizeIpForRateLimit (main/middleware/security.ts:24-27) only strips ::ffff:, returning '::1' for IPv6 loopback instead of '127.0.0.1' and leaving master-pin:::1 on a separate failure budget. Normalize IPv6 loopback (::1 / 0:0:0:0:0:0:0:1) to '127.0.0.1' in normalizeIpForRateLimit (and cover ::1 in tests/master-pin.test.ts:187).

🔧 Fix applied.
✅ Re-checked - no issues remain.

🔧 **Test** - 2 issues found → auto-fixed ✅
  • 🚨 main/routes/database.ts:968 - Live GET /api/db/download with a valid x-master-pin header passes requireMasterPin and creates the checkpointed backup in .flo-download-*, but res.download(snapshotPath, filename, (error) => settle(error)) in main/routes/database.ts:934-981 immediately fails with Express send NotFoundError: Not Found (404) because tempDir starts with a leading dot (.flo-download-) and res.download defaults to dotfiles: 'ignore'. Because a callback is supplied to res.download, Express does not forward the error to next(err), and main/routes/database.ts logs [DB Download] Stream error: Not Found without ending res, causing every real GET /api/db/download request to hang until timeout. tests/database-tools-api.test.ts:181-186 hid this bug by monkey-patching res.download for /api/db/download. Fix main/routes/database.ts (e.g. pass { dotfiles: 'allow' } or use a non-dot temp directory prefix, and end the response if an error occurs before headers are sent) and remove the test stub in tests/database-tools-api.test.ts:181-186 so the test exercises real res.download.
  • 🚨 live validation verdict: no-go (6 of 6 scenarios were driven live against the product); failed: Owner calls GET /api/db/download with ?master_pin=1234 (rejected with 403) and then with x-master-pin: 1234 header to stream a SQLite backup snapshot
  • Live validation: ❌ no-go - 6 of 6 scenarios driven live against the product
Scenario Result Live Evidence
Delegated database.manage user imports JSON containing credentialed owner/manager/server rows referenced by orders; credentials and active state are stripped, owner/manager roles clamp to cashier, ser… ✅ pass live ~/.no-mistakes/evidence/01M6WE39BZ0B9FAKWAG7GDX8Y9/live-batch1-validation.json
Delegated database.manage user attempts additive and overwrite JSON imports mutating user_permission_overrides, role_permission_overrides, authorization_audit_log, auth_audit_log, and users; overrides… ✅ pass live ~/.no-mistakes/evidence/01M6WE39BZ0B9FAKWAG7GDX8Y9/live-batch1-validation.json
Owner exports database via GET /api/db/export; revoked_tokens table is excluded, GOOGLE_DRIVE_PRIVATE_SETTING_KEYS are redacted to [REDACTED], posthog_project_token and posthog_host remain unredacted,… ✅ pass live ~/.no-mistakes/evidence/01M6WE39BZ0B9FAKWAG7GDX8Y9/live-batch1-validation.json
Owner calls GET /api/db/download with ?master_pin=1234 (rejected with 403) and then with x-master-pin: 1234 header to stream a SQLite backup snapshot ❌ fail live ~/.no-mistakes/evidence/01M6WE39BZ0B9FAKWAG7GDX8Y9/live-batch1-validation.json
Client submits 4 wrong Master PIN attempts across different HTTP routes, parameterized backup filenames, trailing slashes, and uppercase paths, then a 5th attempt on POST /api/auth/recover-password (a… ✅ pass live ~/.no-mistakes/evidence/01M6WE39BZ0B9FAKWAG7GDX8Y9/live-batch1-validation.json
Owner creates a SQLite backup via POST /api/db/backup and restores it via POST /api/db/restore; authoritative SQLite backup restore succeeds ✅ pass live ~/.no-mistakes/evidence/01M6WE39BZ0B9FAKWAG7GDX8Y9/live-batch1-validation.json
  • npm run test:master-pin
  • npm run test:database-tools-api
  • npm run test:issue-127-password-recovery
  • npm run test:security
  • npm run test:authorization-permissions
  • npm run build
  • npm run docs:check
  • Live HTTP scenario run against compiled dist/main/server with isolated SQLite store (live-batch1-validation.json)

🔧 Fix applied.
✅ Re-checked - no issues remain.

  • Live validation: ✅ go - 6 of 6 scenarios driven live against the product
Scenario Result Live Evidence
Delegated database.manage user imports JSON containing credential-bearing users (owner, manager, server) referenced by historical orders; imported users are created only as inactive placeholders with… ✅ pass live ~/.no-mistakes/evidence/01M6WE39BZ0B9FAKWAG7GDX8Y9/live-batch1-validation.json (scenarios.scenario1_and_2)
Adversarial: Delegated database.manage user attempts privilege escalation and admin stranding via additive and overwrite JSON imports supplying user_permission_overrides, role_permission_overrides, au… ✅ pass live ~/.no-mistakes/evidence/01M6WE39BZ0B9FAKWAG7GDX8Y9/live-batch1-validation.json (scenarios.scenario1_and_2)
Owner exports database via GET /api/db/export; revoked_tokens is excluded, all 27 GOOGLE_DRIVE_PRIVATE_SETTING_KEYS are redacted to [REDACTED], PostHog public bootstrap settings remain unredacted, and… ✅ pass live ~/.no-mistakes/evidence/01M6WE39BZ0B9FAKWAG7GDX8Y9/live-batch1-validation.json (scenarios.scenario3_export)
Owner calls GET /api/db/download with ?master_pin=1234 (rejected with 403) and then with x-master-pin: 1234 header to stream a valid 1,011,712-byte SQLite backup snapshot with attachment Content-Dispo… ✅ pass live ~/.no-mistakes/evidence/01M6WE39BZ0B9FAKWAG7GDX8Y9/live-batch1-validation.json (scenarios.scenario4_download)
Adversarial: Caller rotates across POST /api/db/backup, POST /api/db-tools/INITIALIZE/, POST /api/db-tools/backups/backup-a.db/delete, POST /api/db-tools/BACKUPS/backup-b.db/DELETE/, and POST /api/aut… ✅ pass live ~/.no-mistakes/evidence/01M6WE39BZ0B9FAKWAG7GDX8Y9/live-batch1-validation.json (scenarios.scenario5_shared_rate_limit)
Owner creates a SQLite backup via POST /api/db/backup and restores it via POST /api/db/restore; authoritative SQLite backup restore succeeds in direct mode across all 69 tables ✅ pass live ~/.no-mistakes/evidence/01M6WE39BZ0B9FAKWAG7GDX8Y9/live-batch1-validation.json (scenarios.scenario6_sqlite_restore)
  • npm run build
  • npm run test:master-pin
  • npm run test:database-tools-api
  • npm run docs:check
  • git diff --check
  • Live HTTP scenario validation against startServer() on http://127.0.0.1:3001 writing ~/.no-mistakes/evidence/01M6WE39BZ0B9FAKWAG7GDX8Y9/live-batch1-validation.json
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

@qodo-code-review

Copy link
Copy Markdown

ⓘ Your Qodo trial ends soon. Ask your workspace admin to set up billing to keep reviews running after the trial. Manage billing

@coderabbitai

coderabbitai Bot commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@qodo-code-review

Copy link
Copy Markdown

PR Summary by Qodo

Harden JSON import/export and share HTTP Master PIN limits

🐞 Bug fix ✨ Enhancement 🧪 Tests 📝 Documentation 🕐 40+ Minutes

Grey Divider

AI Description

• Prevent JSON imports from changing accounts, permission overrides, or authentication audit history
 while preserving staff references.
Diagram

graph TD
  Client["HTTP client"] --> Routes["Database routes"] --> Import["Import boundary"] --> SQLite[("SQLite data")] --> Export["Export redaction"] --> Client
  Routes --> Pin["PIN authorization"] --> Budget["Shared IP budget"]
  Client --> Recovery["Password recovery"] --> Pin
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Require SQLite backup restore instead of JSON import
  • ➕ Avoids accepting security-sensitive rows through an additive JSON importer.
  • ➖ Removes additive-import behavior and changes the existing restore workflow.
2. Stage imports in a separate database
  • ➕ Allows validation of the complete imported dataset before applying it to the live database.
  • ➖ Adds substantial migration and merge complexity while still requiring an explicit security-table policy.

Recommendation: Keep the explicit JSON import boundary: it preserves additive imports and historical staff references without granting imported accounts or overrides authority. A staged importer would be worth considering only as part of a broader import redesign.

Files changed (9) +707 / -55

Bug fix (4) +44 / -28
master-pin.tsShare PIN limits and accept header credentials +10/-4

Share PIN limits and accept header credentials

• Keys HTTP PIN authorization by normalized client IP instead of route. Reads the body PIN first, then 'x-master-pin', without accepting query credentials.

main/middleware/master-pin.ts

security.tsCanonicalize IPv6 loopback for rate limits +2/-1

Canonicalize IPv6 loopback for rate limits

• Maps compressed and expanded IPv6 loopback to IPv4 loopback after lowercasing and stripping IPv4-mapped prefixes.

main/middleware/security.ts

auth.tsJoin recovery to the shared PIN failure budget +1/-1

Join recovery to the shared PIN failure budget

• Uses the normalized-IP Master PIN key for password recovery, preventing a separate recovery-route attempt budget.

main/routes/auth.ts

database.tsProtect JSON boundaries and repair database downloads +31/-22

Protect JSON boundaries and repair database downloads

• Preserves existing users, creates inactive non-privileged placeholders for missing imported users, and blocks permission-override and authentication-audit imports. Excludes revoked tokens and redacts Google Drive private settings on export; permits temporary dotfile download streaming and handles stream failures.

main/routes/database.ts

Tests (2) +634 / -7
database-tools-api.test.tsCover import escalation, export redaction, and PIN downloads +519/-2

Cover import escalation, export redaction, and PIN downloads

• Adds HTTP regressions for delegated-user import attacks, preservation on overwrite, export exclusions, header-authenticated SQLite downloads, and the cross-route recovery PIN limit. Adjusts the stalled-download test stub for the download call signature.

tests/database-tools-api.test.ts

master-pin.test.tsCover middleware credentials and equivalent-IP lockouts +115/-5

Cover middleware credentials and equivalent-IP lockouts

• Tests header acceptance, query-credential rejection, and a shared five-failure budget across paths and equivalent loopback representations.

tests/master-pin.test.ts

Documentation (3) +29 / -20
authentication-and-authorization.mdDocument shared Master PIN failure budgets +12/-7

Document shared Master PIN failure budgets

• Describes normalized-IP bucketing across HTTP Master PIN routes and password recovery, body/header credential handling, and separate IPC keys. Clarifies loopback normalization for login lockouts.

docs/architecture/authentication-and-authorization.md

frontend.mdClarify database-tools Master PIN gates +10/-8

Clarify database-tools Master PIN gates

• Corrects the route count and lists the Master PIN-gated database-tools routes, including conditional PIN protection for reset.

docs/architecture/frontend.md

api.mdSpecify import, export, and download security contracts +7/-5

Specify import, export, and download security contracts

• Documents JSON import exclusions and placeholders, export redactions, and header-based PIN credentials for downloads.

docs/reference/api.md

@qodo-code-review

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)

Grey Divider

Great, no issues found!

Qodo reviewed your code and found no material issues that require review

Grey Divider

Tip of the day
💡 Did you know, you can pick a display mode instead of tweaking every Display option by hand

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

@khaira777
khaira777 merged commit 1f12357 into main Nov 8, 2026
23 checks passed
@khaira777
khaira777 deleted the fm/flocafe-sec-batch1-db-masterpin branch November 8, 2026 03:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant