Secure-Compliance-Solutions-LLC / GVM-Docker

Greenbone Vulnerability Management Docker Image with OpenVAS
https://securecompliance.gitbook.io/projects/
MIT License
246 stars 91 forks source link

[Bug] #292

Closed rvisc closed 2 years ago

rvisc commented 2 years ago

Describe the bug I am trying to use gvm-cli via socket, but in the image I am using (21.4.3-v1-data-full) there is no gvmd.sock. I tried to create gvmd.sock in /data/gvmd/ using the following Python script python3 -c "import socket as s; sock = s.socket(s.AF_UNIX); sock.bind('/data/gvmd/gvmd.sock')" but if I run any gvm-cli command e.g., gvm-cli socket ---socketpath /data/gvmd/gvmd.sock -xml "<get_tasks/>" the system always returns ERROR:gvmtools.cli:Could not connect to socket /data/gvmd/gvmd.sock I also tried the latest docker images with same result.

To Reproduce

  1. download latest docker image;
  2. run it;
  3. open console;
  4. install python and gvm-tools
  5. run as gvm user the following command: gvm-cli socket ---socketpath /data/gvmd/gvmd.sock -xml "<get_tasks/>"

Expected behavior The xml response from gvm-cli.

Dexus commented 2 years ago

please read the docs before you open a bug report.

rvisc commented 2 years ago

I followed the instructions in the doc you gave me (https://securecompliance.gitbook.io/projects/) but: 1) in the start.sh file present in your last docker images (I checked "latest" image and "21.4.3-v1-data-full" image) there is no instruction [su -c "gvmd --listen=0.0.0 --port=9390"]; 2) you should review the following instruction because there is an error su -c "gvmd --unix-socket=/usr/var/run/gvmd.sock/gvmd.sock" gvm 3) if (after creating /usr/var/run/) I try to execute the instruction su -c "gvmd --unix-socket=/usr/var/run/gvmd.sock" gvm I still get an error:

INFO exited: init (exit status 1; not expected) I wrote the command right after the following code snippet

${SUPVISD} start gvmd
if [ "${DEBUG}" == "Y" ]; then
${SUPVISD} status gvmd
fi

and gvmd daemon is running (I checked). 4) the current variables values used by start.sh are:

export SUPVISD=${SUPVISD:-supervisorctl}
export USERNAME=${USERNAME:-${GVMD_USER:-admin}}
export PASSWORD=${PASSWORD:-${GVMD_PASSWORD:-adminpassword}}
export PASSWORD_FILE=${PASSWORD_FILE:-${GVMD_PASSWORD_FILE:-none}}
export TIMEOUT=${TIMEOUT:-15}
export DEBUG=${DEBUG:-N}
export RELAYHOST=${RELAYHOST:-smtp}
export SMTPPORT=${SMTPPORT:-25}
export AUTO_SYNC=${AUTO_SYNC:-false}
export HTTPS=${HTTPS:-true}
export CERTIFICATE=${CERTIFICATE:-none}
export CERTIFICATE_KEY=${CERTIFICATE_KEY:-none}
export TZ=${TZ:-Etc/UTC}
export SSHD=${SSHD:-false}
export DB_PASSWORD=${DB_PASSWORD:-none}
export DB_PASSWORD_FILE=${DB_PASSWORD_FILE:-none}
export OPT_PDF=${OPT_PDF:-0}

5) if I try to run su -c "gvmd --unix-socket=/usr/var/run/gvmd.sock" gvm in console after starting the docker container, nothing happens (no error message, no .sock file created).

May you please let me know HOW to proceed?

Dexus commented 2 years ago

Hi, If you need help with gvmd, ask at Greenbone community. We support only what we provide, no modifications that you need.

If you don‘t know how to manage this, you should work on your knowledge of the product and system.

This is nothing against you, but a general problem.

Regards Josef

Von meinem iPhone gesendet

Am 20.10.2021 um 12:10 schrieb rvisc @.***>:

 I followed the instructions in the doc you gave me (https://securecompliance.gitbook.io/projects/) but:

in the start.sh file present in your last docker images (I checked "latest" image and "21.4.3-v1-data-full" image) there is no instruction [su -c "gvmd --listen=0.0.0 --port=9390"]; you should review the following instruction because there is an error su -c "gvmd --unix-socket=/usr/var/run/gvmd.sock/gvmd.sock" gvm if (after creating /usr/var/run/) I try to execute the instruction su -c "gvmd --unix-socket=/usr/var/run/gvmd.sock" gvm I still get an error: INFO exited: init (exit status 1; not expected) I wrote the command right after the following code snippet

${SUPVISD} start gvmd if [ "${DEBUG}" == "Y" ]; then ${SUPVISD} status gvmd fi and gvmd daemon is running (I checked). 4) the current variables values used by start.sh are:

export SUPVISD=${SUPVISD:-supervisorctl} export USERNAME=${USERNAME:-${GVMD_USER:-admin}} export PASSWORD=${PASSWORD:-${GVMD_PASSWORD:-adminpassword}} export PASSWORD_FILE=${PASSWORD_FILE:-${GVMD_PASSWORD_FILE:-none}} export TIMEOUT=${TIMEOUT:-15} export DEBUG=${DEBUG:-N} export RELAYHOST=${RELAYHOST:-smtp} export SMTPPORT=${SMTPPORT:-25} export AUTO_SYNC=${AUTO_SYNC:-false} export HTTPS=${HTTPS:-true} export CERTIFICATE=${CERTIFICATE:-none} export CERTIFICATE_KEY=${CERTIFICATE_KEY:-none} export TZ=${TZ:-Etc/UTC} export SSHD=${SSHD:-false} export DB_PASSWORD=${DB_PASSWORD:-none} export DB_PASSWORD_FILE=${DB_PASSWORD_FILE:-none} export OPT_PDF=${OPT_PDF:-0} if I try to run su -c "gvmd --unix-socket=/usr/var/run/gvmd.sock" gvm in console after starting the docker container, nothing happens (no error message, no .sock file created). May you please let me know HOW to proceed?

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub, or unsubscribe.

Dexus commented 2 years ago

Only as a sidenode, if you build the image yourself, you should edit the https://github.com/Secure-Compliance-Solutions-LLC/GVM-Docker/blob/master/config/supervisord.conf file.

rvisc commented 2 years ago

Hi, thanks for your clarifications. Anyway, I noticed that, unlike your previous docker images, Greenbone Security Assistant now always starts the automatic data update whenever a container is created. Is there any way to disable this automatic update mechanism? Consider that I have already disabled the daily synchronisation activated via crontab and the one activated by start.sh.

Dexus commented 2 years ago

https://github.com/Secure-Compliance-Solutions-LLC/GVM-Docker/blob/master/scripts/start.sh#L198 is uncomment? You

Also you comment out https://github.com/Secure-Compliance-Solutions-LLC/GVM-Docker/blob/master/scripts/start.sh#L305-L308 ?

rvisc commented 2 years ago

Basically, when I start the container based on your docker image, I load a custom version of the start.sh file in which I have commented out everything that activates synchronisation:

# echo "gvmd --migrate"
# su -c "gvmd --migrate" gvm
...
# Sync NVTs, CERT data, and SCAP data on container start
# See this as a super fallback to have at least some data, even if it is then out of date.
#/sync-initial.sh
...
# ${SUPVISD} start GVMUpdate
# if [ "${DEBUG}" == "Y" ]; then
#   ${SUPVISD} status GVMUpdate
# fi
...
Dexus commented 2 years ago

then there should no automatic update. If it is still there, you doing something wrong in your configuration on start of the container.