History

Remove implicit GitHub connection token from git sources

Rhys Sullivan committed 4 months ago

Commit da4f37c1 parent 628d2d71 file · +4 −17Browse files

Unified · Split

packages/plugins/apps/src/plugin/apps-plugin.ts+4−17
@@ -245,20 +245,9 @@ const appRegistrationErrorToDiagnostic = (error: unknown): SyncDiagnostic => { · 244 unmodified lines
245245 const tokenItemId = (slug: string): ProviderItemId =>
246246 ProviderItemId.make(`apps/source-tokens/${slug}`);
247247
248−const gitHubConnectionToken = (ctx: PluginCtx<AppsStore>): Effect.Effect<string | null, unknown> =>
249− Effect.gen(function* () {
250− const connections = yield* ctx.connections.list({
251− integration: IntegrationSlug.make("github"),
252− });
253− const connection = connections.find((item) => item.owner === "user") ?? connections[0];
254− if (!connection) return null;
255− return yield* ctx.connections.resolveValue({
256− owner: connection.owner,
257− integration: connection.integration,
258− name: connection.name,
259− });
260− });
261−
248+// A source authenticates only with its own explicitly provided token. No
249+// implicit credential sharing: a stored GitHub connection must never leak
250+// into git fetches the user did not tie to it.
262251 const gitTokenFor = (
263252 ctx: PluginCtx<AppsStore>,
264253 config: Extract<AppSourceConfig, { readonly kind: "git" }>,
@@ -270,9 +259,7 @@ const gitTokenFor = ( · 5 unmodified lines
270259 ProviderItemId.make(config.tokenItemId),
271260 );
272261 }
273− const url = yield* parseGitSourceUrl(config.url).pipe(Effect.result);
274− if (Result.isFailure(url) || url.success.hostname.toLowerCase() !== "github.com") return null;
275− return yield* gitHubConnectionToken(ctx);
262+ return null;
276263 });
277264
278265 const activeToolNamesFor = (

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t