Skip to content

Certain commands not streaming full output #727

Open
@TheFlash2k

Description

@TheFlash2k

I have the following code setup to run a simple command in my Sandbox template:

def do_run(cmd):
    out = sbx.commands.run(
        cmd, timeout=0, 
        on_stdout=lambda data: print('stdout: ', data),
        on_stderr=lambda data: print('stderr: ', data)
    )
    return out.stdout or out.stderr

Now, I am trying to run a few particular tools such as katana, nuclei (most of the tools are written in Go-Lang).

The problem I am facing is, whenever I try to invoke any of the tools (particularly the tools provided by projectdiscovery or tools written in Golang), they just get stuck. And HARD-STUCK. The only thing I see is their Ascii art and then they just don't run.

Image

In the logs

Image

Whereas, if in the same sandbox, I try to run the command manually:

Image

Another weird issue I face when the command runs for more than 5 mins is (even though the sandbox timeout is 1 hour).

Image

One of the fixes that I did was inside the sandbox_sync/commands/command.py on Line 232.

- args=["-l", "-c", cmd],
+ args=["-c", cmd],

The most weird part is, it did fix the issue for once, but after some time, the fix stopped working. At this point I am lost debugging this issue further and would require some assistance. Also, I have tried other scripts that were written in python, those seem to work fine without any issue. Even tried rustscan and it did work. Only happens for tools written in golang which is absurd because they're elf binaries anyways.

Already tried with and without 2>&1 (I just did this to redirect stderr to stdout for testing)

If I try to run this with quotes around the command itself, I'm assuming it adds the quotes itself so it would do double quotes and hence sets the blob as one whole command and therefore fails

Image

For further context, the e2b.Dockerfile is:

FROM ubuntu:latest

ENV DEBIAN_INTERACTIVE=1
ENV TZ=Asia/Karachi

RUN apt-get update && \
        apt-get install -y golang && \
    apt-get clean && rm -rf /var/lib/apt/lists*

RUN go install -v github.com/projectdiscovery/nuclei/v3/cmd/nuclei@latest
RUN CGO_ENABLED=1 go install github.com/projectdiscovery/katana/cmd/katana@latest && rm -rf /root/.cache/go*

COPY scripts /usr/bin/

WORKDIR /root

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions