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
|
|
@ -442,8 +442,8 @@ function attachAwards(db, orgs) {
|
|||
}
|
||||
|
||||
/* ── Events ────────────────────────────────────────────────────
|
||||
Flat, with the event scopes alongside. Retreats.tsx owns the
|
||||
band titles and colors and filters this list by scope_id.
|
||||
Flat, with the event scopes alongside, narrowed by the query
|
||||
(below). Each band asks for only what it shows.
|
||||
|
||||
Oldest first, undated last. The carousel shows the list as it
|
||||
comes and opens on the first upcoming event, so past events
|
||||
|
|
@ -461,13 +461,26 @@ content.get("/events", (c) => {
|
|||
.prepare(`SELECT id, name, sort_order FROM event_scopes ORDER BY sort_order`)
|
||||
.all();
|
||||
|
||||
// Optional filters, each narrowing the list (src/lib/eventData.ts):
|
||||
// ?scope=national ?host=<org or person slug> ?status=upcoming
|
||||
// ?type=class,workshop
|
||||
const where = [`is_published = 1`, `is_listed = 1`];
|
||||
const params = [];
|
||||
const scope = c.req.query("scope");
|
||||
if (scope) where.push(`scope_id = ?`), params.push(scope);
|
||||
const host = c.req.query("host");
|
||||
if (host) {
|
||||
where.push(`EXISTS (SELECT 1 FROM event_hosts h WHERE h.event_id = v_events.id AND (h.org_id = ? OR h.person_id = ?))`);
|
||||
params.push(host, host);
|
||||
}
|
||||
const status = c.req.query("status");
|
||||
if (status) where.push(`effective_status = ?`), params.push(status);
|
||||
const types = (c.req.query("type") ?? "").split(",").filter(Boolean).slice(0, 20);
|
||||
if (types.length) where.push(`event_type IN (${marks(types.length)})`), params.push(...types);
|
||||
|
||||
const rows = db
|
||||
.prepare(
|
||||
`SELECT * FROM v_events
|
||||
WHERE is_published = 1 AND is_listed = 1
|
||||
ORDER BY ${EVENT_ORDER}`,
|
||||
)
|
||||
.all();
|
||||
.prepare(`SELECT * FROM v_events WHERE ${where.join(" AND ")} ORDER BY ${EVENT_ORDER}`)
|
||||
.all(...params);
|
||||
|
||||
const ids = rows.map((row) => row.id);
|
||||
const links = loadLinks(db, "event", ids);
|
||||
|
|
@ -576,20 +589,17 @@ content.get("/organizations", (c) => {
|
|||
const ids = rows.map((row) => row.id);
|
||||
const links = loadLinks(db, "organization", ids);
|
||||
const cards = loadBlocks(db, "organization", ids, "card");
|
||||
const bodies = loadBlocks(db, "organization", ids, "body");
|
||||
|
||||
const organizations = rows.map((row) =>
|
||||
shapeOrganization(
|
||||
row,
|
||||
links.get(row.id) ?? [],
|
||||
cards.get(row.id) ?? [],
|
||||
bodies.get(row.id) ?? [],
|
||||
),
|
||||
);
|
||||
// No body blocks or leadership: they grow with every organization
|
||||
// and only a group's own detail panel or page shows them, which
|
||||
// fetch /organizations/:id.
|
||||
const organizations = rows.map((row) => {
|
||||
const { blocks, leadership, ...org } = shapeOrganization(row, links.get(row.id) ?? [], cards.get(row.id) ?? [], []);
|
||||
return org;
|
||||
});
|
||||
|
||||
attachRegionDetails(db, organizations);
|
||||
attachGroupDetails(db, organizations);
|
||||
attachLeadership(db, organizations);
|
||||
|
||||
return json(c, { organizations });
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue