Skip to content

Commit b66a250

Browse files
committed
drop django-tagging as dependency
1 parent 324684e commit b66a250

5 files changed

Lines changed: 1 addition & 96 deletions

File tree

docker/sample_data/initial_dojo_data.json

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -231,22 +231,6 @@
231231
"model": "contenttypes.contenttype",
232232
"pk": 38
233233
},
234-
{
235-
"fields": {
236-
"model": "tag",
237-
"app_label": "tagging"
238-
},
239-
"model": "contenttypes.contenttype",
240-
"pk": 39
241-
},
242-
{
243-
"fields": {
244-
"model": "taggeditem",
245-
"app_label": "tagging"
246-
},
247-
"model": "contenttypes.contenttype",
248-
"pk": 40
249-
},
250234
{
251235
"fields": {
252236
"expire_date": "2016-09-10T12:40:25.483Z",

docs/content/en/open_source/upgrading/2.0.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ exclude_search: true
88
Follow the usual steps to upgrade as described above.
99

1010
BEFORE UPGRADING
11+
- If you are upgrading from a version before 1.11, first do an upgrade to 1.15.1. Then come back to this.
1112
- If you are using SAML2 checkout the new [documentaion](https://documentation.defectdojo.com/integrations/social-authentication/#saml-20) and update you settings following the migration section. We replaced [django-saml2-auth](https://github.com/fangli/django-saml2-auth) with [djangosaml2](https://github.com/IdentityPython/djangosaml2).
1213

1314
AFTER UPGRADING

dojo/db_migrations/0066_django_tagulous.py

Lines changed: 0 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
from django.db import migrations, models
44
# import django.db.models.deletion
5-
from tagging.registry import register as tag_register
65
from django.forms.models import model_to_dict
76
import tagulous.models.fields
87
import tagulous.models.models
@@ -12,69 +11,6 @@
1211

1312

1413
class Migration(migrations.Migration):
15-
16-
def copy_existing_tags_to_tags_from_django_tagging_field(apps, schema_editor):
17-
# We can't import the models directly as it may be a newer
18-
# version than this migration expects. We use the historical version.
19-
logger.info('Migrating tags from django-tagging to django-tagulous step1. Enable DEBUG logging to find out more.')
20-
import tagulous.utils
21-
# for model_name in ['Product']:
22-
for model_name in ['Product', 'test', 'finding', 'engagement', 'endpoint', 'finding_template', 'app_Analysis', 'objects']:
23-
model_class = apps.get_model('dojo', model_name)
24-
# the get_model returns a fake class proxy, which is not registered with django-tagging
25-
tag_register(model_class)
26-
27-
for obj in model_class.objects.all():
28-
# logger.debug('%s:%s:%s', model_class, obj.id, obj)
29-
if obj.tags:
30-
tags_as_string = tagulous.utils.render_tags(obj.tags.all())
31-
logger.debug('%s:%s:%s: found tags: %s', model_class, obj.id, obj, tags_as_string)
32-
obj.tags_from_django_tagging = tags_as_string
33-
# obj.description = tags_as_string
34-
# finding.save() doesn't look at push_all_jira_issue, so we should be good
35-
# if model_name == 'finding2':
36-
# obj.save(dedupe_option=False, rules_option=False, issue_updater_option=False, push_to_jira=False)
37-
# else:
38-
try:
39-
if hasattr(obj, 'prod_type_id') and obj.prod_type_id == 0:
40-
logger.warning('product found without product type (prod_type==0), changing to: "_tag migration lost and found" product type')
41-
Product_Type_Model = apps.get_model('dojo', 'Product_Type')
42-
prod_type_lost_and_found, created = Product_Type_Model.objects.get_or_create(name='_tag migration lost and found')
43-
obj.prod_type = prod_type_lost_and_found
44-
obj.save()
45-
logger.warning('product type successfully changed to %i', prod_type_lost_and_found.id)
46-
47-
obj.save()
48-
except Exception as e:
49-
logger.error('Error saving old existing django-tagging tags to new string field')
50-
logger.error('Details of object:')
51-
logger.error(vars(obj))
52-
logger.error('Model to dict:')
53-
logger.error(model_to_dict(obj))
54-
55-
def copy_tags_from_django_tagging_field_to_new_tagulous_tags_field(apps, schema_editor):
56-
# We can't import the models directly as it may be a newer
57-
# version than this migration expects. We use the historical version.
58-
logger.info('Migrating tags from django-tagging to django-tagulous step2. Enable DEBUG logging to find out more.')
59-
# for model_name in ['Product']:
60-
for model_name in ['Product', 'test', 'finding', 'engagement', 'endpoint', 'finding_template', 'app_Analysis', 'objects_product']:
61-
model_class = apps.get_model('dojo', model_name)
62-
63-
for obj in model_class.objects.all():
64-
# logger.debug('%s:%s:%s', model_class, obj.id, obj)
65-
if obj.tags_from_django_tagging:
66-
logger.debug('%s:%s:%s: found tags: %s', model_class, obj.id, obj, obj.tags_from_django_tagging)
67-
obj.tags = obj.tags_from_django_tagging
68-
69-
try:
70-
obj.save()
71-
except Exception as e:
72-
logger.error('Error saving tags to new tagulous m2m field')
73-
logger.error('Details of object:')
74-
logger.error(vars(obj))
75-
logger.error('Model to dict:')
76-
logger.error(model_to_dict(obj))
77-
7814
dependencies = [
7915
('dojo', '0065_delete_empty_jira_project_configs'),
8016
]
@@ -121,8 +57,6 @@ def copy_tags_from_django_tagging_field_to_new_tagulous_tags_field(apps, schema_
12157
field=models.TextField(blank=True, editable=False, help_text='Temporary archive with tags from the previous tagging library we used'),
12258
),
12359

124-
migrations.RunPython(copy_existing_tags_to_tags_from_django_tagging_field, migrations.RunPython.noop),
125-
12660
migrations.RenameModel('Objects', 'Objects_Product'),
12761

12862
migrations.CreateModel(
@@ -309,6 +243,4 @@ def copy_tags_from_django_tagging_field_to_new_tagulous_tags_field(apps, schema_
309243
name='match_field',
310244
field=models.CharField(choices=[('id', 'id'), ('title', 'title'), ('date', 'date'), ('cwe', 'cwe'), ('cve', 'cve'), ('cvssv3', 'cvssv3'), ('url', 'url'), ('severity', 'severity'), ('description', 'description'), ('mitigation', 'mitigation'), ('impact', 'impact'), ('steps_to_reproduce', 'steps_to_reproduce'), ('severity_justification', 'severity_justification'), ('references', 'references'), ('test', 'test'), ('is_template', 'is_template'), ('active', 'active'), ('verified', 'verified'), ('false_p', 'false_p'), ('duplicate', 'duplicate'), ('duplicate_finding', 'duplicate_finding'), ('out_of_scope', 'out_of_scope'), ('under_review', 'under_review'), ('review_requested_by', 'review_requested_by'), ('under_defect_review', 'under_defect_review'), ('defect_review_requested_by', 'defect_review_requested_by'), ('is_Mitigated', 'is_Mitigated'), ('thread_id', 'thread_id'), ('mitigated', 'mitigated'), ('mitigated_by', 'mitigated_by'), ('reporter', 'reporter'), ('numerical_severity', 'numerical_severity'), ('last_reviewed', 'last_reviewed'), ('last_reviewed_by', 'last_reviewed_by'), ('line_number', 'line_number'), ('sourcefilepath', 'sourcefilepath'), ('sourcefile', 'sourcefile'), ('param', 'param'), ('payload', 'payload'), ('hash_code', 'hash_code'), ('line', 'line'), ('file_path', 'file_path'), ('component_name', 'component_name'), ('component_version', 'component_version'), ('static_finding', 'static_finding'), ('dynamic_finding', 'dynamic_finding'), ('created', 'created'), ('scanner_confidence', 'scanner_confidence'), ('sonarqube_issue', 'sonarqube_issue'), ('unique_id_from_tool', 'unique_id_from_tool'), ('vuln_id_from_tool', 'vuln_id_from_tool'), ('sast_source_object', 'sast_source_object'), ('sast_sink_object', 'sast_sink_object'), ('sast_source_line', 'sast_source_line'), ('sast_source_file_path', 'sast_source_file_path'), ('nb_occurences', 'nb_occurences')], max_length=200),
311245
),
312-
313-
migrations.RunPython(copy_tags_from_django_tagging_field_to_new_tagulous_tags_field, migrations.RunPython.noop),
314246
]

dojo/settings/settings.dist.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,6 @@
9191
DD_WATSON_ASYNC_INDEX_UPDATE_BATCH_SIZE=(int, 1000),
9292
DD_FOOTER_VERSION=(str, ""),
9393
# models should be passed to celery by ID, default is False (for now)
94-
DD_FORCE_LOWERCASE_TAGS=(bool, True),
95-
DD_MAX_TAG_LENGTH=(int, 25),
9694
DD_DATABASE_ENGINE=(str, "django.db.backends.postgresql"),
9795
DD_DATABASE_HOST=(str, "postgres"),
9896
DD_DATABASE_NAME=(str, "defectdojo"),
@@ -781,11 +779,6 @@ def generate_url(scheme, double_slashes, user, password, host, port, path, param
781779
# Used to configure a custom version in the footer of the base.html template.
782780
FOOTER_VERSION = env("DD_FOOTER_VERSION")
783781

784-
# Django-tagging settings
785-
FORCE_LOWERCASE_TAGS = env("DD_FORCE_LOWERCASE_TAGS")
786-
MAX_TAG_LENGTH = env("DD_MAX_TAG_LENGTH")
787-
788-
789782
# ------------------------------------------------------------------------------
790783
# ADMIN
791784
# ------------------------------------------------------------------------------
@@ -890,7 +883,6 @@ def generate_url(scheme, double_slashes, user, password, host, port, path, param
890883
"auditlog",
891884
"dojo",
892885
"watson",
893-
"tagging", # not used, but still needed for migration 0065_django_tagulous.py (v1.10.0)
894886
"imagekit",
895887
"multiselectfield",
896888
"rest_framework",

requirements.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,6 @@ django-polymorphic==4.1.0
1515
django-crispy-forms==2.4
1616
django_extensions==4.1
1717
django-slack==5.19.0
18-
# This library is very outdated and not directly. It is used solely for migration
19-
# purposes to django-tagulous, so it must stay
20-
# django-tagging==0.5.0
21-
git+https://github.com/DefectDojo/django-tagging@develop#egg=django-tagging
2218
django-watson==1.6.3
2319
django-prometheus==2.4.1
2420
Django==5.1.12

0 commit comments

Comments
 (0)