Skip to content

Commit

Permalink
Merge pull request #456 from ColonelThirtyTwo/evidence-long-filenames
Browse files Browse the repository at this point in the history
Increase filename limit for evidences
  • Loading branch information
chrismaddalena authored Jun 17, 2024
2 parents 2b0ad15 + 468e0ac commit c4b79ca
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
20 changes: 20 additions & 0 deletions ghostwriter/reporting/migrations/0053_alter_evidence_document.py
Original file line number Diff line number Diff line change
@@ -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]),
),
]
1 change: 1 addition & 0 deletions ghostwriter/reporting/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
15 changes: 15 additions & 0 deletions ghostwriter/reporting/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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`."""
Expand Down

0 comments on commit c4b79ca

Please sign in to comment.