Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1233)

Unified Diff: pkg/analysis_server/lib/src/plugin/plugin_manager.dart

Issue 2897653002: Add the ability to whitelist plugins (Closed)
Patch Set: Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | pkg/analysis_server/test/analysis_abstract.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.
« no previous file with comments | « no previous file | pkg/analysis_server/test/analysis_abstract.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698