forked from pablosnt/rekono
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reduce complexity in critical and complex methods
- Loading branch information
Showing
49 changed files
with
746 additions
and
813 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
DD_FINDING_DATE_FORMAT = '%Y-%m-%d' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
from defectdojo import uploader | ||
from defectdojo.exceptions import (EngagementIdNotFoundException, | ||
InvalidEngagementIdException, | ||
ProductIdNotFoundException) | ||
from defectdojo.serializers import EngagementSerializer | ||
from drf_spectacular.utils import extend_schema | ||
from rest_framework import status | ||
from rest_framework.decorators import action | ||
from rest_framework.response import Response | ||
from rest_framework.viewsets import GenericViewSet | ||
|
||
|
||
class DDScansViewSet(GenericViewSet): | ||
|
||
def get_executions(self): | ||
return [] | ||
|
||
@extend_schema(request=EngagementSerializer, responses={200: None}) | ||
@action( | ||
detail=True, | ||
methods=['POST'], | ||
url_path='defect-dojo-scans', | ||
url_name='defect-dojo-scans' | ||
) | ||
def defect_dojo_scans(self, request, pk): | ||
serializer = EngagementSerializer(data=request.data) | ||
if serializer.is_valid(): | ||
try: | ||
uploader.upload_executions( | ||
self.get_executions(), | ||
serializer.validated_data.get('engagement_id'), | ||
serializer.validated_data.get('engagement_name'), | ||
serializer.validated_data.get('engagement_description') | ||
) | ||
return Response(status=status.HTTP_200_OK) | ||
except ( | ||
ProductIdNotFoundException, | ||
EngagementIdNotFoundException, | ||
InvalidEngagementIdException | ||
) as ex: | ||
return Response(str(ex), status=status.HTTP_400_BAD_REQUEST) | ||
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST) | ||
|
||
|
||
class DDFindingsViewSet(GenericViewSet): | ||
|
||
def get_findings(self): | ||
return [] | ||
|
||
@extend_schema(request=EngagementSerializer, responses={200: None}) | ||
@action( | ||
detail=True, | ||
methods=['POST'], | ||
url_path='defect-dojo-findings', | ||
url_name='defect-dojo-findings' | ||
) | ||
def defect_dojo_findings(self, request, pk): | ||
serializer = EngagementSerializer(data=request.data) | ||
if serializer.is_valid(): | ||
try: | ||
uploader.upload_findings( | ||
self.get_findings(), | ||
serializer.validated_data.get('engagement_id'), | ||
serializer.validated_data.get('engagement_name'), | ||
serializer.validated_data.get('engagement_description') | ||
) | ||
return Response(status=status.HTTP_200_OK) | ||
except ( | ||
ProductIdNotFoundException, | ||
EngagementIdNotFoundException, | ||
InvalidEngagementIdException | ||
) as ex: | ||
return Response(str(ex), status=status.HTTP_400_BAD_REQUEST) | ||
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Generated by Django 3.2.7 on 2021-11-06 20:15 | ||
|
||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
initial = True | ||
|
||
dependencies = [ | ||
('executions', '0001_initial'), | ||
('processes', '0001_initial'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='execution', | ||
name='step', | ||
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='processes.step'), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.