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.
@jovercao/config-loader
Advanced tools
该工具用于自动加载不同级别的配置文件,并将其合并成运行所需的配置文件。
配置文件均采用JSON的格式,配置共有以下四个:
加载配置覆盖优先级: cwdfile > userfile > appfile
安装:
npm install @jovercao/config-loader
调用:
import load from '@jovercao/config-loader'
const defaultConfig = {
settings1: '这是设置1',
settings2: '这是设置2'
}
const variants = {
var1: '这是变量1的值',
var2: '这是变量2的值'
}
let config
if (process.env.NODE_ENV === 'developement') {
config = load({
default: defaultConfig,
variants,
appfile: 'app.config.dev.json',
pwdfile: '.appname.config.dev.json',
userfile: '.appname.config.dev.json'
})
} else {
config = load({
default: defaultConfig,
variants,
appfile: 'app.config.json',
pwdfile: '.appname.config.json',
userfile: '.appname.config.json'
})
}
查看范例
加载配置文件中的配置
options
选项
options.default
默认配置,通过对象传递,而非路径
options.variants
object 类型,存放变量的对象,加载器将用该对象中的属性varName
替换值为字符串的配置项中格式为${varName}
的内容。
options.appfile
string 类型,指定应用程序配置文件的文件名,默认文件名为app.config.json
options.userfile
string 类型,指定用户配置文件的文件名,不指定时将不加载用户配置文件
options.cwdfile
string 类型,指定工作路径配置文件的文件名,不指定时将不加载,不指定时将不加载工作路径配置文件
defaultConfig
object 类型,默认参数,可空,同options.default
FAQs
We found that @jovercao/config-loader 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.