frida / frida-compile

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

Error "entrypoint must be inside the project root" #82

Open federicodotta opened 1 year ago

federicodotta commented 1 year ago

Hi,

First of all, as usual, thanks for your great work.

I use frida-compile in a tool I wrote. Unfortunately, last versions of frida-compile raise the exception "entrypoint must be inside the project root".

I looked in the code and I found the cause. My tool does not compile the JS files from their folder, but from an external folder using the absolute path of frida compile, of the input JS file and of the output JS file (example: ""/ABS_PATH/frida-compile" -o "/ABS_PATH/output.js" "/ABS_PATH/input.js""). In the recent versions of frida-compile there is the a check that throws an error if "endpoint" does not starts with "projectRoot", but "projectRoot" is derived from the current working directory and causes my issue.

The code I mentioned is the following one:

cli.ts (lines 21-22)

    const projectRoot: string = process.cwd();
    const entrypoint: string = program.args[0];

compiler.ts (lines 214-228)

function deriveEntrypoint(options: Options): EntrypointName {
    const { projectRoot, entrypoint } = options;

    const input = crosspath.isAbsolute(entrypoint) ? entrypoint : crosspath.join(projectRoot, entrypoint);
    if (!input.startsWith(projectRoot)) {
        throw new Error("entrypoint must be inside the project root");
    }

    let output = input.substring(projectRoot.length);
    if (output.endsWith(".ts")) {
        output = output.substring(0, output.length - 2) + "js";
    }

    return { input, output };
}

Compilation outside the project root can cause troubles with recent frida-compile versions?

Thank you.

Federico

rotsen93 commented 10 months ago

hola federico, encontraste alguna solucion para esto, a mi me pasa igual.

RealVolAnd commented 9 months ago

I has facing with same issue. What is this mean?