Can't get function name in invokeFun/invokeFunPre
freetom opened this issue · 2 comments
I'm trying to write an analysis that will run on node js apps. I have to filter for certain function invocations.
So I started by printing functions names using API invokeFunPre
and accessing f.name
that should contain the name of the function documentation
When I run with node jalangi2-master/src/js/commands/jalangi.js --inlineIID --inlineSource --analysis sample_anal.js node_app/sample1.js node_app/input
I get as output some function names correctly but not all of them. For example require('child_process').exec
is not logged instead an empty string is written on the output as his name.
Update: I discovered that even typing require('child_process').exec.name
on node console return ''
so at this point I guess it's not a jalangi issue, it's a javascript issue mozilla fun name
How could I distinguish functions during the invokeFunPre/invokeFun callbacks? any idea?
Reproduce:
rep.zip
Are the functions of interest user-defined or predefined by the native environment? You need different solutions for the two cases.
For user-defined functions, I record their identity during #declare when they are first allocated.
For predefined functions, I know their names up front and record their identity when my analysis is initialized:
var forbiddenFunctions = [];
forbiddenFunctions.push(require('child_process').exec));
...
this.declare = function (iid, name, val, ...){
if(typeof val === 'function' && shouldBeForbidden(???)){
forbiddenFunctions.push(val);
}
}
thanks, solved!
var functions = {};
functions[require('child_process').exec]='exec';
this.invokeFun = function(iid, f, base, args, isConstructor, isMethod){
if(functions[f]!=null)
console.log(functions[f])
};
}