
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.
lightbright
Advanced tools
An experimental, lightweight module for code tracing, using
the process.binding('async-wrap')
API. For more information
about the API, refer to the existing Node.js
documentation
$ npm install --save lightbright
Lightbright accepts filters which will be notified of all
asynchronous events defined by async-wrap
. Those are: init
,
pre
, post
, destroy
. Each time the filter is called, its
parameter is an object containing information about one of these
events. E.g.
{
uid: 12,
step: 'pre',
timestamp: 1466221549272
}
Add a filter using the addFilter
function. And then activate it.
lightbright.addFilter(myFilter);
lightbright.activate();
Filters are just functions which accept a record
parameter.
const lightbright = require('lightbright');
lightbright.addFilter((record) => fs.writeSync(1, record.toString()));
Records are simply objects that contain the asynchronous trace information.
{
uid: 1,
step: 'init',
handle:
TCP {
bytesRead: 0,
_externalStream: undefined,
fd: -22,
reading: false,
owner: null,
onread: null,
onconnection: null
},
provider: 15,
parent: {
parentUid: null,
parentHandle: null
},
timestamp: 1470251890590
}
Note: Do not execute asyncronous code from within a filter function.
You can deactivate and remove all filters using the deactivate
function.
lightbright.deactivate();
To remove a single filter, use the removeFilter
function.
lightbright.removeFilter(noLongerUsedFilter);
Lightbright comes with some builtin filters that make common processing of the trace data a little simpler. For example, the timing filter aggregates timing data. Use it in your application like so:
const LightBright = require('lightbright');
const Timing = LightBright.builtins.timing;
LightBright.addFilter(Timing.timer);
LightBright.enable();
// Do some async stuff
util.format(Timing.timings())
Ouput of this filter for an HTTP request might look something like this.
[ { location: 'TCP',
stack:
[ ' at TCP.init (/Users/lanceball/src/lightbright/lib/trace_hooks.js:32:3)',
' at createServerHandle (net.js:1180:14)',
' at Server._listen2 (net.js:1224:14)',
' at listen (net.js:1289:10)',
' at Server.listen (net.js:1385:5)',
' at Object.<anonymous> (/Users/lanceball/src/lightbright/example/timing/index.js:18:8)' ],
id: 1,
init: 1470255980229,
pre: 1470255982061,
post: 1470255982061,
elapsed: 0 },
{ location: 'TCP',
stack:
[ ' at TCP.init (/Users/lanceball/src/lightbright/lib/trace_hooks.js:32:3)',
' at createServerHandle (net.js:1180:14)',
' at Server._listen2 (net.js:1224:14)',
' at listen (net.js:1289:10)',
' at Server.listen (net.js:1385:5)',
' at Object.<anonymous> (/Users/lanceball/src/lightbright/example/timing/index.js:18:8)' ],
id: 1,
init: 1470255980229,
pre: 1470255982061,
post: 1470255982061,
elapsed: 0 },
{ location: 'TCP',
stack:
[ ' at TCP.init (/Users/lanceball/src/lightbright/lib/trace_hooks.js:32:3)',
' at createServerHandle (net.js:1180:14)',
' at Server._listen2 (net.js:1224:14)',
' at listen (net.js:1289:10)',
' at Server.listen (net.js:1385:5)',
' at Object.<anonymous> (/Users/lanceball/src/lightbright/example/timing/index.js:18:8)' ],
id: 1,
init: 1470255980229,
pre: 1470255982061,
post: 1470255982061,
elapsed: 0 },
{ location: 'TCP',
stack:
[ ' at TCP.init (/Users/lanceball/src/lightbright/lib/trace_hooks.js:32:3)',
' at createServerHandle (net.js:1180:14)',
' at Server._listen2 (net.js:1224:14)',
' at listen (net.js:1289:10)',
' at Server.listen (net.js:1385:5)',
' at Object.<anonymous> (/Users/lanceball/src/lightbright/example/timing/index.js:18:8)' ],
id: 1,
init: 1470255980229,
pre: 1470255982061,
post: 1470255982061,
elapsed: 0 },
{ location: 'HTTPParser',
stack:
[ ' at HTTPParser.init (/Users/lanceball/src/lightbright/lib/trace_hooks.js:32:3)',
' at new <anonymous> (_http_common.js:159:16)',
' at exports.FreeList.alloc (internal/freelist.js:14:46)',
' at Server.connectionListener (_http_server.js:316:24)',
' at emitOne (events.js:96:13)',
' at Server.emit (events.js:188:7)' ],
id: 7,
init: 1470255982059,
pre: 1470255982164,
post: 1470255982164,
elapsed: 0 },
{ location: 'HTTPParser',
stack:
[ ' at HTTPParser.init (/Users/lanceball/src/lightbright/lib/trace_hooks.js:32:3)',
' at new <anonymous> (_http_common.js:159:16)',
' at exports.FreeList.alloc (internal/freelist.js:14:46)',
' at Server.connectionListener (_http_server.js:316:24)',
' at emitOne (events.js:96:13)',
' at Server.emit (events.js:188:7)' ],
id: 7,
init: 1470255982059,
pre: 1470255982164,
post: 1470255982164,
elapsed: 0 },
{ location: 'HTTPParser',
stack:
[ ' at HTTPParser.init (/Users/lanceball/src/lightbright/lib/trace_hooks.js:32:3)',
' at new <anonymous> (_http_common.js:159:16)',
' at exports.FreeList.alloc (internal/freelist.js:14:46)',
' at Server.connectionListener (_http_server.js:316:24)',
' at emitOne (events.js:96:13)',
' at Server.emit (events.js:188:7)' ],
id: 7,
init: 1470255982059,
pre: 1470255982164,
post: 1470255982164,
elapsed: 0 },
{ location: 'FSReqWrap',
stack:
[ ' at FSReqWrap.init (/Users/lanceball/src/lightbright/lib/trace_hooks.js:32:3)',
' at Object.fs.readFile (fs.js:303:11)',
' at Server.http.createServer (/Users/lanceball/src/lightbright/example/timing/index.js:12:6)',
' at emitTwo (events.js:106:13)',
' at Server.emit (events.js:191:7)',
' at HTTPParser.parserOnIncoming [as onIncoming] (_http_server.js:543:12)' ],
id: 14,
init: 1470255982163,
pre: 1470255982165,
post: 1470255982165,
elapsed: 0 },
{ location: 'FSReqWrap',
stack:
[ ' at FSReqWrap.init (/Users/lanceball/src/lightbright/lib/trace_hooks.js:32:3)',
' at FSReqWrap.readFileAfterOpen [as oncomplete] (fs.js:374:11)' ],
id: 15,
init: 1470255982165,
pre: 1470255982165,
post: 1470255982165,
elapsed: 0 },
{ location: 'FSReqWrap',
stack:
[ ' at FSReqWrap.init (/Users/lanceball/src/lightbright/lib/trace_hooks.js:32:3)',
' at ReadFileContext.read (fs.js:342:11)',
' at FSReqWrap.readFileAfterStat [as oncomplete] (fs.js:398:11)' ],
id: 16,
init: 1470255982165,
pre: 1470255982165,
post: 1470255982166,
elapsed: 1 } ]
This is a work in progress. Don't expect it to remain stable for for any amount of time in the near future.
FAQs
A lightweight module for code tracing using async-wrap
We found that lightbright 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.