|
10 | 10 | from tastypie.validation import CleanedDataFormValidation |
11 | 11 |
|
12 | 12 | from dojo.models import Product, Engagement, Test, Finding, \ |
13 | | - User, ScanSettings, IPScan, Scan, Stub_Finding, Risk_Acceptance |
| 13 | + User, ScanSettings, IPScan, Scan, Stub_Finding, Risk_Acceptance, Finding_Template |
14 | 14 | from dojo.forms import ProductForm, EngForm2, TestForm, \ |
15 | | - ScanSettingsForm, FindingForm, StubFindingForm |
| 15 | + ScanSettingsForm, FindingForm, StubFindingForm, FindingTemplateForm |
16 | 16 |
|
17 | 17 | """ |
18 | 18 | Setup logging for the api |
@@ -420,7 +420,7 @@ class FindingResource(BaseModelResource): |
420 | 420 | class Meta: |
421 | 421 | resource_name = 'findings' |
422 | 422 | queryset = Finding.objects.select_related("test") |
423 | | - # deleting of findings is not allowed via UI or API. |
| 423 | + # deleting of findings is not allowed via API. |
424 | 424 | # Admin interface can be used for this. |
425 | 425 | list_allowed_methods = ['get', 'post'] |
426 | 426 | detail_allowed_methods = ['get', 'post', 'put'] |
@@ -458,6 +458,55 @@ def dehydrate(self, bundle): |
458 | 458 | "/api/v1/products/%s/" % engagement[0].product.id |
459 | 459 | return bundle |
460 | 460 |
|
| 461 | +""" |
| 462 | + /api/v1/finding_templates/ |
| 463 | + GET [/id/], DELETE [/id/] |
| 464 | + Expects: no params or test_id |
| 465 | + Returns test: ALL or by test_id |
| 466 | + Relevant apply filter ?active=True, ?id=?, ?severity=? |
| 467 | +
|
| 468 | + POST, PUT [/id/] |
| 469 | + Expects *title, *severity, *description, *mitigation, *impact, |
| 470 | + *endpoint, *test, cwe, active, false_p, verified, |
| 471 | + mitigated, *reporter |
| 472 | +
|
| 473 | +""" |
| 474 | + |
| 475 | + |
| 476 | +class FindingTemplateResource(BaseModelResource): |
| 477 | + |
| 478 | + class Meta: |
| 479 | + resource_name = 'finding_templates' |
| 480 | + queryset = Finding_Template.objects.all() |
| 481 | + excludes= ['numerical_severity'] |
| 482 | + # deleting of Finding_Template is not allowed via API. |
| 483 | + # Admin interface can be used for this. |
| 484 | + list_allowed_methods = ['get', 'post'] |
| 485 | + detail_allowed_methods = ['get', 'post', 'put'] |
| 486 | + include_resource_uri = True |
| 487 | + """ |
| 488 | + title = models.TextField(max_length=1000) |
| 489 | + cwe = models.IntegerField(default=None, null=True, blank=True) |
| 490 | + severity = models.CharField(max_length=200, null=True, blank=True) |
| 491 | + description = models.TextField(null=True, blank=True) |
| 492 | + mitigation = models.TextField(null=True, blank=True) |
| 493 | + impact = models.TextField(null=True, blank=True) |
| 494 | + references = models.TextField(null=True, blank=True, db_column="refs") |
| 495 | + numerical_severity |
| 496 | + """ |
| 497 | + filtering = { |
| 498 | + 'id': ALL, |
| 499 | + 'title': ALL, |
| 500 | + 'cwe': ALL, |
| 501 | + 'severity': ALL, |
| 502 | + 'description': ALL, |
| 503 | + 'mitigated': ALL, |
| 504 | + } |
| 505 | + authentication = DojoApiKeyAuthentication() |
| 506 | + authorization = DjangoAuthorization() |
| 507 | + serializer = Serializer(formats=['json']) |
| 508 | + validation = CleanedDataFormValidation(form_class=FindingTemplateForm) |
| 509 | + |
461 | 510 |
|
462 | 511 | class StubFindingResource(BaseModelResource): |
463 | 512 | reporter = fields.ForeignKey(UserResource, 'reporter', null=False) |
|
0 commit comments