tweaselORG / cyanoacrylate

Toolkit for large-scale automated traffic analysis of mobile apps on Android and iOS.
MIT License
5 stars 1 forks source link

Use standard cache folder instead of `__dirname` for venv and mitmproxy scripts #18

Closed baltpeter closed 1 year ago

baltpeter commented 1 year ago

Putting the venv and mitmproxy scripts into our node_modules folder (relative to __dirname) is unfortunately quite fragile. We've already had a fair amount of breakage due to this and while reviewing #17, I once again noticed this breaking.

For some bizarre reason, __dirname is /home/benni/coding/JS/tweasel/cyanoacrylate/dist/src, even though that folder doesn't exist (the built index.js is in dist, deleting that and the Parcel cache didn't help).

I propose that we instead put this stuff into the system cache folder using global-cache-dir. That feels more idiomatic, anyway.

Additional benefit: If we want to distribute a single executable at some point, there won't be a node_modules folder that we can write to, anyway.

What do you think, @zner0L?

baltpeter commented 1 year ago

One thing to consider: It's plausible that someone might delete this cache directory without re-running the postinstall script, which would break the module. This could already happen with the current implementation, but I feel like it's more likely if we use a cache directory.

Not too hard to work around, though: We can just check whether the necessary files exist and run the postinstall script otherwise.

zner0L commented 1 year ago

Yeah, that seems reasonable to me. I am just not sure where we would put this check. In startAnalysis?

baltpeter commented 1 year ago

I am just not sure where we would put this check. In startAnalysis?

Yeah, that seems reasonable to me.

baltpeter commented 1 year ago

Actually, I went with startTrafficCollection(), since startAnalysis() isn't async and we only need those dependencies for the traffic collection.

baltpeter commented 1 year ago

This change has fixed the CLI for me.

baltpeter commented 1 year ago

Actually, I went with startTrafficCollection(), since startAnalysis() isn't async and we only need those dependencies for the traffic collection.

Okay, never mind. We need to set the PATH up correctly for ensureFrida(), so we do need to make startAnalysis() async.