django-DefectDojo icon indicating copy to clipboard operation
django-DefectDojo copied to clipboard

Undo effects of setting DD_SITE_URL

Open fuzzah opened this issue 3 years ago • 1 comments

So I configured Jira integration, but Jira issues created by Defect Dojo contained finding URLs like http://localhost:8080/finding/85. I needed normal URLs like https://dojo.mycompany.com/finding/85. I found out that this may be fixed via setting DD_SITE_URL environment variable. ( https://github.com/DefectDojo/django-DefectDojo/issues/6422 )

Problem description

I have put DD_SITE_URL in docker-compose.override.https.yml, like so:

uwsgi:
    environment:
        DD_SITE_URL: "dojo.mycompany.com"

I then rebuilt DD images and restarted docker-compose:

docker-compose --profile mysql-rabbitmq --env-file ./docker/environments/mysql-rabbitmq.env build
docker-compose --profile mysql-rabbitmq --env-file ./docker/environments/mysql-rabbitmq.env up

Problem 1: it turned out that now every single URL of Defect Dojo itself looks like this: https://dojo.mycompany.com/dojo.mycompany.comfinding/85

(this is actually displayed in web browser as current URL for finding). But Jira now at least contained same URLs which were working.

Then I tried fixing the URLs in Defect Dojo by moving DD_SITE_URL from uwsgi to celeryworker in docker-compose.override.https.yml, like so:

celeryworker:
    environment:
        DD_SITE_URL: "dojo.mycompany.com"

After rebuild & restart everything still looked the same.

Problem 2: login URL of Defect Dojo has stopped working!

It says 404 not found. No amount of appending "dojo.mycompany.com" helped solving the login issue.

Then I removed DD_SITE_URL from the docker-compose.override.https.yml, rebuilt images, restarted containers.

Problem 3: URLs are still broken after unsetting DD_SITE_URL

Expected behavior

I expected:

  1. documentation on Jira integration should explain how to fix "localhost:8080" URLs
  2. setting DD_SITE_URL should not mess login screen
  3. unsetting DD_SITE_URL should restore changed URLs back to original or there should be some fixing mechanism like e.g. manage.py script for that

Deployment method

  • [X] Docker Compose
  • [ ] Kubernetes
  • [ ] GoDojo

Environment information

  • DefectDojo version: v. 2.13.1 ( release mode )

fuzzah avatar Aug 26 '22 07:08 fuzzah

i've had same problem, while I'm doing this https://github.com/DefectDojo/django-DefectDojo/issues/6433

the problem is that your setting changed the url_prefix to dojo.mycompany.com, that is the reason you get https://dojo.mycompany.com/dojo.mycompany.comfinding/85 the resolution is you must change it back directly in the database by accessing the database and change it manually (that is what i do since i can't open defectdojo anymore from that point)

how to correctly set DD_SITE_PROFILE is to create/change the SITE_PROFILE with setting.py https://defectdojo.github.io/django-DefectDojo/getting_started/configuration/#local_settingspy-not-with-kubernetes

Hope it helps

Roooodie avatar Sep 07 '22 04:09 Roooodie

I have DD_SITE_URL in an env file and set this via the parameter "--env-file". This worked for me in 2.10.0. Since the update 2.14.3 we have also localhost in the URL placed in Jira tickets and also in MS Teams messages. In other places, like the suggested JIRA Webhook URL in the UI, the correct site url is used.

AndreVirtimo avatar Oct 28 '22 05:10 AndreVirtimo

I fixed this now by adding DD_SITE_URL: "${DD_SITE_URL}" to environment in the docker-compose.yml for uwsgi and celeryworker

AndreVirtimo avatar May 02 '23 13:05 AndreVirtimo