DefectDojo / django-DefectDojo

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

Tables do not exist #2018

Closed httpnotonly closed 4 years ago

httpnotonly commented 4 years ago

Bug description django.db.utils.ProgrammingError: (1146, "Table 'defectdojo.django_site' doesn't exist") django.db.utils.ProgrammingError: (1146, "Table 'defectdojo.dojo_system_settings' doesn't exist") ..

Steps to reproduce Steps to reproduce the behavior:

  1. docker-compose build
  2. docker-compose up
  3. See error

Expected behavior A clear and concise description of what you expected to happen.

Deployment method (select with an X)

Environment information

madchap commented 4 years ago

This points to the fact you may have not waited long enough for the stack to initialize and were already with your browser on the URL.

Don't forget to copy the setting.dist.py to settings.py as well.

httpnotonly commented 4 years ago

This points to the fact you may have not waited long enough for the stack to initialize and were already with your browser on the URL.

10 minutes is not enough?

Don't forget to copy the setting.dist.py to settings.py as well.

I don't know what and where it is. I'm just trying 3rd time to install this platform :) Now it seems like instructions on the main page are no working

git clone https://github.com/DefectDojo/django-DefectDojo
cd django-DefectDojo
docker-compose build
docker-compose up -d

UPD. Step 16/23 : RUN cp dojo/settings/settings.dist.py dojo/settings/settings.py ---> Running in ddecc7d0e46c

Copying is working fine

madchap commented 4 years ago

10 minutes is not enough?

It should be enough, but only logs would tell.

Try to docker-compose rm -vf and delete your docker mysql volume with some docker volume rm -f <your_dojo_mysql_vol> to start fresh, it usually cures many issues especially if things were tried before that could have broken the initial... initialization.

httpnotonly commented 4 years ago

I'm rebuilding my Digital Ocean droplet for that purpose :) I did:

docker system prune

First raws are saying, that all is ok and already exist image

But then.. image image image

madchap commented 4 years ago

If it says already exist, then it didn't clean everything. Your docker volume must still be around.

httpnotonly commented 4 years ago

So, I have destroyed my DO VM. Now

sudo -i

apt install apt-transport-https ca-certificates curl gnupg-agent software-properties-common -y

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

add-apt-repository \
   "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
   $(lsb_release -cs) \
   stable"

apt-get update

apt-get install docker-ce docker-ce-cli containerd.io -y

curl -L https://github.com/docker/compose/releases/download/1.23.1/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose

git clone https://github.com/DefectDojo/django-DefectDojo

cd django-DefectDojo
docker-compose build
docker-compose up -d

finally it works

bbirkinbine commented 4 years ago

Anyone else still having problems with app DB tables not being created/populated for defect dojo after using docker-compose?

I can connect to mysql using defectdojo user but app tables are not present. I feel like something isn't being run to create the application tables.

Tried fresh github clone of defectdojo, nuked all the docker volumes and images, also re-installed docker-machine vm. Same issue with or without copying a new settings.py in dojo/settings/

$ git status HEAD detached at 1.5.4.1 nothing to commit, working tree clean

$ docker-machine version docker-machine version 0.16.2, build bd45ab1

$ docker-compose version docker-compose version 1.25.5, build unknown docker-py version: 4.2.0 CPython version: 3.8.2 OpenSSL version: OpenSSL 1.1.1g 21 Apr 2020

Host: MacOS version $ sw_vers -productVersion 10.14.5

Docker host: boot2docker 19.03.5

errors below that I'm seeing

uwsgi_1 | django.db.utils.ProgrammingError: (1146, "Table 'defectdojo.django_site' doesn't exist")

celeryworker_1 | MySQLdb._exceptions.ProgrammingError: (1146, "Table 'defectdojo.dojo_system_settings' doesn't exist")

bbirkinbine commented 4 years ago

Figured out a workaround.

Apparently during docker-compose up, the initializer docker image exits without initializing the application and db. Not sure if this is intended, but not clear on quick start docs.

If you run initializer image manually with the correct environment variable set I can get the app environment (include db) to initialize properly.

$ docker-compose up Wait for all images to be running (ie. mysql server needs to be running before next step)

$ export DD_INITIALIZE=true $ docker-compose up initializer This will connect to running mysql environment and do proper table creation

This will also create a random 'admin' password for initial login to the application (see output below)

