Skip to content

Commit

Permalink
fix advisory cannot be created from finding (#142)
Browse files Browse the repository at this point in the history
* closes #141
  • Loading branch information
blockisec committed Jan 21, 2024
1 parent 95a346f commit e40b890
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
3 changes: 1 addition & 2 deletions server/backend/models/advisory.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,9 @@ def create_from_finding(self, finding, **data):
else:
advisory.recommendation = finding.vulnerability.recommendation
for proof in finding.findingimageattachment_set.all():
image_file = ImageFile(proof.image)
image_file = ImageFile(proof.image, name=proof.name)

ImageAttachment.objects.create(
caption=proof.caption,
advisory=advisory,
image=image_file
)
Expand Down
6 changes: 5 additions & 1 deletion server/backend/tests/test_finding_viewset.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
VulnerabilityTemplate,
Advisory,
ProjectVulnerability,
ReportTemplate,
ReportTemplate
)
from backend.models.finding import FindingStatus, Severity
from backend.models.account import Account
Expand Down Expand Up @@ -219,6 +219,10 @@ def setUp(self) -> None:
"affected_versions": "234.2",
}

def test_function(self):
advisory = Advisory.objects.create_from_finding(self.finding1, **self.data)
self.assertIsNotNone(advisory)

def test_pentester1(self):
self.client.force_login(self.pentester1)
self.basic_status_code_check(self.url, self.client.post, 201, data=self.data)
Expand Down

0 comments on commit e40b890

Please sign in to comment.