History

Add hosted outbound HTTP policy

Route hosted plugin outbound requests through a shared Effect HttpClient layer that blocks local/private/metadata targets and re-checks redirects. Thread the executor-provided HTTP client through OpenAPI, GraphQL, MCP probing, and OAuth discovery, keep local harnesses on the normal fetch client, and split the restored security coverage into the relevant existing suites. Fix cloud migration scripts to invoke the local Drizzle binary under op run.

Rhys Sullivan committed 6 months ago

Commit 5fc67cd1 parent 745deac19 files · +559 −36Browse files

Showing the changes to packages/plugins/openapi/src (1 of 19 files). Show all

Unified · Split

packages/plugins/openapi/src/sdk/plugin.ts+6−4
@@ -1,6 +1,6 @@
11 import { Effect, Option, Predicate, Schema } from "effect";
22 import type { Layer } from "effect";
3−import { FetchHttpClient, HttpClient } from "effect/unstable/http";
3+import { HttpClient } from "effect/unstable/http";
44
55 import { OpenApiGroup } from "../api/group";
66 import { OpenApiExtensionService, OpenApiHandlers } from "../api/handlers";
@@ -754,8 +754,6 @@ const toOpenApiSourceConfig = ( · 747 unmodified lines
754754 const isHttpUrl = (s: string): boolean => s.startsWith("http://") || s.startsWith("https://");
755755
756756 export const openApiPlugin = definePlugin((options?: OpenApiPluginOptions) => {
757− const httpClientLayer = options?.httpClientLayer ?? FetchHttpClient.layer;
758−
759757 type RebuildInput = {
760758 readonly specText: string;
761759 readonly scope: string;
@@ -902,6 +900,7 @@ export const openApiPlugin = definePlugin((options?: OpenApiPluginOptions) => { · 140 unmodified lines
902900 // than surface a 500 through the unwhitelisted error channel.
903901 const refreshSourceInternal = (ctx: PluginCtx<OpenapiStore>, sourceId: string, scope: string) =>
904902 Effect.gen(function* () {
903+ const httpClientLayer = options?.httpClientLayer ?? ctx.httpClientLayer;
905904 const existing = yield* ctx.storage.getSource(sourceId, scope);
906905 if (!existing) return;
907906 const effective = yield* resolveEffectiveSourceConfig(ctx, existing);
@@ -938,6 +937,7 @@ export const openApiPlugin = definePlugin((options?: OpenApiPluginOptions) => { · 30 unmodified lines
938937 storage: (deps): OpenapiStore => makeDefaultOpenapiStore(deps),
939938
940939 extension: (ctx) => {
940+ const httpClientLayer = options?.httpClientLayer ?? ctx.httpClientLayer;
941941 const addSpecInternal = (config: OpenApiSpecConfig) =>
942942 Effect.gen(function* () {
943943 // Resolve URL → text and parse BEFORE opening a transaction.
@@ -1173,6 +1173,7 @@ export const openApiPlugin = definePlugin((options?: OpenApiPluginOptions) => { · 229 unmodified lines
11731173
11741174 invokeTool: ({ ctx, toolRow, args }) =>
11751175 Effect.gen(function* () {
1176+ const httpClientLayer = options?.httpClientLayer ?? ctx.httpClientLayer;
11761177 // toolRow.scope_id is the resolved owning scope of the tool
11771178 // (innermost-wins from the executor's stack). The matching
11781179 // openapi_operation + openapi_source rows live at the same
@@ -1313,8 +1314,9 @@ export const openApiPlugin = definePlugin((options?: OpenApiPluginOptions) => { · 134 unmodified lines
13131314 // means stale UI state, which is worth surfacing to the caller.
13141315 refreshSource: ({ ctx, sourceId, scope }) => refreshSourceInternal(ctx, sourceId, scope),
13151316
1316− detect: ({ url }) =>
1317+ detect: ({ ctx, url }) =>
13171318 Effect.gen(function* () {
1319+ const httpClientLayer = options?.httpClientLayer ?? ctx.httpClientLayer;
13181320 const trimmed = url.trim();
13191321 if (!trimmed) return null;
13201322 const parsed = yield* Effect.try({