-
Notifications
You must be signed in to change notification settings - Fork 3
Description
With #39 we can now have plugins, even user contributed ones. However it may be unclear how this works. For this I want to (eventually) write some documentation.
I'll mark this as low priority for now. I'll use the plugin system myself in the meanwhile and discover any bugs fix and improvements to make.
- Users contributing plugins must be informed about security restrictions (and encouraged not to always go for the most lenient permission.
- See below for the available
IPermissionoptions forpermissions.xml - Create documentation (not just for plugin contributors) on how a Plugin is loaded in it's own process through the PluginHost application.
- Plugins are communicated to from the Host (Key2Joy) through Object Reference Marshalling
- Plugins communicate back with events through a named pipe (seperate for each plugin). See
Core/Key2Joy.Contracts/Plugins/Remoting/RemoteEventSubscriber.cs
- Add documentation and an example that show that a WPF User Control can be created by the plugin, to allow for custom Trigger/Action options
Finish some example plugins:
- Make
Key2Joy.Plugin.HelloWorldan example that needs minimal permissions and simply shows how to log to a file - Make
Key2Joy.Plugin.Midian example how to use a third-party library to provide additional Triggers - Make
Key2Joy.Plugin.Ffmpegan example how to add scripting functionality through a third-party library - Make a plugin that adds a scripting Language, consider moving Lua/JS to such a plugin.
Some more thoughts:
If we move a default plugin (like a scripting language) to a plugin, it would be nice if those were enabled by default. This would probably require me signing the plugin so it can't be replaced with a malicious one that is then auto-enabled.
I'm talking a lot about security and whatever, but I feel like I've tunnel visioned to the point where I'm just happy the plugin system works. I'd love some outside eyes to peer over the code, find problems and help me make this system more safe/robust. I won't want to release a version 1.0.0 if I'm not certain it's not technically safe.
Available IPermission options for permissions.xml
A plugin can include a permissions.xml to specify which permissions it desires. When a user enables a plugin they must agree to grant this. A checksum of the permissions file is stored with the enabled plugin. If the permissions file suddenly changes the plugin is not loaded and disabled.
<PermissionSet>
<!-- unrestricted (potentially dangerous) -->
<IPermission
class="Key2Joy.Contracts.Plugins.SecurityOverride, Key2Joy.Contracts, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"
Unrestricted="true" />
<!-- unrestricted file access anywhere on your device -->
<IPermission
class="System.Security.Permissions.FileIOPermission, mscorlib, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"
Unrestricted="true" />
<!-- file reading access anywhere on your device -->
<IPermission
class="System.Security.Permissions.FileIOPermission, mscorlib, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"
Access="Read" />
<!-- file writing access anywhere on your device -->
<IPermission
class="System.Security.Permissions.FileIOPermission, mscorlib, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"
Access="Write" />
<!-- file appending access anywhere on your device -->
<IPermission
class="System.Security.Permissions.FileIOPermission, mscorlib, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"
Access="Append" />
<!-- file and folder path discovery access anywhere on your device -->
<IPermission
class="System.Security.Permissions.FileIOPermission, mscorlib, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"
Access="PathDiscovery" />
<!-- file full access anywhere on your device -->
<IPermission
class="System.Security.Permissions.FileIOPermission, mscorlib, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"
Access="AllAccess" />
<!-- unrestricted access to load external assemblies (potentially dangerous) -->
<!-- Needed for the test runner and Assembly.LoadFrom (for plugins that want to use external libraries like FFmpeg) -->
<IPermission
class="System.Security.Permissions.EnvironmentPermission, mscorlib, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"
Unrestricted="true" />
</PermissionSet>