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.
extensioner
Advanced tools
Extensioner is responsible for managing apps modules. Scalable apps become easy
Usually applications should be split into smaller logical parts called modules. A problem appears when each module should be configured in multiple places. And when there is lot of different modules, configuring each of them separately became a challenge.
This library is responsible for managing all app modules. You only initialize everything once and then just register and unregister new and old modules.
In each module lets create init file
someCustomModuleA init file:
//modules/someCustomModuleA/index.js
export default {
properties: {
customPropertyA: "customValueAA",
customPropertyB: "customValueAB"
},
events: {
customEventA: () => "customResponseFromEventAA",
customEventB: () => "customResponseFromEventAB"
}
}
As you can see this is just an object with properties : properties
and events
someCustomModuleB init file:
//modules/someCustomModuleB/index.js
import { Extension } from "extensioner";
export default class SomeCustomModuleB extends Extension{
constructor(someInitOptions) {
super();
this.setProperty("customPropertyA", "customValueBA");
this.setProperty("customPropertyC", "customValueBC");
this.onCustomEventA = this.onCustomEventA.bind(this);
this.setEventListener("customEventA", this.onCustomEventA);
this.onCustomEventC = this.onCustomEventC.bind(this);
this.setEventListener("customEventC", this.onCustomEventC);
}
onCustomEventA (initValue) {
return "customResponseFromEventBA";
}
onCustomEventC (initValue) {
return "customResponseFromEventBC";
}
}
In above init file we created class which extends from Extension
.
someCustomModuleC init file:
//modules/someCustomModuleC/index.js
export default function someCustomModuleC(someInitOptions) {
return {
properties: {
customPropertyB: "customValueBC",
customPropertyC: "customValueCC"
},
events: {
customEventB: () => "customResponseFromEventCB",
customEventC: () => "customResponseFromEventCC"
}
}
}
In above init file we created function which will return extension object
Lets create manager instance and register modules
//index.js
import { Manager } from "extensioner";
import someCustomModuleA from "./modules/someCustomModuleA/index.js";
import SomeCustomModuleB from "./modules/someCustomModuleB/index.js";
import someCustomModuleC from "./modules/someCustomModuleC/index.js";
const manager = new Manager();
manager
.registerExtension("someCustomModuleNameA", someCustomModuleA)
.registerExtension("someCustomModuleNameB", new SomeCustomModuleB())
.registerExtension("someCustomModuleNameC", someCustomModuleC());
Lets prepare event and call it.
const event = manager.createEvent("customEventA");
const responses = event();
/**
* responses is equal:
* [
* "customResponseFromEventAA",
* "customResponseFromEventBA"
* ]
*/
Lets prepare event with async event resolver
import { asyncListCompose } from "extensioner";
const event = manager.createEvent("customEventB", asyncListCompose);
event()
.then(responses => {
/**
* responses is equal:
* [
* "customResponseFromEventAB",
* "customResponseFromEventCB"
* ]
*/
});
Lets get property values from all modules
manager.getExtensionsWithProperty("customPropertyA").forEach(extension => {
extension.getProperty("customPropertyA")
})
Creates new manager
Each module should have one root class with all settings and this class should extend Extension
Allow to register/add any new extension and return same manager instance. Second argument can be instance of Extension class
OR
Allow to register/add any new extension and return same manager instance.
Second argument is simple object with properties: properties
and events
When onlyActive
flag is true it will return all active extensions joints for previously registered extensions
When flag is false then it will return all extensions.
When onlyActive
flag is true it will return array of active extension joints with specific property
When flag is false then it will return all extensions with specific property
When onlyActive
flag is true it will return array of active extension joints with specific event listener
When flag is false then it will return all extensions with specific event listener
Return true if extension with ext ensionInstanceName exist and is active. Otherwise false
Returns true if extension with extensionInstanceName exists.
Disable extension with undefinedextensionInstanceName name then it will return true. If extension doesn't exist it will return false
Enable extension with extensionInstanceName name then it will return true. If extension doesn't exist it will return false
Return extension joint by its name or null if doesn't exist.
Return object where keys are extension joints names, and values are extensions properties values
Create event function. Next step is to call this function to trigger event. Response from compose function
const event = manager.createEvent("onRenderHeader", (extensions, eventName, value) => { extensions.map(extension => extension.getEventListener(eventName)(value)) });
event()
.then(response => {
//do something with responses
})
composeFunction is function which compose responses from corresponding event handler.
function composeFunction(extensions: <Extension>Array, eventName: String, value: any): any
This function will get :
By default is used syncListCompose
function which will call sync all event handlers, returns response which will be fulfilled with array of responses.
Available functions :
This is object containing reference to Manager and to Extension, It also have name. It is created only in manager when extension is registered
Return true when extension is enabled
Enable extension
Disable extension
Returns extension
Returns extension name
Returns manager
Create new extension. ExtensionData is simple object with properties: properties
and events
.
Add new property to module
Check if module has property.
Return property value.
Add new event listener
Check if module has event Listener.
Return event handler.
MIT
FAQs
Extensioner is responsible for managing apps modules. Scalable apps become easy
We found that extensioner 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.