diff --git a/ghostwriter/reporting/migrations/0053_alter_evidence_document.py b/ghostwriter/reporting/migrations/0053_alter_evidence_document.py new file mode 100644 index 000000000..30aa41697 --- /dev/null +++ b/ghostwriter/reporting/migrations/0053_alter_evidence_document.py @@ -0,0 +1,20 @@ +# Generated by Django 3.2.19 on 2024-06-13 20:53 + +from django.db import migrations, models +import ghostwriter.reporting.models +import ghostwriter.reporting.validators + + +class Migration(migrations.Migration): + + dependencies = [ + ('reporting', '0052_auto_20240516_1722'), + ] + + operations = [ + migrations.AlterField( + model_name='evidence', + name='document', + field=models.FileField(blank=True, max_length=255, upload_to=ghostwriter.reporting.models.set_evidence_upload_destination, validators=[ghostwriter.reporting.validators.validate_evidence_extension]), + ), + ] diff --git a/ghostwriter/reporting/models.py b/ghostwriter/reporting/models.py index 36b56677e..535f4168d 100644 --- a/ghostwriter/reporting/models.py +++ b/ghostwriter/reporting/models.py @@ -679,6 +679,7 @@ class Evidence(models.Model): upload_to=set_evidence_upload_destination, validators=[validate_evidence_extension], blank=True, + max_length=255, ) friendly_name = models.CharField( "Friendly Name", diff --git a/ghostwriter/reporting/tests/test_models.py b/ghostwriter/reporting/tests/test_models.py index 6dbc258d1..1ffbf9226 100644 --- a/ghostwriter/reporting/tests/test_models.py +++ b/ghostwriter/reporting/tests/test_models.py @@ -529,6 +529,21 @@ def test_prop_filename(self): except Exception: self.fail("Evidence model `filename` property failed unexpectedly!") + def test_long_filename(self): + name = "In-mi-nisi-dignissim-nec-eleifend-sed-porta-eu-lacus-Sed-nunc-nisl-tristique-at-enim-bibendum-rutrum-sodales-ligula-Aliquam-quis-pharetra-sem-Morbi-nec-vestibulum-nunc-Nullam-urna-tortor-venenatis-et-nisi-ac-" + \ + "fringilla-sodales-sed.txt" + evidence = EvidenceOnFindingFactory( + document=factory.django.FileField( + filename=name, + data=b"lorem ipsum") + ) + self.assertEqual(evidence.filename, name) + try: + evidence.get_absolute_url() + except: + self.fail("Evidence.get_absolute_url() raised an exception") + evidence.delete() + class FindingNoteModelTests(TestCase): """Collection of tests for :model:`reporting.FindingNote`."""