mercedes-benz / sechub

SecHub provides a central API to test software with different security tools.
https://mercedes-benz.github.io/sechub/
MIT License
258 stars 58 forks source link

Unable to launch server as described in Getting Started 1.2.3 #2414

Open peterkir opened 11 months ago

peterkir commented 11 months ago

When launching from git bash on windows, I'm not able to successfully launch the server container. https://mercedes-benz.github.io/sechub/latest/sechub-getting-started.html#start-gosecpds-server

#17 [sechub sechub  8/11] COPY --chmod=755 install-java/debian/ /sechub/install-java/
#17 DONE 0.1s

#18 [sechub sechub  9/11] RUN cd "/sechub/install-java/" &&     ./install-java.sh "openjdk" "17" jre
#18 0.712 /usr/bin/env: 'sh\r': No such file or directory
#18 0.712 /usr/bin/env: use -[v]S to pass options in shebang lines
#18 ERROR: process "/bin/sh -c cd \"$SECHUB_FOLDER/install-java/\" &&     ./install-java.sh \"$JAVA_DISTRIBUTION\" \"$JAVA_VERSION\" jre" did not complete successfully: exit code: 127
------
 > [sechub sechub  9/11] RUN cd "/sechub/install-java/" &&     ./install-java.sh "openjdk" "17" jre:
0.712 /usr/bin/env: 'sh\r': No such file or directory
0.712 /usr/bin/env: use -[v]S to pass options in shebang lines
------
failed to solve: process "/bin/sh -c cd \"$SECHUB_FOLDER/install-java/\" &&     ./install-java.sh \"$JAVA_DISTRIBUTION\" \"$JAVA_VERSION\" jre" did not complete successfully: exit code: 127
Jeeppler commented 11 months ago

@peterkir thank you for the bug report.

I think the culprit is the newline character under windows \r: /usr/bin/env: 'sh\r'. Can you provide more information about your git bash environment? We would want to reproduce the issue.

Did you use:

peterkir commented 11 months ago

I'm using git bash on win 10

Jeeppler commented 11 months ago

What command/tool did you use to clone the SecHub repository?

Jeeppler commented 11 months ago

Here is what I did:

  1. I installed Git Bash
  2. Cloned the repo: git clone https://github.com/mercedes-benz/sechub.git
  3. Switched into the SecHub folder cd sechub
  4. Ran ./sechub-pds-solutions/gosec/05-start-single-sechub-network-docker-compose.sh
$ ./sechub-pds-solutions/gosec/05-start-single-sechub-network-docker-compose.sh
Environment file does not exist.
Creating default environment file .env for you.
Environment file does not exist.
Creating default environment file .env-single for you.
Starting single container.
./sechub-pds-solutions/gosec/05-start-single-sechub-network-docker-compose.sh: line 20: docker: command not found

While installing git bash I got the following option: git-bash-line-endings

If I check the global git configuration, I can see that the core.autocrlf=true option is set to true.

$ git config --list
diff.astextplain.textconv=astextplain
filter.lfs.clean=git-lfs clean -- %f
filter.lfs.smudge=git-lfs smudge -- %f
filter.lfs.process=git-lfs filter-process
filter.lfs.required=true
http.sslbackend=openssl
http.sslcainfo=C:/Program Files/Git/mingw64/ssl/certs/ca-bundle.crt
core.autocrlf=true
core.fscache=true
core.symlinks=false
pull.rebase=false

It might be necessary to set core.autocrlf=false, because the scripts are executed in a Linux container environment. I assume the \r newline endings are added automatically under Windows and cause the error you are seeing: 0.712 /usr/bin/env: 'sh\r': No such file or directory.

Furthermore, you might have noticed, that I did get an error:

./sechub-pds-solutions/gosec/05-start-single-sechub-network-docker-compose.sh: line 20: docker: command not found

I expected this error to happen since I did not install Docker. It seems you installed Docker. Can you let me know how you installed Docker?