Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
bunyan-cassandra
Advanced tools
Bunyan stream for saving logs to Cassandra
npm install bunyan-cassandra
Basic example:
var CassandraStream = require('bunyan-cassandra');
var logger = bunyan.createLogger({
src: true,
name: 'name',
streams: [{
level: 'debug',
stream: new CassandraStream({
hosts: ['localhost'],
keyspace: 'mykeyspace',
username: 'myuser',
password: 'mypass',
query: 'INSERT INTO log (id, message) VALUES(uuid(), ?)',
args: ['msg']
})
}]
});
// this mesage will be saved to cassandra
logger.debug('some log message');
Advanced example:
var CassandraStream = require('bunyan-cassandra');
var logger = bunyan.createLogger({
src: true,
name: 'name',
streams: [{
stream: process.stdout,
level: 'debug'
}, {
type: 'raw',
level: 'debug',
stream: new CassandraStream({
hosts: ['localhost'],
keyspace: 'mykeyspace',
username: 'myuser',
password: 'mypass',
query: 'INSERT INTO log (id, message, ip, date, user, line, file, func) VALUES(uuid(), ?, ?, ?, ?, ?, ?, ?)',
args: ['msg', 'ctx.ip', 'time', 'ctx.session.user.id', 'src.line', 'src.file', 'src.func'],
callback: function (err, res) {
// this callback is optional
// here you can do something with query results
// or catch possible Cassandra errors
},
transform: function (log) {
// add/remove/edit log object
}
})
}]
});
// ctx can be express request object for example
// it is completely up to you, you just need to configure ``query`` and ``args`` option
// to support provided object
logger.debug({
ctx: {
ip: '127.0.0.1',
session: {
user: {
id: 1
}
}
}
},'this is some log message');
You can pass following options
Array with cassandra hosts
default ['localhost']
Name of keyspace to use
default 'logs'
Cassandra username to use
default 'cassandra'
Cassandra password to use
default 'cassandra'
Query for inserting data to Cassandra. This will be executed for each log.
default 'INSERT INTO logs (id) VALUES (uuid())'
Array of object paths. When new log will be added to Cassandra, module will look
for values on provided paths inside args
option, and after that values with
CQL query will be passed to Cassandra, and new record will be added.
For example if your bunyan log entry looks like this:
{
msg: 'this is some log message',
ctx: {
ip: '127.0.0.1',
session: {
id: 2
}
},
level: 20
}
Then if you have CQL query like this:
query: 'INSERT INTO logs (id, msg, ip, sessionid, level) VALUES (uuid(), ?, ?, ?, ?)'
you can populate ?
with values if value of your args
option is something like this:
args: ['msg', 'ctx.ip', 'ctx.session.id', 'level']
default []
After query is executed callback
function will be called (if is defined).
You can catch possible Cassandra errors here, or see result of operation.
default undefined
Each time when new log is received, log will be passed as argument to transform
function, so you will have opportunity to modify raw log data, for example add or remove some fields from log.
transform: function (row) {
// let we say we want date with specific format
row.date = moment(row.time).format('YYYY-MM-DD');
return row;
}
FAQs
Cassandra bunyan stream
The npm package bunyan-cassandra receives a total of 0 weekly downloads. As such, bunyan-cassandra popularity was classified as not popular.
We found that bunyan-cassandra 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 a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.