eliasgranderubio / dagda

a tool to perform static analysis of known vulnerabilities, trojans, viruses, malware & other malicious threats in docker images/containers and to monitor the docker daemon and running docker containers for detecting anomalous activities
Apache License 2.0
1.16k stars 163 forks source link

Unable to use python3 dagda.py vuln --init #78

Closed liangxiaoxiaoxiao closed 4 years ago

liangxiaoxiaoxiao commented 4 years ago

Short description

Hi,

I was trying to do docker-compose exec dagda python3 dagda.py vuln --init

But the following error appears: <2020-04-21 04:29:15,356> <HTTPConnectionPool(host="'127.0.0.1'", port=5000): Max retries exceeded with url: /v1/vuln/init (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f7ea5408fd0>: Failed to establish a new connection: [Errno -2] Name does not resolve',))> Traceback (most recent call last): File "/usr/local/lib/python3.6/site-packages/urllib3/connection.py", line 159, in _new_conn (self._dns_host, self.port), self.timeout, **extra_kw) File "/usr/local/lib/python3.6/site-packages/urllib3/util/connection.py", line 57, in create_connection for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM): File "/usr/local/lib/python3.6/socket.py", line 745, in getaddrinfo for res in _socket.getaddrinfo(host, port, family, type, proto, flags): socket.gaierror: [Errno -2] Name does not resolve

Reproduction steps

I used docker-compose to deploy dagda. First, I downloaded the entire project to the local centos7 virtual machine, and then unzipped,Run the following commands in sequence:

  1. docker-compose pull 2.docker-compose build
  2. docker-compose up -d Then I got two running containers,There were not too many abnormal mistakes during the period, which prevented the container from starting

Expected results

The resulting container is as follows: Name Command State Ports

dagda python dagda.py start -s 0 ... Up 0.0.0.0:5000->5000/tcp
vulndb docker-entrypoint.sh mongod Up 0.0.0.0:27017->27017/tcp

View related processes on this machine: [root@centos dagda-master]# ps -ef | grep dagda root 2212 2196 0 10:44 ? 00:00:04 python dagda.py start -s 0.0.0.0 -p 5000 -m vulndb -mp 27017 root 2266 2212 0 10:44 ? 00:00:00 python dagda.py start -s 0.0.0.0 -p 5000 -m vulndb -mp 27017 root 2267 2212 0 10:44 ? 00:00:03 python dagda.py start -s 0.0.0.0 -p 5000 -m vulndb -mp 27017 root 2268 2212 0 10:44 ? 00:00:03 python dagda.py start -s 0.0.0.0 -p 5000 -m vulndb -mp 27017 root 4504 3512 0 12:37 pts/1 00:00:00 grep --color=auto dagda

On which platforms did you notice this:

docker version : Docker version 1.13.1, build cccb291/1.13.1 docker-compose version : docker-compose version 1.25.0, build 0a186604 hostnamectl: Static hostname: centos Icon name: computer-vm Chassis: vm Machine ID: cfe7d820a0254cd4a02769c7ed967f18 Boot ID: fbfbb4ebe55242f593c6671d7828ddc8 Virtualization: vmware Operating System: CentOS Linux 7 (Core) CPE OS Name: cpe:/o:centos:centos:7 Kernel: Linux 3.10.0-1062.el7.x86_64 Architecture: x86-64 Firewall and selinux are off

Solution

I hope I can use this command in docker-compose mode python3 dagda.py vuln --init And can complete the detection and use of dagda tools

ps: I have seen other issues about this issue, and I saw the three steps of the inspection you have inscribed, But it seems that this problem cannot be solved,There is currently no other way to solve it, sincerely hope you can help me

liangxiaoxiaoxiao commented 4 years ago

I suspect that it may be caused by my python and pip versions not being installed correctly.

liangxiaoxiaoxiao commented 4 years ago

Hello, I hope you can help me see this problem that can't run python3 dagda.py vuln --init command, because I use docker-compose for deployment, but it seems that this does not take effect. Lived, tried my own ending, changed the environment and the like, but there will still be similar errors

liangxiaoxiaoxiao commented 4 years ago

I tried to add the native resolution in the dagda container, but the problem has not been solved, and a new error has occurred requests.exceptions.ConnectionError: HTTPConnectionPool (host = "'127.0.0.1'", port = 5000): Max retries exceeded with url: / v1 / vuln / init-status (Caused by NewConnectionError ('<urllib3.connection.HTTPConnection object at 0x7f3b9ce07f28>: Failed to establish a new connection: [Errno -3] Try again ',)) Can you help to see how this error should be resolved? There are already many stuck installations, there is currently no good way, and retrying has no effect, so I plan to give up the compose installation first to see if it succeeds

liangxiaoxiaoxiao commented 4 years ago

Later, when I used pip3 to install on the local machine, I found the command: export DAGDA_HOST = '127.0.0.1' Then executing echo $ DAGDA_HOST outputs127.0.0.1 itself, which reminds me of HTTPConnectionPool (host = "'127.0.0.1'", port = 5000) Looking at the string here carefully, it may be that a'127.0.0.1' is passed in instead of 127.0.0.1, so I reinstalled it using compose, The environment variables declared in yml are as follows:

10     environment:
 11       - DAGDA_HOST=127.0.0.1
 12       - DAGDA_PORT=5000

This stuck due to my inexperience with yaml wasted a lot of time, but fortunately the problem was solved

The result is:

[root @ localhost dagda-master] # docker-compose exec dagda / bin / sh -c 'python3 dagda.py vuln --init'
{
    "msg": "Accepted the init db request"
}

It seems to be good, let me close this question first, thanks