Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
= GemPlugin: Gem Based Plugin System
GemPlugin is a system that lets your users install gems and lets you load them as additional features to use in your software. It originated from the Mongrel (http://mongrel.rubyforge.org) project but proved useful enough to break out into a separate project.
GemPlugin works by listing the gems installed, and doing a require_gem on any that have the right dependencies. For example, if a gem depends on "gem_plugin" and "mongrel" then it'll load as a Mongrel plugin. This makes it so that users of the plugins only need to gem install (and maybe config a bit), and plugin authors only need to make gems.
== Implementers
To use GemPlugin in your system you only have to require 'gem_plugin' and then use the GemPlugin::Manager.create, GemPlugin::Manager.load, and GemPlugin::Manager.available methods to work with them.
=== Loading Plugins
As an example from Mongrel it's necessary to load plugins that depend on rails after the Rails system is configured, but load other plugins right when Mongrel is ready. To do this we very first do:
GemPlugin::Manager.instance.load "mongrel" => GemPlugin::INCLUDE, "rails" => GemPlugin::EXCLUDE
Later, when it's ready to load Rails plugins as well we do this:
GemPlugin::Manager.instance.load "mongrel" => GemPlugin::INCLUDE
This simply loads any plugins that remain and are ready for use in Rails.
=== Creating Plugins
Creating a plugin is cake:
plug = GemPlugin::Manager.instance.create("/commands/snazzy", "something" => "yeah")
In this case we're making the snazzy command and passing a couple fake options.
=== Finding Available Plugins
Finding plugins is also very easy, you just call GemPlugin::Manager.instance.available and you get a Hash that maps categories to name => class. For example, if I had the "/commands/snazzy" plugin registered above, then I'd get the following:
puts GemPlugin::Manager.instance.available["/commands"].inspect -> { "/snazzy" => Snazzy}
=== Plugins Inside Modules
Plugins that are placed in modules are also lowercased when registered but still retain their module. So, if Snazzy was actually MyModule::Snazzy, then it'd be registered as "/commands/mymodule::snazzy".
== Plugin Authors
People who wish to write gem plugins have a faily easy time of it, but need to know the particular rules for the target system. To keep this example concrete we'll assume you want to write a Mongrel command plugin.
First thing is create your project like normal and setup Rake to make your gem. Your plugin then needs to be created like so:
class Snazzy < GemPlugin::Plugin "/commands" ... end
And place this code in a file you will have RubyGems autorequire (I use lib/init.rb).
Next you need to add the following to whatever Rakefile code you use to create your gem:
spec.add_dependency('gem_plugin', '>= 0.1') spec.add_dependency('mongrel', '>= 0.3.9') spec.autorequire = 'init.rb'
This does three things:
Now, all the users of your plugin have to do is gem install it and then they get the plugin automagically.
People writing GemPlugins for other systems would have to check the documentation from that project to get an idea of what extra requirements might be needed. For example, you'd probably have to depend on another project other that mongrel and most likely have a few more things to configure in your init.rb.
== Plugin Users
Plugin users have it the easiest of all. They simply do:
gem install mongrel_command_snazzy
And that's it. When they run mongrel_rails (given the above example) this snazzy command get loaded automatically without any intervention.
The only thing missing in this release is a way for end users to configure such a plugin. I really think this is the job of the implementers to define.
== Contact
E-mail zedshaw at zedshaw.com and I'll help. Comments about the API are welcome.
FAQs
Unknown package
We found that gem_plugin demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.