
Research
Two Malicious Rust Crates Impersonate Popular Logger to Steal Wallet Keys
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.
彩虹桥,被用作此架构名,意在进入神域的通道。而此架构,是开发所有nodejs
应用的主架构。它实现了进程化管理以及微服务插件的概念,具有非常强大的扩展性和丰富的生命周期供开发者创建自己的应用服务。
npm install bifroster --save
const path = require('path');
const Bifrost = require('bifroster');
const bifrost = new Bifrost({
cwd: __dirname,
agents: ['agent']
});
Bifrost-project
├── package.json
├── index.js
├── app.js (可选)
├── agent.js (可选)
├── plugin.js (可选)
├── app
| ├── router
│ | └── index.js
│ ├── controller
│ | └── home.js
│ ├── service (可选)
│ | └── user.js
│ ├── middleware (可选)
│ | └── response_time.js
new Bifrost({ ...options });
number
最大启动子进程个数string
项目目录array
agent进程列表,格式为 agents:['agent']
object
启动安全协议的配置 {key, cert}
组合,使用https
协议number
服务启动端口string
服务启动ip[
'agent:ready',
'ready',
'agent:exit',
'exit'
].forEach(name => {
bifrost.on(name, (...args) => {
bifrost.console.log(`[${bifrost.type}]:`, name, ...args);
});
});
请看这里
微服务部署核心类。
/agent.js =>
const Bifrost = require('bifroster');
module.exports = agent => {
[
'receive:message',
'master:ready',
'agent:beforeCreate',
'agent:created',
'agent:beforeDestroy',
'agent:destroyed'
].forEach(name => {
agent.on(name, (...args) => {
agent.console.log('[agent]:', name, ...args);
})
});
}
在项目根目录下有一个文件plugin.js
。
const path = require('path');
module.exports = {
test: {
enable: true,
env: '*',
path: path.resolve(__dirname, 'plugins', 'test'),
// package: 'component',
agent: '*',
config: {}
},
test2: {
enable: true,
env: '*',
path: path.resolve(__dirname, 'plugins', 'test2'),
// package: 'component',
agent: '*',
config: {}
}
}
参数:
boolean
是否可用 默认true
array
运行环境 默认全环境string
插件文件夹 与package
互斥string
插件模块 与path
互斥array
运行在哪个agent上 默认全agent每个插件分2个入口:
微服务中可以理解为为整个一个工程,每条业务线都是流水作业。所以我们通过不断询问流水线负责人来确认是否要进入此微服务来获取数据。如果负责人现在的状态是locked
,而且他答应处理(可能由于业务太多忙不过来),那么他会将消息暂时存入堆栈,等到空闲了再处理,相当于任务的调度。
实际情况下,我们采用路由中间件的模式来处理这些请求,从而返回数据。
首先来认识4个生命周期:
module.exports = component => {
[
'task:start',
'task:done',
'server:start',
'server:destroy'
].forEach(name => {
component.on(name, (...args) => {
console.log('[agent]:', '[channel]:', name, ...args);
})
});
component.use(async(ctx, next) => {
ctx.send({
a: 1,
b: 2,
c: ctx.body
});
await next();
})
}
我们可以看到,里面的数据都是通过中间件模式被返回的,这个在使用nodejs的开发者是最清楚如何使用,这里我就不再多说。
注意:这里的
ctx.send
只有一个参数,意思说明,现在的数据需要按原路返回给请求者。 同样的,ctx.reply
就是ctx.send
只有一个参数时候的作用
/app.js
生命周期如下:
app.js
module.exports = app => {
[
'wroker:beforeStart',
'wroker:started',
'wroker:beforeStop',
'wroker:stoped',
'master:ready',
'receive:message'
].forEach(name => {
app.on(name, (...args) => {
app.console.log('[worker]:', name, ...args);
})
});
}
You can see how to write through the examples in the test folder, and you can test the class by using the npm run test
command.
Bifrost is MIT licensed.
FAQs
nodejs base dev framework
We found that bifroster 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
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.
Research
A malicious package uses a QR code as steganography in an innovative technique.
Research
/Security News
Socket identified 80 fake candidates targeting engineering roles, including suspected North Korean operators, exposing the new reality of hiring as a security function.