` $ export DD_INITIALIZE=true

$ docker-compose up initializer django-defectdojo_mysql_1 is up-to-date Recreating django-defectdojo_initializer_1 ... done Attaching to django-defectdojo_initializer_1 initializer_1 | wait-for-it.sh: waiting 60 seconds for mysql:3306 initializer_1 | wait-for-it.sh: mysql:3306 is available after 0 seconds initializer_1 | Initializing. initializer_1 | Admin user: admin initializer_1 | Admin password: yourRandomAdminPasswordGeneratedHere initializer_1 | Waiting for database to be reachable initializer_1 | No changes detected in app 'dojo' initializer_1 | Operations to perform: initializer_1 | Apply all migrations: admin, auditlog, auth, authtoken, contenttypes, custom_field, defectDojo_engagement_survey, django_celery_results, dojo, sessions, sites, social_django, tagging, tastypie, watson initializer_1 | Running migrations: initializer_1 | Applying contenttypes.0001_initial... OK initializer_1 | Applying auth.0001_initial... OK initializer_1 | Applying admin.0001_initial... OK initializer_1 | Applying admin.0002_logentry_remove_auto_add... OK initializer_1 | Applying admin.0003_logentry_add_action_flag_choices... OK initializer_1 | Applying auditlog.0001_initial... OK initializer_1 | Applying auditlog.0002_auto_support_long_primary_keys... OK initializer_1 | Applying auditlog.0003_logentry_remote_addr... OK initializer_1 | Applying auditlog.0004_logentry_detailed_object_repr... OK initializer_1 | Applying auditlog.0005_logentry_additional_data_verbose_name... OK initializer_1 | Applying auditlog.0006_object_pk_index... OK initializer_1 | Applying auditlog.0007_object_pk_type... OK initializer_1 | Applying contenttypes.0002_remove_content_type_name... OK initializer_1 | Applying auth.0002_alter_permission_name_max_length... OK initializer_1 | Applying auth.0003_alter_user_email_max_length... OK initializer_1 | Applying auth.0004_alter_user_username_opts... OK initializer_1 | Applying auth.0005_alter_user_last_login_null... OK initializer_1 | Applying auth.0006_require_contenttypes_0002... OK initializer_1 | Applying auth.0007_alter_validators_add_error_messages... OK initializer_1 | Applying auth.0008_alter_user_username_max_length... OK initializer_1 | Applying auth.0009_alter_user_last_name_max_length... OK initializer_1 | Applying auth.0010_alter_group_name_max_length... OK initializer_1 | Applying auth.0011_update_proxy_permissions... OK initializer_1 | Applying authtoken.0001_initial... OK initializer_1 | Applying authtoken.0002_auto_20160226_1747... OK initializer_1 | Applying custom_field.0001_initial... OK initializer_1 | Applying custom_field.0002_auto_20150119_2032... OK initializer_1 | Applying custom_field.0003_customfield_mask... OK initializer_1 | Applying custom_field.0004_django2_upgrade... OK initializer_1 | Applying dojo.0001_initial... OK initializer_1 | Applying defectDojo_engagement_survey.0001_initial... OK initializer_1 | Applying django_celery_results.0001_initial... OK initializer_1 | Applying django_celery_results.0002_add_task_name_args_kwargs... OK initializer_1 | Applying django_celery_results.0003_auto_20181106_1101... OK initializer_1 | Applying django_celery_results.0004_auto_20190516_0412... OK initializer_1 | Applying dojo.0002_auto_20190503_1817... OK initializer_1 | Applying dojo.0003_test_title... OK initializer_1 | Applying dojo.0004_cve_field... OK initializer_1 | Applying dojo.0005_repo_field... OK initializer_1 | Applying dojo.0006_django2_upgrade... OK initializer_1 | Applying dojo.0007_note_additions... OK initializer_1 | Applying dojo.0008_finding_mitigation... OK initializer_1 | Applying dojo.0009_endpoint_remediation... OK initializer_1 | Applying dojo.0010_jira_conf_configuration_name... OK initializer_1 | Applying dojo.0011_finding_template_activity... OK initializer_1 | Applying dojo.0012_jira_finding_age... OK initializer_1 | Applying dojo.0013_jira_info_level... OK initializer_1 | Applying dojo.0014_jira_conf_resolution_mappings... OK initializer_1 | Applying dojo.0015_findingimage_caption... OK initializer_1 | Applying dojo.0016_increase_filepath_length... OK initializer_1 | Applying dojo.0017_auto_20190827_1421... OK initializer_1 | Applying dojo.0018_sonarqube_api_integration...Database vendor: mysql initializer_1 | OK initializer_1 | Applying dojo.0019_notetype_additions... OK initializer_1 | Applying dojo.0020_system_settings_allow_anonymous_survey_repsonse... OK initializer_1 | Applying dojo.0021_cve_index... OK initializer_1 | Applying dojo.0022_google_sheet_sync_additions... OK initializer_1 | Applying dojo.0023_SAST_track_unique_vulnerabilities... OK initializer_1 | Applying dojo.0024_cve_fix_1553... OK initializer_1 | Applying dojo.0025_jira_security_issuetype... OK initializer_1 | Applying dojo.0026_login_banner... OK initializer_1 | Applying dojo.0027_jira_issue_type_settings... OK initializer_1 | Applying sessions.0001_initial... OK initializer_1 | Applying sites.0001_initial... OK initializer_1 | Applying sites.0002_alter_domain_unique... OK initializer_1 | Applying social_django.0001_initial... OK initializer_1 | Applying social_django.0002_add_related_name... OK initializer_1 | Applying social_django.0003_alter_email_max_length... OK initializer_1 | Applying social_django.0004_auto_20160423_0400... OK initializer_1 | Applying social_django.0005_auto_20160727_2333... OK initializer_1 | Applying social_django.0006_partial... OK initializer_1 | Applying social_django.0007_code_timestamp... OK initializer_1 | Applying social_django.0008_partial_timestamp... OK initializer_1 | Applying tagging.0001_initial... OK initializer_1 | Applying tagging.0002_on_delete... OK initializer_1 | Applying tagging.0003_adapt_max_tag_length... OK initializer_1 | Applying tastypie.0001_initial... OK initializer_1 | Applying tastypie.0002_api_access_url_length... OK initializer_1 | Applying watson.0001_initial... OK initializer_1 | Installed 1 object(s) from 1 fixture(s) initializer_1 | Installed 1 object(s) from 1 fixture(s) initializer_1 | Installed 76 object(s) from 1 fixture(s)

initializer_1 | Installed 13 object(s) from 1 fixture(s) initializer_1 | Installed 88 object(s) from 1 fixture(s) initializer_1 | Deleted 0 stale search entry(s) in 'default' search engine. initializer_1 | Deleted 0 stale search entry(s) in 'admin' search engine. initializer_1 | Refreshed 0 search entry(s) in 'admin' search engine. django-defectdojo_initializer_1 exited with code 0`