taintable/utils/attrFinder.js
// get the name of the a variable (base or standalone)
get the name of the a variable (base or standalone)
get the name of the a variable ( base or standalone )
function read_standalone_or_base(node, path, cmd){
    if (node.hasOwnProperty("property")){
        while (node.object.type === "MemberExpression") node = node.object;
        if (node.object.type === "Identifier"){
            path.push( node.object.name );
        } else if (node.object.type === "ThisExpression"){
            path.push("this");
        } else {
            if (node.object.type === "CallExpression") {
                cmd.res.push(-1);
                return;
            }
            if (node.object.type === "Literal") {
                cmd.res.push(-1);
                return;
            }
            if (node.object.type === "NewExpression") {
                cmd.res.push(-1);
                return;
            }
            if (node.object.type === "ArrayExpression") {
                cmd.res.push(-1);
                return;
            }
            if (node.object.type === "AssignmentExpression"){
                cmd.res.push(-1);
                return;
            }
            if (node.object.type === "ConditionalExpression"){
                cmd.res.push(-1);
                return;
            }
            console.log(tynt.Red("[x] read_standalone_or_base error: unknown object type " + JSON.stringify(node.object.type)));
            return;
        }
        cmd.res.push(path.join("."));
        return;
    }else{
        if (JSON.stringify(node.loc) === JSON.stringify(cmd.loc)){
            path.push(node.name)
            cmd.res.push(path.join(".")); 
            return;
        }else{
            console.log(tynt.Red("[x] read_standalone_or_base error: not a standalone object iid " + JSON.stringify(node)));
        }
    }
}
function read_standalone_or_base ( node , path , cmd ) { if ( node . hasOwnProperty ( "property" ) ) { while ( node . object . type === "MemberExpression" ) node = node . object ; if ( node . object . type === "Identifier" ) { path . push ( node . object . name ) ; } else if ( node . object . type === "ThisExpression" ) { path . push ( "this" ) ; } else { if ( node . object . type === "CallExpression" ) { cmd . res . push ( - 1 ) ; return ; } if ( node . object . type === "Literal" ) { cmd . res . push ( - 1 ) ; return ; } if ( node . object . type === "NewExpression" ) { cmd . res . push ( - 1 ) ; return ; } if ( node . object . type === "ArrayExpression" ) { cmd . res . push ( - 1 ) ; return ; } if ( node . object . type === "AssignmentExpression" ) { cmd . res . push ( - 1 ) ; return ; } if ( node . object . type === "ConditionalExpression" ) { cmd . res . push ( - 1 ) ; return ; } console . log ( tynt . Red ( "[x] read_standalone_or_base error: unknown object type " + JSON . stringify ( node . object . type ) ) ) ; return ; } cmd . res . push ( path . join ( "." ) ) ; return ; } else { if ( JSON . stringify ( node . loc ) === JSON . stringify ( cmd . loc ) ) { path . push ( node . name ) cmd . res . push ( path . join ( "." ) ) ; return ; } else { console . log ( tynt . Red ( "[x] read_standalone_or_base error: not a standalone object iid " + JSON . stringify ( node ) ) ) ; } } }
get the name of the a variable (base or standalone)
get the name of the a variable ( base or standalone )
// find the exact match of the loc  // this is a member expr  // find "a" in a.b.c.d.e.f  // return results here  // this is a standalone var