
Research
/Security News
Weaponizing Discord for Command and Control Across npm, PyPI, and RubyGems.org
Socket researchers uncover how threat actors weaponize Discord across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.
Read program options from config files, environment variables and command line arguments.
const {config} = require('any-cfg')
const cfg = config({
configDir: '.',
configFile: '.myapprc',
envPrefix: 'MYAPP_',
})
.options({
HOST: {type: 'string', short: 'h'},
PORT: {type: 'number', short: 'p', required: true},
DEBUG: {type: 'boolean'},
HELP: {type: 'boolean'},
})
const {
HOST = 'localhost',
PORT,
DEBUG,
HELP,
} = cfg.parse()
if (HELP) {
cfg.help()
process.exit(0)
}
server.listen(PORT, HOST)
Specify options using format FOO_BAR
(upper snake case).
Each option can have type, required flag and short name.
Supported types are: string, number, boolean,
list (array of strings) and map (object of strings).
First, options will be read from config files starting from configDir
and going upwards.
First file with basename configFile
will be parsed.
It must include an extension (either .json
or .toml
).
Parser expects options to be formatted as foo_bar
(lower snake case).
Then, options can be overwritten by environment variables.
Upper snake case format with optional envPrefix
is expected.
Lists and maps are reset, not appended.
Format for lists is comma or semicolon separated string.
For maps it's a list of key-value pairs separated by =
.
Lastly, options can be overwritten by command line arguments.
The format is --foo-bar
(lower kebab case) or -x
for short options.
Short options can be grouped (-abc
).
Boolean options should be either --opt
for true and --no-opt
for false.
To provide a list, specify the same option multiple times.
For map specify a list of key-value pairs separated by =
.
Special _
option is automatically added, which contains a list of the rest of command line arguments.
FAQs
Config loader
The npm package any-cfg receives a total of 0 weekly downloads. As such, any-cfg popularity was classified as not popular.
We found that any-cfg 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 researchers uncover how threat actors weaponize Discord across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.
Security News
Socket now integrates with Bun 1.3’s Security Scanner API to block risky packages at install time and enforce your organization’s policies in local dev and CI.
Research
The Socket Threat Research Team is tracking weekly intrusions into the npm registry that follow a repeatable adversarial playbook used by North Korean state-sponsored actors.