Closed domcar closed 1 year ago
Did you checked the initializer container logs?
@damiencarol I can't see any InitContainer in the deployment, are you sure there is one? Or do you refer to something different?
I also tried to modify some settings as test and I get :
django.db.utils.ProgrammingError: column "enable_notify_sla_active" of relation "dojo_system_settings" does not exist
LINE 1: ...ngagement_auto_close_days", "enable_finding_sla", "enable_no...
Something got really wrong with the DB
Try simply exec into DD pod, django container and fro there run ./manage.py showmigrations
It will show you missing migrations
I got the following
bash-5.1$ ./manage.py showmigrations
[15/Feb/2023 11:24:11] INFO [dojo.models:4168] enabling audit logging
/usr/local/lib/python3.11/site-packages/jira/client.py:11: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13
import imghdr
/app/dojo/reports/views.py:747: DeprecationWarning: invalid escape sequence '\?'
path_items = list(filter(None, re.split('/|\?', url))) # noqa W605
/app/dojo/engagement/views.py:1218: DeprecationWarning: invalid escape sequence '\?'
path_items = list(filter(None, re.split('/|\?', url))) # noqa W605
System check identified some issues:
WARNINGS:
?: (staticfiles.W004) The directory '/app/components/node_modules' in the STATICFILES_DIRS setting does not exist.
admin
[X] 0001_initial
[X] 0002_logentry_remove_auto_add
[X] 0003_logentry_add_action_flag_choices
auditlog
[X] 0001_initial
[X] 0002_auto_support_long_primary_keys
[X] 0003_logentry_remote_addr
[X] 0004_logentry_detailed_object_repr
[X] 0005_logentry_additional_data_verbose_name
[X] 0006_object_pk_index
[X] 0007_object_pk_type
[X] 0008_action_index
[X] 0009_alter_logentry_additional_data
[X] 0010_alter_logentry_timestamp
[ ] 0011_logentry_serialized_data
[ ] 0012_add_logentry_action_access
auth
[X] 0001_initial
[X] 0002_alter_permission_name_max_length
[X] 0003_alter_user_email_max_length
[X] 0004_alter_user_username_opts
[X] 0005_alter_user_last_login_null
[X] 0006_require_contenttypes_0002
[X] 0007_alter_validators_add_error_messages
[X] 0008_alter_user_username_max_length
[X] 0009_alter_user_last_name_max_length
[X] 0010_alter_group_name_max_length
[X] 0011_update_proxy_permissions
[X] 0012_alter_user_first_name_max_length
authtoken
[X] 0001_initial
[X] 0002_auto_20160226_1747
[X] 0003_tokenproxy
contenttypes
[X] 0001_initial
[X] 0002_remove_content_type_name
django_celery_results
[X] 0001_initial
[X] 0002_add_task_name_args_kwargs
[X] 0003_auto_20181106_1101
[X] 0004_auto_20190516_0412
[X] 0005_taskresult_worker
[X] 0006_taskresult_date_created
[X] 0007_remove_taskresult_hidden
[X] 0008_chordcounter
[X] 0009_groupresult
[X] 0010_remove_duplicate_indices
[X] 0011_taskresult_periodic_task_name
dojo
[X] 0001_squashed_0090_index_duplicate_finding (90 squashed migrations)
[X] 0091_npm_audit_path_censoring
[X] 0092_is_mitigated
[X] 0093_django_tagging_removal
[X] 0094_remove_system_settings_s_finding_severity_naming
[X] 0095_remove_old_product_contact_fields
[X] 0096_grype_name_change
[X] 0097_engagement_type
[X] 0098_anchore_vuln_id
[X] 0099_delete_report
[X] 0100_dojo_user_for_authv2
[X] 0101_enable_features
[X] 0102_dojo_group
[X] 0103_report_notification
[X] 0104_endpoint_userinfo_creation
[X] 0105_endpoint_host_migration
[X] 0106_role_model
[X] 0107_global_role
[X] 0108_blank_fields
[X] 0109_group_user_role
[X] 0110_auth_v2_migrate_user_roles
[X] 0111_group_user_rename
[X] 0112_group_user_rename_2
[X] 0113_endpoint_protocol
[X] 0114_cyclonedx_vuln_uniqu
[X] 0115_language_types
[X] 0116_test_type_active
[X] 0117_usercontactinfo_force_password_reset
[X] 0118_remove_finding_images
[X] 0119_default_group_is_staff
[X] 0120_sonarqube_test_and_clean
[X] 0121_user_restrict
[X] 0122_cobaltio_product
[X] 0123_scan_type
[X] 0124_sonarqube_api_type_length_change
[X] 0125_sonarqube_clean
[X] 0126_finding_publish_date
[X] 0127_remove_hashes
[X] 0128_pytz_update
[X] 0129_finding_deprecated_fields
[X] 0130_product_api_scan_configuration
[X] 0131_migrate_sonarcube_cobalt
[X] 0132_remove_configs_from_test
[X] 0133_finding_service
[X] 0134_sonarque_cobaltio_removal
[X] 0135_email_from
[X] 0136_default_group_help_text
[X] 0137_system_settings_enable_endpoint_metadata_import
[X] 0138_remove_authorized_users
[X] 0139_google_sheets_rules_framework_enable
[X] 0140_auth_group
[X] 0141_enable_user_profile_editable
[X] 0142_environment_delete
[X] 0143_objects
[X] 0144_import_action_untouched
[X] 0145_system_settings_default_group_email_pattern
[X] 0146_lead_optional
[X] 0147_rename_sslyze_parser
[X] 0148_default_notifications
[X] 0149_harmonize_user_format
[X] 0150_dedupe_endpoint_status
[X] 0151_index_endpoint_status
[X] 0152_notifications_template
[X] 0153_migrate_endpoint_mitigated
[X] 0154_remove_endpoint_mitigated
[X] 0155_enable_finding_groups
[X] 0156_migrate_finding_groups_setting
[X] 0157_vulnerability_reference
[X] 0158_vulnerability_id
[X] 0159_remove_broken_endpoint_statuses
[X] 0160_set_notnull_endpoint_statuses
[X] 0161_alter_dojo_group_social_provider
[X] 0162_created_and_updated
[X] 0163_system_settings_enable_calendar
[X] 0164_remove_system_settings_staff_user_email_pattern
[X] 0165_custom_sla
[X] 0166_copy_sla_from_system_settings
[X] 0167_system_settings_add_vulnerability_id_to_jira_label
[X] 0168_alter_system_settings_time_zone
[X] 0169_planned_remediation_date
[X] 0170_jira_project_custom_fields
[X] 0171_jira_labels_per_product_and_engagement
[X] 0172_optimize_usage_of_endpoint_status
[X] 0173_alter_risk_acceptance_name
[ ] 0174_jira_project_default_assignee
[ ] 0175_system_settings_enable_notify_sla
[ ] 0176_custom_password_requirements
[ ] 0177_alter_system_settings_time_zone
[ ] 0178_alter_answer_polymorphic_ctype_and_more
[ ] 0179_alter_finding_verified
[ ] 0180_announcement_userannouncement
sessions
[X] 0001_initial
sites
[X] 0001_initial
[X] 0002_alter_domain_unique
social_django
[X] 0001_initial (2 squashed migrations)
[X] 0002_add_related_name (2 squashed migrations)
[X] 0003_alter_email_max_length (2 squashed migrations)
[X] 0004_auto_20160423_0400 (2 squashed migrations)
[X] 0005_auto_20160727_2333 (1 squashed migrations)
[X] 0006_partial
[X] 0007_code_timestamp
[X] 0008_partial_timestamp
[X] 0009_auto_20191118_0520
[X] 0010_uid_db_index
tagging
[X] 0001_initial
[X] 0002_on_delete
[X] 0003_adapt_max_tag_length
watson
[X] 0001_initial
[ ] 0002_alter_searchentry_object_id
Could you please tell me how to preceed? Do I need to perform migrations?
ok, i did the migration with ./manage.py migrate
now they are all shown as completed in the list from showmigrations
. Unfortunately this didn't change much, I still get the whole 500 errors in the UI and the same logs as abode.
Anything I can do?
Can you point me to the exact logs/error you have now after migration has been applied?
An example is when in the UI I click on the menu --> all Products. This generate in the UI a 500 Internal Server Error and in the logs I see
[15/Feb/2023 12:31:30] INFO [django.request:241] OK: /product
Traceback (most recent call last):
File "/usr/local/lib/python3.11/site-packages/django/db/backends/utils.py", line 89, in _execute
return self.cursor.execute(sql, params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
psycopg2.errors.UndefinedColumn: column dojo_jira_project.default_assignee does not exist
LINE 1: ..."component", "dojo_jira_project"."custom_fields", "dojo_jira...
Or if in the UI I go to menu settings --> announcement the error is
[15/Feb/2023 12:35:25] INFO [django.request:241] OK: /configure_announcement
Traceback (most recent call last):
File "/usr/local/lib/python3.11/site-packages/django/db/backends/utils.py", line 89, in _execute
return self.cursor.execute(sql, params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
psycopg2.errors.UndefinedTable: relation "dojo_announcement" does not exist
LINE 1: ..."."dismissable", "dojo_announcement"."style" FROM "dojo_anno...
^
Do you really have [ ] 0180_announcement_userannouncement
and [ ] 0174_jira_project_default_assignee
checked when using show migration?
I ran again the command just to be sure
bash-5.1$ ./manage.py showmigrations
[15/Feb/2023 14:24:44] INFO [dojo.models:4168] enabling audit logging
/usr/local/lib/python3.11/site-packages/jira/client.py:11: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13
import imghdr
/app/dojo/reports/views.py:747: DeprecationWarning: invalid escape sequence '\?'
path_items = list(filter(None, re.split('/|\?', url))) # noqa W605
/app/dojo/engagement/views.py:1218: DeprecationWarning: invalid escape sequence '\?'
path_items = list(filter(None, re.split('/|\?', url))) # noqa W605
System check identified some issues:
WARNINGS:
?: (staticfiles.W004) The directory '/app/components/node_modules' in the STATICFILES_DIRS setting does not exist.
admin
[X] 0001_initial
[X] 0002_logentry_remove_auto_add
[X] 0003_logentry_add_action_flag_choices
auditlog
[X] 0001_initial
[X] 0002_auto_support_long_primary_keys
[X] 0003_logentry_remote_addr
[X] 0004_logentry_detailed_object_repr
[X] 0005_logentry_additional_data_verbose_name
[X] 0006_object_pk_index
[X] 0007_object_pk_type
[X] 0008_action_index
[X] 0009_alter_logentry_additional_data
[X] 0010_alter_logentry_timestamp
[X] 0011_logentry_serialized_data
[X] 0012_add_logentry_action_access
auth
[X] 0001_initial
[X] 0002_alter_permission_name_max_length
[X] 0003_alter_user_email_max_length
[X] 0004_alter_user_username_opts
[X] 0005_alter_user_last_login_null
[X] 0006_require_contenttypes_0002
[X] 0007_alter_validators_add_error_messages
[X] 0008_alter_user_username_max_length
[X] 0009_alter_user_last_name_max_length
[X] 0010_alter_group_name_max_length
[X] 0011_update_proxy_permissions
[X] 0012_alter_user_first_name_max_length
authtoken
[X] 0001_initial
[X] 0002_auto_20160226_1747
[X] 0003_tokenproxy
contenttypes
[X] 0001_initial
[X] 0002_remove_content_type_name
django_celery_results
[X] 0001_initial
[X] 0002_add_task_name_args_kwargs
[X] 0003_auto_20181106_1101
[X] 0004_auto_20190516_0412
[X] 0005_taskresult_worker
[X] 0006_taskresult_date_created
[X] 0007_remove_taskresult_hidden
[X] 0008_chordcounter
[X] 0009_groupresult
[X] 0010_remove_duplicate_indices
[X] 0011_taskresult_periodic_task_name
dojo
[X] 0001_squashed_0090_index_duplicate_finding (90 squashed migrations)
[X] 0091_npm_audit_path_censoring
[X] 0092_is_mitigated
[X] 0093_django_tagging_removal
[X] 0094_remove_system_settings_s_finding_severity_naming
[X] 0095_remove_old_product_contact_fields
[X] 0096_grype_name_change
[X] 0097_engagement_type
[X] 0098_anchore_vuln_id
[X] 0099_delete_report
[X] 0100_dojo_user_for_authv2
[X] 0101_enable_features
[X] 0102_dojo_group
[X] 0103_report_notification
[X] 0104_endpoint_userinfo_creation
[X] 0105_endpoint_host_migration
[X] 0106_role_model
[X] 0107_global_role
[X] 0108_blank_fields
[X] 0109_group_user_role
[X] 0110_auth_v2_migrate_user_roles
[X] 0111_group_user_rename
[X] 0112_group_user_rename_2
[X] 0113_endpoint_protocol
[X] 0114_cyclonedx_vuln_uniqu
[X] 0115_language_types
[X] 0116_test_type_active
[X] 0117_usercontactinfo_force_password_reset
[X] 0118_remove_finding_images
[X] 0119_default_group_is_staff
[X] 0120_sonarqube_test_and_clean
[X] 0121_user_restrict
[X] 0122_cobaltio_product
[X] 0123_scan_type
[X] 0124_sonarqube_api_type_length_change
[X] 0125_sonarqube_clean
[X] 0126_finding_publish_date
[X] 0127_remove_hashes
[X] 0128_pytz_update
[X] 0129_finding_deprecated_fields
[X] 0130_product_api_scan_configuration
[X] 0131_migrate_sonarcube_cobalt
[X] 0132_remove_configs_from_test
[X] 0133_finding_service
[X] 0134_sonarque_cobaltio_removal
[X] 0135_email_from
[X] 0136_default_group_help_text
[X] 0137_system_settings_enable_endpoint_metadata_import
[X] 0138_remove_authorized_users
[X] 0139_google_sheets_rules_framework_enable
[X] 0140_auth_group
[X] 0141_enable_user_profile_editable
[X] 0142_environment_delete
[X] 0143_objects
[X] 0144_import_action_untouched
[X] 0145_system_settings_default_group_email_pattern
[X] 0146_lead_optional
[X] 0147_rename_sslyze_parser
[X] 0148_default_notifications
[X] 0149_harmonize_user_format
[X] 0150_dedupe_endpoint_status
[X] 0151_index_endpoint_status
[X] 0152_notifications_template
[X] 0153_migrate_endpoint_mitigated
[X] 0154_remove_endpoint_mitigated
[X] 0155_enable_finding_groups
[X] 0156_migrate_finding_groups_setting
[X] 0157_vulnerability_reference
[X] 0158_vulnerability_id
[X] 0159_remove_broken_endpoint_statuses
[X] 0160_set_notnull_endpoint_statuses
[X] 0161_alter_dojo_group_social_provider
[X] 0162_created_and_updated
[X] 0163_system_settings_enable_calendar
[X] 0164_remove_system_settings_staff_user_email_pattern
[X] 0165_custom_sla
[X] 0166_copy_sla_from_system_settings
[X] 0167_system_settings_add_vulnerability_id_to_jira_label
[X] 0168_alter_system_settings_time_zone
[X] 0169_planned_remediation_date
[X] 0170_jira_project_custom_fields
[X] 0171_jira_labels_per_product_and_engagement
[X] 0172_optimize_usage_of_endpoint_status
[X] 0173_alter_risk_acceptance_name
[X] 0174_jira_project_default_assignee
[X] 0175_system_settings_enable_notify_sla
[X] 0176_custom_password_requirements
[X] 0177_alter_system_settings_time_zone
[X] 0178_alter_answer_polymorphic_ctype_and_more
[X] 0179_alter_finding_verified
[X] 0180_announcement_userannouncement
sessions
[X] 0001_initial
sites
[X] 0001_initial
[X] 0002_alter_domain_unique
social_django
[X] 0001_initial (2 squashed migrations)
[X] 0002_add_related_name (2 squashed migrations)
[X] 0003_alter_email_max_length (2 squashed migrations)
[X] 0004_auto_20160423_0400 (2 squashed migrations)
[X] 0005_auto_20160727_2333 (1 squashed migrations)
[X] 0006_partial
[X] 0007_code_timestamp
[X] 0008_partial_timestamp
[X] 0009_auto_20191118_0520
[X] 0010_uid_db_index
tagging
[X] 0001_initial
[X] 0002_on_delete
[X] 0003_adapt_max_tag_length
watson
[X] 0001_initial
[X] 0002_alter_searchentry_object_id
is there a way maybe to force the migration to run again?
You can run this one [X] 0173_alter_risk_acceptance_name
will unapply migrations, and then run one by one migration stating from 0175_system_settings_enable_notify_sla
to see if there are any errors
Can you tell me which command to use? Sorry, i'm not familiar with the tool
./manege.py 0173_alter_risk_acceptance_name
to rollback
Please take a look at the https://docs.djangoproject.com/en/4.1/ref/django-admin/#migrate for more detail about the other options
Hi @dsever when I try ./manage.py migrate dojo 0173_alter_risk_acceptance_name
it ends with the following error:
[17/Feb/2023 07:05:04] INFO [dojo.models:4168] enabling audit logging
/usr/local/lib/python3.11/site-packages/jira/client.py:11: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13
import imghdr
/app/dojo/reports/views.py:747: DeprecationWarning: invalid escape sequence '\?'
path_items = list(filter(None, re.split('/|\?', url))) # noqa W605
/app/dojo/engagement/views.py:1218: DeprecationWarning: invalid escape sequence '\?'
path_items = list(filter(None, re.split('/|\?', url))) # noqa W605
System check identified some issues:
WARNINGS:
?: (staticfiles.W004) The directory '/app/components/node_modules' in the STATICFILES_DIRS setting does not exist.
Operations to perform:
Target specific migration: 0173_alter_risk_acceptance_name, from dojo
Running migrations:
Rendering model states... DONE
Unapplying dojo.0180_announcement_userannouncement...Traceback (most recent call last):
File "/usr/local/lib/python3.11/site-packages/django/db/backends/utils.py", line 89, in _execute
return self.cursor.execute(sql, params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
psycopg2.errors.UndefinedTable: table "dojo_userannouncement" does not exist
So I tried with some previous migration, for example ./manage.py migrate dojo 0139_google_sheets_rules_framework_enable
but it still has errors
[17/Feb/2023 07:07:49] INFO [dojo.models:4168] enabling audit logging
/usr/local/lib/python3.11/site-packages/jira/client.py:11: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13
import imghdr
/app/dojo/reports/views.py:747: DeprecationWarning: invalid escape sequence '\?'
path_items = list(filter(None, re.split('/|\?', url))) # noqa W605
/app/dojo/engagement/views.py:1218: DeprecationWarning: invalid escape sequence '\?'
path_items = list(filter(None, re.split('/|\?', url))) # noqa W605
System check identified some issues:
WARNINGS:
?: (staticfiles.W004) The directory '/app/components/node_modules' in the STATICFILES_DIRS setting does not exist.
Operations to perform:
Target specific migration: 0139_google_sheets_rules_framework_enable, from dojo
Running migrations:
Rendering model states...Killed
Do you have other ideas what I could try?
Ehi, I created manually those tables and it worked a bit more, but now I get django.db.migrations.exceptions.IrreversibleError: Operation <RunPython <function migrate_notify_sla_from_settings_file at 0x7f4855c31e40>> in dojo.0175_system_settings_enable_notify_sla is not reversible
when running the migration
Nothing should be created manually... do you have backup maybe?
I restored the backup and everything is going fine. I still would like to know what happened, to avoid it happening in the future, do you have any idea how I could find this out?
To be honest, have no idea hot to replicate it. Can we close this issue?
Bug description I think the postgres DB got corrupted while using defectdojo
Steps to reproduce When connected to the UI i get 500 Internal errors for several pages. In the logs of defectdojo I can see errors like:
django.db.utils.ProgrammingError: column dojo_jira_project.default_assignee does not exist
ordjango.db.utils.ProgrammingError: column auditlog_logentry.serialized_data does not exist
Deployment method (select with an
X
)Environment information I deployed defectDojo using the helm chart version
1.6.43
with the following settings:Logs
This happened suddenly without anything from our side, no upgrade nor manual changes anywhere.