-
Notifications
You must be signed in to change notification settings - Fork 39.1k
feat(plugins): allow component paths within repository boundary #308776
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -147,6 +147,8 @@ type PluginEntry = IAgentPlugin; | |
| interface IPluginSource { | ||
| readonly uri: URI; | ||
| readonly fromMarketplace: IMarketplacePlugin | undefined; | ||
| /** Repository root that serves as the boundary for component path resolution. */ | ||
| readonly repositoryUri?: URI; | ||
| /** Called when remove is invoked on the plugin */ | ||
| remove(): void; | ||
| } | ||
|
|
@@ -203,7 +205,7 @@ export abstract class AbstractAgentPluginDiscovery extends Disposable implements | |
| if (!seenPluginUris.has(key)) { | ||
| seenPluginUris.add(key); | ||
| const format = await detectPluginFormat(source.uri, this._fileService); | ||
| plugins.push(this._toPlugin(source.uri, format, source.fromMarketplace, () => source.remove())); | ||
| plugins.push(this._toPlugin(source.uri, format, source.fromMarketplace, source.repositoryUri, () => source.remove())); | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -222,7 +224,7 @@ export abstract class AbstractAgentPluginDiscovery extends Disposable implements | |
| } | ||
| } | ||
|
|
||
| private _toPlugin(uri: URI, format: IPluginFormatConfig, fromMarketplace: IMarketplacePlugin | undefined, removeCallback: () => void): IAgentPlugin { | ||
| private _toPlugin(uri: URI, format: IPluginFormatConfig, fromMarketplace: IMarketplacePlugin | undefined, repositoryUri: URI | undefined, removeCallback: () => void): IAgentPlugin { | ||
| const key = uri.toString(); | ||
| const existing = this._pluginEntries.get(key); | ||
| if (existing) { | ||
|
|
@@ -258,7 +260,7 @@ export abstract class AbstractAgentPluginDiscovery extends Disposable implements | |
| } | ||
|
|
||
| const paths = parseComponentPathConfig(section); | ||
| const dirs = resolveComponentDirs(uri, defaultPath, paths); | ||
| const dirs = resolveComponentDirs(uri, defaultPath, paths, repositoryUri); | ||
| for (const d of dirs) { | ||
| const watcher = this._fileService.createWatcher(d, { recursive: false, excludes: [] }); | ||
| reader.store.add(watcher); | ||
|
|
@@ -632,9 +634,12 @@ export class MarketplaceAgentPluginDiscovery extends AbstractAgentPluginDiscover | |
| continue; | ||
| } | ||
|
|
||
| const repositoryUri = this._pluginRepositoryService.getRepositoryUri(entry.plugin.marketplaceReference, entry.plugin.marketplaceType); | ||
|
|
||
| sources.push({ | ||
| uri: stat.resource, | ||
| fromMarketplace: entry.plugin, | ||
| repositoryUri, | ||
|
Comment on lines
+637
to
+642
|
||
| remove: () => { | ||
| this._enablementModel.remove(stat.resource.toString()); | ||
| this._pluginMarketplaceService.removeInstalledPlugin(entry.pluginUri); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
boundaryUricurrently replaces the containment check target unconditionally (boundary = boundaryUri ?? pluginUri). If a caller accidentally passes a boundary that is not an ancestor ofpluginUri(different cache dir, different authority/scheme, etc.), thenisEqualOrParent(resolved, boundary)will reject all manifest paths — including ones that are valid within the plugin itself (notably whenexclusive: true).To make this API safer and avoid surprising regressions, consider only using
boundaryUriwhenpluginUriis equal to or contained by it (e.g.boundaryUri && isEqualOrParent(pluginUri, boundaryUri)), otherwise fall back topluginUri. Adding a small unit test for the non-ancestor boundary case would help lock this in.