frida / frida-compile

Compile a Frida script comprised of one or more Node.js modules
Other
188 stars 48 forks source link

Won't compile after importing external node libraries #73

Open dogtopus opened 1 year ago

dogtopus commented 1 year ago

Step to reproduce:

Error:

> frida-agent-test@1.0.0 build
> frida-compile agent/index.ts -o _agent.js -c

TypeError: node.expression.getText is not a function
    at visitCallExpression (file:///home/user/Documents/src/frida-agent-test/node_modules/frida-compile/ext/cjstoesm.js:1577:25)
    at visitNode (file:///home/user/Documents/src/frida-agent-test/node_modules/frida-compile/ext/cjstoesm.js:2633:16)
    at file:///home/user/Documents/src/frida-agent-test/node_modules/frida-compile/ext/cjstoesm.js:2894:33
    at visitNode (file:///home/user/Documents/src/frida-agent-test/node_modules/frida-compile/ext/typescript.js:85139:21)
    at visitEachChildOfParenthesizedExpression (file:///home/user/Documents/src/frida-agent-test/node_modules/frida-compile/ext/typescript.js:85817:32)
    at Object.visitEachChild (file:///home/user/Documents/src/frida-agent-test/node_modules/frida-compile/ext/typescript.js:85389:35)
    at Object.childContinuation (file:///home/user/Documents/src/frida-agent-test/node_modules/frida-compile/ext/cjstoesm.js:2893:47)
    at visitNode (file:///home/user/Documents/src/frida-agent-test/node_modules/frida-compile/ext/cjstoesm.js:2635:20)
    at file:///home/user/Documents/src/frida-agent-test/node_modules/frida-compile/ext/cjstoesm.js:2894:33
    at visitNode (file:///home/user/Documents/src/frida-agent-test/node_modules/frida-compile/ext/typescript.js:85139:21)
bluewave41 commented 1 year ago

Provide a reproduction repo please. This does indeed work as you've described it.

dogtopus commented 1 year ago

@bluewave41 You would also need to delete the lock file and run npm install so it would pull the latest version. frida-agent-example uses an older version by default which isn't affected by this regression.

I think this was introduced in 16.2.0.

Let me know if you still have issue reproducing it.

bluewave41 commented 1 year ago

I see it now.

If it specifically started in 16.2.0 which is most likely the case then it's going to be something in this beast of a commit: https://github.com/frida/frida-compile/commit/487d0281bb93b38c1a2645005a039b8cc297e154#diff-48f38ed4a20115aadfb06657d8d88c8df5c501c4f73b9f44dcce647a35435640

Submodule TypeScript updated 9959 files

Right here is where it looks to initially break down

I'd ran into this issue a couple of times and managed to fix a few of them but I don't think the issues I ran into are related to what you're trying to do.