Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shelljs EXEC does not work when running a pre-compiled binary application #1155

Closed
dathtd119 opened this issue Apr 15, 2024 · 4 comments
Closed
Labels
exec Issues specific to the shell.exec() API question Question from a user (which may not require code/documentation changes to the project)

Comments

@dathtd119
Copy link

Node version:

v18.19.1

ShellJS version (the most recent version/Github branch you see the bug on):

0.8.5

Operating system:

WSL2 Kali Linux

Description of the bug:

  • When I try using exec() with a pre-compile binary from nmap-formatter (the binary file was around 9mb), it worked fine.
  • But when I used exec() with cvemap (the binary file was around 24mb), it just stops, even though I can run it normally on the terminal it owns.

Example ShellJS command to reproduce the error:

let shell = require('shelljs')
async function getCveMapDetails(cveId) {
    console.log(`Executing cvemap tool for CVE: ${cveId}`);
    try {
        const output = await shell.exec(`${CVEMAP_DIR} -id ${cveId} -json`);
        console.log(`cvemap tool output: ${output}`);
        return JSON.parse(output);
    } catch (error) {
      console.error(`Error fetching CVE details for ${cveId}: ${error}`);
      return {};
    }
  }

//try the get cve details
const cveDetails = await getCveMapDetails('CVE-2010-2075');
console.log("get cve details successful.");
//Console log:
Executing cvemap tool for CVE: CVE-2010-2075
//It just stand right here
@dathtd119
Copy link
Author

I tried that cvemap with this for help page and it run smoothly, but not other function.

shell.exec(`${CVEMAP_DIR} -h`)

The CVEMAP output when performing something is output line by line, is that an issue with shelljs?

@nfischer
Copy link
Member

shell.exec() waits for the process to finish, then it returns all the output. I think shell.exec() can also print output line by line, but it won't terminate until the command you're running finishes.

If that's not what you want, you can try using shell.exec() in async mode. Check out the README for how to do that.

@nfischer nfischer added question Question from a user (which may not require code/documentation changes to the project) exec Issues specific to the shell.exec() API labels Apr 16, 2024
@dathtd119
Copy link
Author

I changed to spawnSync , using it directly from 'child_process', and it just worked, Imma perform it with Shelljs again in the future.

Also this error was done, but not using ShellJS, should I close this issue?

@nfischer nfischer closed this as not planned Won't fix, can't repro, duplicate, stale May 5, 2024
@nfischer
Copy link
Member

nfischer commented May 5, 2024

Closing as not reproducible. Let me know if you switch back to shell.exec() and see this error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
exec Issues specific to the shell.exec() API question Question from a user (which may not require code/documentation changes to the project)
Projects
None yet
Development

No branches or pull requests

2 participants