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.
composite-modules
Advanced tools
yarn users:
yarn add composite-modules
npm users:
npm install composite-modules
Importing:
import { ModulesContainer } from 'composite-modules'
You should use the default ModuleContainer and add all the modules you created to it.
const unamedComposite = new ModuleUnamed('unamed');
const anotherUnamedComposite = new AnotherModuleUnamed('anotherUnamed');
const simpleModule = new SimpleUnamedModule('simpleUnamed');
anotherUnamedComposite.add(simpleModule);
unamedComposite.add(anotherUnamedComposite);
ModulesContainer.add(unamedComposite);
void ModulesContainer.init();
ModulesContainer.events.on('ready', (modules) => {
// Here we ensure that all of your modules have been loaded and you can access them.
modules.collection.use('anotherUnamed').anotherFunction()
...
})
You need to extend the CompositeModule or SimpleModule modules, creating from them the modules you want to add to the module tree.
Remembering that the CompositeModule can have child modules. These will normally be loaded into the structure, as long as they are added correctly.
export class ModuleUnamed extends CompositeModule {
// You can add as many properties as you need...
private myProperty: any;
public myPropertyTwo: any;
// As a standard you always need to pass a name as parameter.
constructor(name: string, yourParams: any) {
super(name); // Must always pass name as super call.
// Your constructor definitions goes here...
...
}
async load (): Promise<void> {
this.beautyLogs.info('Loading this structures...');
// Your loading definitions goes here...
...
this.beautyLogs.success('Loaded this structures...');
}
async unload (): Promise<void> {
this.beautyLogs.info('Unoading this structures...');
// Your unload definitions goes here...
...
this.beautyLogs.success('Unloaded this structures...');
}
}
I recommend using this.beautyLogs
for logs, it displays logs in a pattern and pretty like this (with colors):
2021-09-22T15:28:41.218Z (system) [Container]: [*] System is starting...
2021-09-22T15:28:41.220Z (info) [SimpleUnamedModule]: Loading this structures...
2021-09-22T15:28:41.220Z (success) [SimpleUnamedModule]: Loaded this structures...
2021-09-22T15:28:41.220Z (info) [AnotherModuleUnamed]: Loading this structures...
2021-09-22T15:28:41.221Z (info) [ModuleUnamed]: Loading this structures...
2021-09-22T15:28:41.221Z (success) [ModuleUnamed]: Loaded this structures...
👤 Iago Calazans (💼 Senior Node | TypeScript Developer)
FAQs
A module loader structure implemented using Composite Pattern.
We found that composite-modules 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.