Refresh HiveGrid Cloud reference snapshot

This commit is contained in:
david committed 2026-08-03 15:31:14 +02:00
1 parent 5e99e14772
commit 7f88026f79
5955 files changed
+1177325 -188362

No files matched your search

@@ -148,13 +148,21 @@ describe("PluginSettingsService", () => {
});
});
test("rejects symlink traversal out of the plugin bundle", async () => {
test("rejects symlink traversal out of the plugin bundle", async ({ skip }) => {
const root = await mkdtemp(path.join(os.tmpdir(), "plugin-settings-"));
const outside = path.join(root, "outside.html");
const bundleRoot = path.join(root, "com.acme.settings", "1.0.0", "ui");
await mkdir(bundleRoot, { recursive: true });
await writeFile(outside, "<main>Outside</main>");
await symlink(outside, path.join(bundleRoot, "settings.html"));
try {
await symlink(outside, path.join(bundleRoot, "settings.html"));
} catch (error) {
if (process.platform === "win32" && error && typeof error === "object" && "code" in error && error.code === "EPERM") {
skip("Windows symlink creation requires Developer Mode; Linux CI covers the traversal guard.");
return;
}
throw error;
}
process.env.PLUGIN_BINARY_BASE_PATH = root;
getPluginForTenantMock.mockResolvedValue(pluginFixture());
@@ -106,10 +106,11 @@ describe("emitPluginHookFireAndForget", () => {
{
hookName: "workflow.failed",
tenantId: "tenant_1",
error: "outbox unavailable",
errorName: "Error",
},
"plugin.hook.emit_failed"
);
expect(JSON.stringify(mocks.loggerError.mock.calls)).not.toContain("outbox unavailable");
});
it("publishes a plugin hook outbox event inside its one-shot transaction", async () => {
@@ -147,7 +148,14 @@ describe("emitPluginHookFireAndForget", () => {
});
it("records hook validation failures in logs without failing the caller", async () => {
const issues = [{ path: ["workflowId"], message: "Required" }];
const issues = [
{
code: "invalid_type",
path: ["workflowId"],
message: "Required: SECRET_API_KEY",
received: "owner@example.test",
},
];
mocks.emitPluginHook.mockRejectedValueOnce(new TestPluginHookValidationError("workflow.failed", issues));
await expect(
@@ -159,10 +167,13 @@ describe("emitPluginHookFireAndForget", () => {
{
hookName: "workflow.failed",
tenantId: "tenant_1",
issues,
issueCount: 1,
issues: [{ code: "invalid_type", path: ["workflowId"] }],
},
"plugin.hook.payload_invalid"
);
expect(JSON.stringify(mocks.loggerWarn.mock.calls)).not.toContain("SECRET_API_KEY");
expect(JSON.stringify(mocks.loggerWarn.mock.calls)).not.toContain("owner@example.test");
});
it("records transaction failures in logs without failing the caller", async () => {
@@ -190,9 +201,10 @@ describe("emitPluginHookFireAndForget", () => {
{
hookName: "user.created",
tenantId: "tenant_1",
error: "db down",
errorName: "Error",
},
"plugin.hook.emit_failed"
);
expect(JSON.stringify(mocks.loggerError.mock.calls)).not.toContain("db down");
});
});
@@ -18,18 +18,29 @@
*/
import { db } from "~/utils/db.server";
import {
publishOutboxEvent,
type OutboxPublisherTransaction,
} from "@hivegrid/db/outbox";
import {
emitPluginHook,
PluginHookValidationError,
type PluginHookDefinition,
} from "@hivegrid/plugin-runtime";
import { publishOutboxEvent, type OutboxPublisherTransaction } from "@hivegrid/db/outbox";
import { emitPluginHook, PluginHookValidationError, type PluginHookDefinition } from "@hivegrid/plugin-runtime";
import { createScopedLogger } from "~/utils/logger.server";
import { toSafeErrorLog } from "~/utils/safeErrorLog.server";
const pluginHookLogger = createScopedLogger("plugin-hook-publisher");
const SAFE_ISSUE_PATH_SEGMENT = /^[A-Za-z_][A-Za-z0-9_-]{0,63}$/u;
function summarizeValidationIssues(issues: readonly unknown[]) {
return issues.slice(0, 20).map((issue) => {
const candidate = issue && typeof issue === "object" ? (issue as { code?: unknown; path?: unknown }) : null;
const path = Array.isArray(candidate?.path)
? candidate.path.slice(0, 8).map((segment) => {
if (typeof segment === "number" && Number.isSafeInteger(segment)) return segment;
return typeof segment === "string" && SAFE_ISSUE_PATH_SEGMENT.test(segment) ? segment : "<redacted>";
})
: [];
return {
code: typeof candidate?.code === "string" && SAFE_ISSUE_PATH_SEGMENT.test(candidate.code) ? candidate.code : "unknown",
path,
};
});
}
/**
* Emit a plugin hook outside an existing transaction. Use this for the
@@ -68,7 +79,8 @@ export async function emitPluginHookFireAndForget<TPayload>(
{
hookName: def.name,
tenantId: options.tenantId ?? null,
issues: error.issues,
issueCount: error.issues.length,
issues: summarizeValidationIssues(error.issues),
},
"plugin.hook.payload_invalid"
);
@@ -78,7 +90,7 @@ export async function emitPluginHookFireAndForget<TPayload>(
{
hookName: def.name,
tenantId: options.tenantId ?? null,
error: error instanceof Error ? error.message : String(error),
...toSafeErrorLog(error),
},
"plugin.hook.emit_failed"
);