Third audit: security fixes and server-side scalability
Security: - docx unzip reads each part once (a repeated entry was a zip bomb) - request files must be named for their type (no PDF named .html) - team roster hidden when its organization is unpublished - /people?ids= hides draft organizations, takes 200 ids - v_events takes the first published host and reads event_hosts directly (migration 059, plus an index on person_awards.event_id) - group accounts refused while access groups are off; group sync can't undo a superadmin's disable - 64 KB body limit on login, feedback and csp-report - Drive pick-up races no longer 500; random upload boundary Scalability: - /events filters by scope, host, status and type on the server; Home no longer prefetches every event - /organizations leaves out bodies and leadership; the map's group panel fetches its own - admin lists page with Show more and a real count - content request record search and the newsletter's post list ask the server Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
0bb4b8685f
commit
f99010252f
18 changed files with 229 additions and 96 deletions
|
|
@ -66,16 +66,24 @@ export async function groupRole(db, email) {
|
|||
/* Brings a group account in line with `role` (null: in no group).
|
||||
Returns what changed, as text for the log and the Panel, or null. */
|
||||
export function applyGroupRole(db, user, role) {
|
||||
// `user` was read before the group lookups were awaited, so each
|
||||
// write rechecks that a superadmin hasn't disabled or promoted the
|
||||
// account meanwhile.
|
||||
const STILL_OURS = `AND role <> 'superadmin' AND (is_active = 1 OR group_disabled = 1)`;
|
||||
let change = null;
|
||||
if (!role) {
|
||||
if (user.is_active === 1) {
|
||||
db.prepare(`UPDATE admin_users SET is_active = 0, group_disabled = 1 WHERE id = ?`).run(user.id);
|
||||
const res = db
|
||||
.prepare(`UPDATE admin_users SET is_active = 0, group_disabled = 1 WHERE id = ? ${STILL_OURS}`)
|
||||
.run(user.id);
|
||||
db.prepare(`DELETE FROM sessions WHERE user_id = ?`).run(user.id);
|
||||
change = "disabled: in no access group";
|
||||
if (res.changes) change = "disabled: in no access group";
|
||||
}
|
||||
} else if (user.is_active !== 1 || user.role !== role) {
|
||||
db.prepare(`UPDATE admin_users SET role = ?, is_active = 1, group_disabled = 0 WHERE id = ?`).run(role, user.id);
|
||||
change = user.is_active !== 1 ? `enabled as ${role}` : `${user.role} → ${role}`;
|
||||
const res = db
|
||||
.prepare(`UPDATE admin_users SET role = ?, is_active = 1, group_disabled = 0 WHERE id = ? ${STILL_OURS}`)
|
||||
.run(role, user.id);
|
||||
if (res.changes) change = user.is_active !== 1 ? `enabled as ${role}` : `${user.role} → ${role}`;
|
||||
}
|
||||
db.prepare(`UPDATE admin_users SET groups_checked_at = datetime('now') WHERE id = ?`).run(user.id);
|
||||
if (change) console.log(`access: ${user.email} ${change}`);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue