DefectDojo / django-DefectDojo

DevSecOps, ASPM, Vulnerability Management. All on one platform.
https://defectdojo.com
BSD 3-Clause "New" or "Revised" License
3.5k stars 1.48k forks source link

socket.gaierror: [Errno -2] Name or service not known - Getting the error while importing the vulnerabilities from the sonarqube to the defect dojo #10365

Open Nsai1997 opened 4 weeks ago

Nsai1997 commented 4 weeks ago

Hi team, I am encountering the error socket.gaierror: [Errno -2] Name or service not known while importing the vulnerabilities from the sonarqube to the defect dojo

image

Can you please help me in this.

These are the few logs

django-defectdojo-2351-uwsgi-1 | File "/usr/local/lib/python3.11/socket.py", line 962, in getaddrinfo django-defectdojo-2351-uwsgi-1 | for res in _socket.getaddrinfo(host, port, family, type, proto, flags): django-defectdojo-2351-uwsgi-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ django-defectdojo-2351-uwsgi-1 | socket.gaierror: [Errno -2] Name or service not known django-defectdojo-2351-uwsgi-1 | django-defectdojo-2351-uwsgi-1 | The above exception was the direct cause of the following exception: django-defectdojo-2351-uwsgi-1 | django-defectdojo-2351-uwsgi-1 | Traceback (most recent call last):I even django-defectdojo-2351-uwsgi-1 | File "/usr/local/lib/python3.11/site-packages/rest_framework/views.py", line 506, in dispatch django-defectdojo-2351-uwsgi-1 | response = handler(request, *args, **kwargs) django-defectdojo-2351-uwsgi-1

kiblik commented 4 weeks ago

@Nsai1997, thank you for asking. However, this is not a bug in DD. Name or service not known means: I'm not able to translate host to IP. Here are possible reasons:

Nsai1997 commented 3 weeks ago

I have provided the correct url and ApI key and even it is showing it has access to the sonar projects.But only while importing I facing the above issue

kiblik commented 3 weeks ago

Can you provide more logs (to see full stacktrace) for better investigation.

Nsai1997 commented 3 weeks ago

Please find some more logs lgs.txt

kiblik commented 3 weeks ago

This would be enough


