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.
zhike-consul
Advanced tools
a simple consul client
const Consul = require('zhike-consul');
const keys = ['orderPrivate', 'mq', 'userService'];
const host = '127.0.0.1';
const port = 8500;
const env = 'development';
const timeout = 3000;
const output = false;
// 1.初始化consul
let consul = new Consul(keys, host, port, global, { timeout, output });
// 2.加载相关配置
consul.pull(env).then(function(data) {
/**
data = {
CFG: {
orderPrivate: {port: 6002, timeout: 10},
mq: {user: 'test', pass: 'test'},
userService: {url: 'http://api.dev.smartstudy.com/user'}
},
config: {
port: 6002,
timeout: 10,
mq: {user: 'test', pass: 'test'},
userService: {url: 'http://api.dev.smartstudy.com/user'}
}
}
*/
/** 每个key的配置信息会默认挂载在global的CFG对象下
global.CFG = data.CFG
*/
/** global的config对象会以私有配置为准,把其余的key的配置信息平铺在一起
global.config = data.config;
*/
// 3.启动HTTP Server
let express = require('express');
let app = express();
let mq = amqplib.connect('amqp://' + config.mq.user + ':' + config.mq.pass + '@' + config.mq.host + ':' + config.mq.port);
app.listen(config.port);
})
Initialize a new Consul client
var Consul = require('zhike-consul');
var consul = new Consul(keys, host, port, global, { timeout: 3000, output: false });
Get config values.
consul.pull('development').then(function(data) {
console.log(data.CFG.redis.port); // 6379
console.log(data.config.redis.port); // 6379
// 或直接用global对象CFG和config
console.log(config.redis.port); // 6379
console.log(CFG.redis.port); // 6379
})
Register current service
consul.register(data).then(function() {
console.log('success');
})
Get ip address of consul service is running
consul.getNodeIp().then(function(data) {
console.log(data); // 172.16.3.2
})
npm test
FAQs
a simple consul client
The npm package zhike-consul receives a total of 11 weekly downloads. As such, zhike-consul popularity was classified as not popular.
We found that zhike-consul 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.