-
Notifications
You must be signed in to change notification settings - Fork 402
Make sure that extensions are bundled with the package they claim to be. #9981
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: master
Are you sure you want to change the base?
Changes from all commits
1c9d477
569f427
29e8ec7
b00b953
68e69d5
ae1ee0a
e14a0c1
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 |
|---|---|---|
|
|
@@ -78,6 +78,14 @@ void _validateDirectoryContents(String packagePath) { | |
| throw FileSystemException('${packageDirectory.path} directory not found'); | ||
| } | ||
|
|
||
| final pubspecFile = File(path.join(packageDirectory.path, 'pubspec.yaml')); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the additional validations added to this file seem useful, but they also seem out of scope of this PR. Are these somehow related to resolving the security bug?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think AGY added this because extensions need to be included in a Dart package, right? |
||
| if (!pubspecFile.existsSync()) { | ||
| throw const FileSystemException(''' | ||
| A pubspec.yaml file is required, but none was found. | ||
| See ${ValidateExtensionCommand.docUrl}. | ||
| '''); | ||
| } | ||
|
|
||
| final devtoolsExtensionDir = Directory( | ||
| path.join(packageDirectory.path, 'extension', 'devtools'), | ||
| ); | ||
|
|
@@ -109,6 +117,17 @@ An extension/devtools/config.yaml file is required, but none was found. | |
| See ${ValidateExtensionCommand.docUrl}. | ||
| '''); | ||
| } | ||
|
|
||
| // Ensure the extension's name is a valid identifier. | ||
| final configYaml = _configAsMap(packagePath); | ||
| final configName = configYaml['name']; | ||
| final underscoresAndLetters = RegExp(r'^[a-z0-9_]*$'); | ||
| if (configName is! String || !underscoresAndLetters.hasMatch(configName)) { | ||
| throw StateError( | ||
| 'The "name" field in config.yaml should only contain lowercase letters, ' | ||
| 'numbers, and underscores but instead was "$configName".', | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| Map<String, Object?> _configAsMap(String packagePath) { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.