| Index: pkg/analysis_server/lib/src/plugin/plugin_manager.dart
|
| diff --git a/pkg/analysis_server/lib/src/plugin/plugin_manager.dart b/pkg/analysis_server/lib/src/plugin/plugin_manager.dart
|
| index 01e26286effe3480b6c17c5250826d95a0e991a9..ebcf5a61a3a0fce5ac37b94925f6aa87336d7a7f 100644
|
| --- a/pkg/analysis_server/lib/src/plugin/plugin_manager.dart
|
| +++ b/pkg/analysis_server/lib/src/plugin/plugin_manager.dart
|
| @@ -261,6 +261,11 @@ class PluginManager {
|
| final InstrumentationService instrumentationService;
|
|
|
| /**
|
| + * The list of globs used to match plugin paths that have been whitelisted.
|
| + */
|
| + List<Glob> _whitelistGlobs;
|
| +
|
| + /**
|
| * A table mapping the paths of plugins to information about those plugins.
|
| */
|
| Map<String, PluginInfo> _pluginMap = <String, PluginInfo>{};
|
| @@ -291,7 +296,13 @@ class PluginManager {
|
| * running plugins will be handled by the given [notificationManager].
|
| */
|
| PluginManager(this.resourceProvider, this.byteStorePath, this.sdkPath,
|
| - this.notificationManager, this.instrumentationService);
|
| + this.notificationManager, this.instrumentationService) {
|
| + // TODO(brianwilkerson) Figure out the right list of plugin paths.
|
| + _whitelistGlobs = <Glob>[
|
| + new Glob(resourceProvider.pathContext.separator,
|
| + '**/analyze_angular/tools/analysis_plugin')
|
| + ];
|
| + }
|
|
|
| /**
|
| * Add the plugin with the given [path] to the list of plugins that should be
|
| @@ -300,6 +311,9 @@ class PluginManager {
|
| */
|
| Future<Null> addPluginToContextRoot(
|
| analyzer.ContextRoot contextRoot, String path) async {
|
| + if (!_isWhitelisted(path)) {
|
| + return;
|
| + }
|
| PluginInfo plugin = _pluginMap[path];
|
| bool isNew = plugin == null;
|
| if (isNew) {
|
| @@ -475,6 +489,16 @@ class PluginManager {
|
| return Future.wait(_pluginMap.values.map((PluginInfo info) => info.stop()));
|
| }
|
|
|
| + /**
|
| + * Whitelist all plugins.
|
| + */
|
| + @visibleForTesting
|
| + void whitelistEverything() {
|
| + _whitelistGlobs = <Glob>[
|
| + new Glob(resourceProvider.pathContext.separator, '**/*')
|
| + ];
|
| + }
|
| +
|
| WatchEventType _convertChangeType(watcher.ChangeType type) {
|
| switch (type) {
|
| case watcher.ChangeType.ADD:
|
| @@ -493,6 +517,18 @@ class PluginManager {
|
| }
|
|
|
| /**
|
| + * Return `true` if the plugin with the given [path] has been whitelisted.
|
| + */
|
| + bool _isWhitelisted(String path) {
|
| + for (Glob glob in _whitelistGlobs) {
|
| + if (glob.matches(path)) {
|
| + return true;
|
| + }
|
| + }
|
| + return false;
|
| + }
|
| +
|
| + /**
|
| * Return the execution path and .packages path associated with the plugin at
|
| * the given [path], or `null` if there is a problem that prevents us from
|
| * executing the plugin.
|
|
|