django-defectdojo-2351-uwsgi-1  | [10/Jun/2024 08:36:53] ERROR [django.request:241] Internal Server Error: /finding/bulk
django-defectdojo-2351-uwsgi-1  | Traceback (most recent call last):
django-defectdojo-2351-uwsgi-1  |   File "/usr/local/lib/python3.11/site-packages/kombu/utils/functional.py", line 32, in __call__
django-defectdojo-2351-uwsgi-1  |     return self.__value__
django-defectdojo-2351-uwsgi-1  |            ^^^^^^^^^^^^^^
django-defectdojo-2351-uwsgi-1  | AttributeError: 'ChannelPromise' object has no attribute '__value__'
django-defectdojo-2351-uwsgi-1  |
django-defectdojo-2351-uwsgi-1  | During handling of the above exception, another exception occurred:
django-defectdojo-2351-uwsgi-1  |
django-defectdojo-2351-uwsgi-1  | Traceback (most recent call last):
django-defectdojo-2351-uwsgi-1  |   File "/usr/local/lib/python3.11/site-packages/kombu/connection.py", line 472, in _reraise_as_library_errors
django-defectdojo-2351-uwsgi-1  |     yield
django-defectdojo-2351-uwsgi-1  |   File "/usr/local/lib/python3.11/site-packages/kombu/connection.py", line 459, in _ensure_connection
django-defectdojo-2351-uwsgi-1  |     return retry_over_time(
django-defectdojo-2351-uwsgi-1  |            ^^^^^^^^^^^^^^^^
django-defectdojo-2351-uwsgi-1  |   File "/usr/local/lib/python3.11/site-packages/kombu/utils/functional.py", line 318, in retry_over_time
django-defectdojo-2351-uwsgi-1  |     return fun(*args, **kwargs)
django-defectdojo-2351-uwsgi-1  |            ^^^^^^^^^^^^^^^^^^^^
django-defectdojo-2351-uwsgi-1  |   File "/usr/local/lib/python3.11/site-packages/kombu/connection.py", line 934, in _connection_factory
django-defectdojo-2351-uwsgi-1  |     self._connection = self._establish_connection()
django-defectdojo-2351-uwsgi-1  |                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
django-defectdojo-2351-uwsgi-1  |   File "/usr/local/lib/python3.11/site-packages/kombu/connection.py", line 860, in _establish_connection
django-defectdojo-2351-uwsgi-1  |     conn = self.transport.establish_connection()
django-defectdojo-2351-uwsgi-1  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
django-defectdojo-2351-uwsgi-1  |   File "/usr/local/lib/python3.11/site-packages/kombu/transport/pyamqp.py", line 203, in establish_connection
django-defectdojo-2351-uwsgi-1  |     conn.connect()
django-defectdojo-2351-uwsgi-1  |   File "/usr/local/lib/python3.11/site-packages/amqp/connection.py", line 324, in connect
django-defectdojo-2351-uwsgi-1  |     self.transport.connect()
django-defectdojo-2351-uwsgi-1  |   File "/usr/local/lib/python3.11/site-packages/amqp/transport.py", line 129, in connect
django-defectdojo-2351-uwsgi-1  |     self._connect(self.host, self.port, self.connect_timeout)
django-defectdojo-2351-uwsgi-1  |   File "/usr/local/lib/python3.11/site-packages/amqp/transport.py", line 172, in _connect
django-defectdojo-2351-uwsgi-1  |     entries = socket.getaddrinfo(
django-defectdojo-2351-uwsgi-1  |               ^^^^^^^^^^^^^^^^^^^
django-defectdojo-2351-uwsgi-1  |   File "/usr/local/lib/python3.11/socket.py", line 962, in getaddrinfo
django-defectdojo-2351-uwsgi-1  |     for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
django-defectdojo-2351-uwsgi-1  |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
django-defectdojo-2351-uwsgi-1  | socket.gaierror: [Errno -2] Name or service not known
django-defectdojo-2351-uwsgi-1  |
django-defectdojo-2351-uwsgi-1  | The above exception was the direct cause of the following exception:
django-defectdojo-2351-uwsgi-1  |
django-defectdojo-2351-uwsgi-1  | Traceback (most recent call last):
django-defectdojo-2351-uwsgi-1  |   File "/usr/local/lib/python3.11/site-packages/django/core/handlers/exception.py", line 56, in inner
django-defectdojo-2351-uwsgi-1  |     response = get_response(request)
django-defectdojo-2351-uwsgi-1  |                ^^^^^^^^^^^^^^^^^^^^^
django-defectdojo-2351-uwsgi-1  |   File "/usr/local/lib/python3.11/site-packages/django/core/handlers/base.py", line 197, in _get_response
django-defectdojo-2351-uwsgi-1  |     response = wrapped_callback(request, *callback_args, **callback_kwargs)
django-defectdojo-2351-uwsgi-1  |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
django-defectdojo-2351-uwsgi-1  |   File "/app/dojo/finding/views.py", line 2723, in finding_bulk_update_all
django-defectdojo-2351-uwsgi-1  |     find.delete()
django-defectdojo-2351-uwsgi-1  |   File "/app/dojo/models.py", line 2739, in delete
django-defectdojo-2351-uwsgi-1  |     calculate_grade(self.test.engagement.product)
django-defectdojo-2351-uwsgi-1  |   File "/app/dojo/decorators.py", line 74, in __wrapper__
django-defectdojo-2351-uwsgi-1  |     return func(*args, **kwargs)
django-defectdojo-2351-uwsgi-1  |            ^^^^^^^^^^^^^^^^^^^^^
django-defectdojo-2351-uwsgi-1  |   File "/app/dojo/decorators.py", line 45, in __wrapper__
django-defectdojo-2351-uwsgi-1  |     return func.apply_async(args=args, kwargs=kwargs, countdown=countdown)
django-defectdojo-2351-uwsgi-1  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
django-defectdojo-2351-uwsgi-1  |   File "/usr/local/lib/python3.11/site-packages/celery/app/task.py", line 594, in apply_async
django-defectdojo-2351-uwsgi-1  |     return app.send_task(
django-defectdojo-2351-uwsgi-1  |            ^^^^^^^^^^^^^^
django-defectdojo-2351-uwsgi-1  |   File "/usr/local/lib/python3.11/site-packages/celery/app/base.py", line 801, in send_task
django-defectdojo-2351-uwsgi-1  |     amqp.send_task_message(P, name, message, **options)
django-defectdojo-2351-uwsgi-1  |   File "/usr/local/lib/python3.11/site-packages/celery/app/amqp.py", line 518, in send_task_message
django-defectdojo-2351-uwsgi-1  |     ret = producer.publish(
django-defectdojo-2351-uwsgi-1  |           ^^^^^^^^^^^^^^^^^
django-defectdojo-2351-uwsgi-1  |   File "/usr/local/lib/python3.11/site-packages/kombu/messaging.py", line 186, in publish
django-defectdojo-2351-uwsgi-1  |     return _publish(
django-defectdojo-2351-uwsgi-1  |            ^^^^^^^^^
django-defectdojo-2351-uwsgi-1  |   File "/usr/local/lib/python3.11/site-packages/kombu/connection.py", line 556, in _ensured
django-defectdojo-2351-uwsgi-1  |     return fun(*args, **kwargs)
django-defectdojo-2351-uwsgi-1  |            ^^^^^^^^^^^^^^^^^^^^
django-defectdojo-2351-uwsgi-1  |   File "/usr/local/lib/python3.11/site-packages/kombu/messaging.py", line 195, in _publish
django-defectdojo-2351-uwsgi-1  |     channel = self.channel
django-defectdojo-2351-uwsgi-1  |               ^^^^^^^^^^^^
django-defectdojo-2351-uwsgi-1  |   File "/usr/local/lib/python3.11/site-packages/kombu/messaging.py", line 218, in _get_channel
django-defectdojo-2351-uwsgi-1  |     channel = self._channel = channel()
django-defectdojo-2351-uwsgi-1  |                               ^^^^^^^^^
django-defectdojo-2351-uwsgi-1  |   File "/usr/local/lib/python3.11/site-packages/kombu/utils/functional.py", line 34, in __call__
django-defectdojo-2351-uwsgi-1  |     value = self.__value__ = self.__contract__()
django-defectdojo-2351-uwsgi-1  |                              ^^^^^^^^^^^^^^^^^^^
django-defectdojo-2351-uwsgi-1  |   File "/usr/local/lib/python3.11/site-packages/kombu/messaging.py", line 234, in <lambda>
django-defectdojo-2351-uwsgi-1  |     channel = ChannelPromise(lambda: connection.default_channel)
django-defectdojo-2351-uwsgi-1  |                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^
django-defectdojo-2351-uwsgi-1  |   File "/usr/local/lib/python3.11/site-packages/kombu/connection.py", line 953, in default_channel
django-defectdojo-2351-uwsgi-1  |     self._ensure_connection(**conn_opts)
django-defectdojo-2351-uwsgi-1  |   File "/usr/local/lib/python3.11/site-packages/kombu/connection.py", line 458, in _ensure_connection
django-defectdojo-2351-uwsgi-1  |     with ctx():
django-defectdojo-2351-uwsgi-1  |   File "/usr/local/lib/python3.11/contextlib.py", line 158, in __exit__
django-defectdojo-2351-uwsgi-1  |     self.gen.throw(typ, value, traceback)
django-defectdojo-2351-uwsgi-1  |   File "/usr/local/lib/python3.11/site-packages/kombu/connection.py", line 476, in _reraise_as_library_errors
django-defectdojo-2351-uwsgi-1  |     raise ConnectionError(str(exc)) from exc
django-defectdojo-2351-uwsgi-1  | kombu.exceptions.OperationalError: [Errno -2] Name or service not known

Your uwsgi is not able to connect to your RabbitMQ probably because DD_CELERY_BROKER_URL is not set or it is incorrect. Probably for the same reason as here https://github.com/DefectDojo/django-DefectDojo/issues/10366.

Nsai1997 commented 3 weeks ago

Can you please let me know what we need to set the DD_CELERY_BROKER_URL

I have installed the defect dojo over the docker in the virtual machine in the GCP