GitGuardian / ggshield

Find and fix 360+ types of hardcoded secrets and 70+ types of infrastructure-as-code misconfigurations.
https://gitguardian.com
MIT License
1.57k stars 138 forks source link

`ggshield scan docker` fails with missing path error when run from the Docker image #924

Open cdupuis opened 1 week ago

cdupuis commented 1 week ago

Environment

Describe the bug

I expect the following command to not fail:

❯ docker run -it -v /var/run/docker.sock:/var/run/docker.sock -e GITGUARDIAN_API_KEY=${GITGUARDIAN_API_KEY} gitguardian/ggshield ggshield secret scan docker alpine
Saving docker image...
Error: [Errno 2] No such file or directory: 'docker'

Re-run the command with --verbose to get a stack trace.
fnareoh commented 1 week ago

Hi, thank you for creating this issue. I believe this is due to the docker command not being available inside your docker. The error occurs when trying to run this command to download the docker image alpine, but we will improve the error by catching it and printing something more explicit. :smile:

cdupuis commented 1 week ago

I believe this is due to the docker command not being available inside your docker.

This is your official Docker image, not my image. So shouldn't you add the Docker CLI to the ggshield image in that case to make this error disappear?

fnareoh commented 1 week ago

Ah yes sorry I got confused, yes we will !

cdupuis commented 1 week ago

I can confirm that running ggshield from an image built from the following Dockerfile works as expected:

FROM gitguardian/ggshield:latest

RUN \
    apt-get update \
    && apt-get install -y --no-install-recommends ca-certificates curl gnupg \
    && apt-get clean \
    && rm -rf /var/lib/apt/lists/* \
    && curl -fsSL https://get.docker.com | sh
fnareoh commented 1 week ago

Thanks a lot :pray: , I doubled checked and opened a PR. We will just wait for the return of @agateau-gg (our main maintainer, returning probably next Wednesday) to validate !