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.
@hapiness/config
Advanced tools
Configuration module based on node-config & js-yaml libraries.
yarn
or npm
it in your package.json
$ npm install --save @h@hapiness/config
or
$ yarn add @hapiness/config
"dependencies": {
"@hapiness/config": "^1.2.1",
//...
}
//...
./config/default.yml
:
my:
config: test
Node.js Script
:
import { Config } from '@hapiness/config';
if (Config.has('my.config')) {
console.log(Config.get('my.config')); // output: 'test'
}
./config/default.yml
:
external_service:
baseUrl: 'test'
mymodule_database:
provider: postgresql
hostname: localhost
user: pguser
password: keyboard cat
Hapiness module
:
// external-module.ts
import {
HapinessModule,
CoreModuleWithProviders,
InjectionToken,
Inject,
Optional,
} from '@hapiness/core';
import { ConfigHelper, ConfigInterface } from '@hapiness/config';
@HapinessModule({
...
})
export class ExternalModule {
static setConfig(config: ConfigInterface): CoreModuleWithProviders {
return {
module: ExternalModule,
providers: [ConfigHelpers.getProvider('mymodule_database', config)]
};
}
}
export class Service {
constructor(@Optional() @Inject(ConfigHelper.getInjectionToken('mymodule_database')) config) { // @Optional to not throw errors if config is not passed
...
}
}
// main-module.ts
import {
HapinessModule,
} from '@hapiness/core';
import { ExternalModule } from 'external-module';
import { Config } from '@hapiness/config';
@HapinessModule({
...
imports: [ ExternalModule.setConfig(Config.get('mymodule_database')) ]
})
...
Hapiness service
:
// main-module.ts
import {
HapinessModule,
} from '@hapiness/core';
import { ConfigHelper, Config } from '@hapiness/config';
import { MyCustomService } from './services';
@HapinessModule({
...
providers: [
ConfigHelper.getProvider('external_service'),
MyCustomService,
...
]
})
...
import { Injectable } from '@hapiness/core';
import { ConfigInterface } from '@hapiness/config';
// my-custom-service.ts
@Injectable()
class MyCustomService {
private _baseUrl: string;
constrcutor(
@Inject(ConfigHelper.getInjectionToken('external_service'))
private _config: ConfigInterface
) {}
connect() {
this._baseUrl = this._config.get<string>('baseUrl');
}
}
...
get()
was a falsy value and wrongly interpreted as undefinedpeerDependencies
config
Config
module.Julien Fauville | Antoine Gomez | Sébastien Ritz | Nicolas Jessel |
Copyright (c) 2018 Hapiness Licensed under the MIT license.
FAQs
Configuration Library to use it inside Hapiness framework
The npm package @hapiness/config receives a total of 1 weekly downloads. As such, @hapiness/config popularity was classified as not popular.
We found that @hapiness/config 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.