Refresh HiveGrid Cloud reference snapshot
This commit is contained in:
1 parent
5e99e14772
commit
7f88026f79
5955 files changed
+1177325
-188362
No files matched your search
+30
-5
@@ -17,8 +17,15 @@
|
||||
* The validation + payload-shaping below are pure functions so they unit
|
||||
* test without a database; only `recordAdminAction` touches the writer.
|
||||
*/
|
||||
import { createAuditEvent, type AuditEventInput, type AuditOutcome } from "@hivegrid/db/audit-events.server";
|
||||
import {
|
||||
createAuditEvent,
|
||||
createAuditEventInExistingTransaction,
|
||||
type AuditEventInput,
|
||||
type AuditEventWriterClient,
|
||||
type AuditOutcome,
|
||||
} from "@hivegrid/db/audit-events.server";
|
||||
import type { Prisma } from "@hivegrid/db/prisma-browser";
|
||||
import { getTrustedClientIpOrNull } from "~/utils/server/IpUtils";
|
||||
|
||||
/**
|
||||
* Closed taxonomy of audited platform-operator actions. Closed union so a
|
||||
@@ -38,10 +45,24 @@ export const ADMIN_OPERATOR_ACTIONS = [
|
||||
"queue.paused",
|
||||
"queue.resumed",
|
||||
"queue.jobRetried",
|
||||
"webhook.replayRequested",
|
||||
"support.replied",
|
||||
"support.noteAdded",
|
||||
"support.statusChanged",
|
||||
"support.assigned",
|
||||
// AK-P21 — reading a customer-uploaded feedback attachment. A read, not a
|
||||
// mutation, but it exposes material the customer uploaded, so it is audited
|
||||
// like the mutating operator actions.
|
||||
"support.attachmentDownloaded",
|
||||
"security.sessionRevoked",
|
||||
"security.trustedDeviceForgotten",
|
||||
"security.adminUserPrepared",
|
||||
"security.adminUserDisabled",
|
||||
"security.adminRolesChanged",
|
||||
"security.adminRolePermissionsChanged",
|
||||
"featureFlag.bulkOverride",
|
||||
"portalDomain.killSwitchEnabled",
|
||||
"portalDomain.killSwitchDisabled",
|
||||
] as const;
|
||||
|
||||
export type AdminOperatorAction = (typeof ADMIN_OPERATOR_ACTIONS)[number];
|
||||
@@ -127,8 +148,7 @@ export type AdminActionAuditContext = {
|
||||
|
||||
function clientMeta(request: Request | undefined): { ip: string | null; userAgent: string | null } {
|
||||
if (!request) return { ip: null, userAgent: null };
|
||||
const fwd = request.headers.get("x-forwarded-for") ?? "";
|
||||
const ip = fwd.split(",")[0]?.trim() || request.headers.get("x-real-ip") || null;
|
||||
const ip = getTrustedClientIpOrNull(request);
|
||||
const userAgent = request.headers.get("user-agent") || null;
|
||||
return { ip, userAgent };
|
||||
}
|
||||
@@ -168,6 +188,11 @@ export function buildAdminActionAuditInput(context: AdminActionAuditContext): Au
|
||||
* propagate (unlike the best-effort SSO logger): a sensitive operator
|
||||
* action that cannot be audited should surface, not silently succeed.
|
||||
*/
|
||||
export async function recordAdminAction(context: AdminActionAuditContext): Promise<void> {
|
||||
await createAuditEvent(buildAdminActionAuditInput(context));
|
||||
export async function recordAdminAction(context: AdminActionAuditContext, client?: AuditEventWriterClient): Promise<void> {
|
||||
const input = buildAdminActionAuditInput(context);
|
||||
if (client) {
|
||||
await createAuditEventInExistingTransaction(input, client);
|
||||
return;
|
||||
}
|
||||
await createAuditEvent(input);
|
||||
}
|
||||
Reference in new issue
Block a user