I'm analysing arguments/parameters of a function in Javascript that either they are tainted or untainted through a JS library. I divided it in three scenarios. First one is if all the arguments/parameters are tainted then the result will be true. Second is if all args are untainted then result will be false. Third scenario is when some arguments are tainted and some are untainted, I want to ignore this scenario. For the first two scenarios I coded the following lines. If someone can help me with third scenario.
function Shadow(x) {
this.val = x;
}
Shadow.getVal = function(v) {
return Shadow.isShadowed(v) ? v.val : v;
}
Shadow.isShadowed = function(x) {
return x instanceof Shadow;
}
function Taint() {
this._taintStack = [];
this.invokeFunPre = function (iid, f, base, args) {
let isTainted = false;
let n_args = [];
for(let i = 0; i < args.length; i++) {
if (Shadow.isShadowed(args[i])) {
n_args.push(Shadow.getVal(args[i]));
isTainted = true;
} else {
n_args.push(args[i]);
}
}
this._taintStack.push(isTainted);
return {f: f, base: base, args: n_args, skip: false};
};
Aucun commentaire:
Enregistrer un commentaire