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.
Writing a Node app? Need to know the function backtrace? Don't want to compile C++ code? Use Traceback.
Traceback provides a normal JavaScript array of the execution stack frames. You can see function names, line numbers, and other useful stuff.
Traceback is available from NPM.
$ npm install traceback
example.js
var traceback = require('../traceback');
function start() { first() }
function first() { second() }
var second = function() { last() }
function last() {
var stack = traceback();
console.log('I am ' + stack[0].name + ' from file ' + stack[0].file)
for(var i = 1; i <= 3; i++)
console.log(' ' + i + ' above me: ' + stack[i].name + ' at line ' + stack[i].line);
}
start();
Output:
I am last from file example.js
1 above me: second at line 5
2 above me: first at line 4
3 above me: start at line 3
Simply calling traceback()
gives you the stack, with the current function in position 0.
Stack frame objects have normal V8 CallSite objects as prototypes. All those methods will work. You can also call traceback.raw()
to get the exact stack made by V8.
But traceback()
's stack frame objects have convenient attribute names:
path
file ("example.js"
)this
in the functionthis
; the name of the constructor function (Object, ReadStream, etc.)CallSite
that ran eval()
, if this frame is an evalthis
eval()
callnew
) callThey also work correctly in JSON.stringify()
.
Tests use node-tap. Clone this Git repository, run npm install
and then run the tests through npm:
$ npm test
> traceback@0.3.1 test /Users/jhs/src/traceback
> tap test/
ok test/api.js ...................................... 326/326
ok test/fail.js ....................................... 36/36
ok test/format.js ....................................... 7/7
ok test/readme.js ....................................... 2/2
total ............................................... 371/371
ok
Apache 2.0
FAQs
Easy access to the call stack, written in pure JavaScript
The npm package traceback receives a total of 79 weekly downloads. As such, traceback popularity was classified as not popular.
We found that traceback 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.