Skip to content

Commit

Permalink
Publish v0.102
Browse files Browse the repository at this point in the history
  • Loading branch information
MWedl committed Jul 5, 2023
1 parent fca8d0e commit 935327d
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 7 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## v0.102 - 2023-07-05
* Fix serialization of project check messages


## v0.101 - 2023-07-05
* Implement file upload in user notebook
* Optimize image loading in markdown preview
Expand Down
1 change: 0 additions & 1 deletion api/src/reportcreator_api/notifications/views.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from rest_framework import viewsets, mixins, permissions
from rest_framework.settings import api_settings

from reportcreator_api.notifications.models import UserNotification
from reportcreator_api.notifications.serializers import UserNotificationSerializer
from reportcreator_api.users.views import UserSubresourceViewSetMixin

Expand Down
8 changes: 5 additions & 3 deletions api/src/reportcreator_api/pentests/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,7 @@ class PublishPdfOptionsSerializer(serializers.Serializer):


class PdfResponseSerializer(serializers.Serializer):
messages = ErrorMessageSerializer(read_only=True)
messages = ErrorMessageSerializer(many=True, read_only=True)
pdf = extend_schema_field(OpenApiTypes.BYTE)(serializers.CharField(allow_null=True, read_only=True))


Expand Down Expand Up @@ -800,14 +800,16 @@ def update(self, instance, validated_data):


class PentestProjectCheckSerializer(serializers.ModelSerializer):
messages = ErrorMessageSerializer(read_only=True)
messages = ErrorMessageSerializer(many=True, read_only=True)

class Meta:
model = PentestProject
fields = ['messages']

def update(self, instance, validated_data):
return instance.perform_checks()
return {
'messages': instance.perform_checks()
}


class CustomizeProjectTypeSerializer(serializers.ModelSerializer):
Expand Down
19 changes: 17 additions & 2 deletions api/src/reportcreator_api/utils/error_messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import enum
from typing import Optional, Union
from rest_framework import serializers
from rest_framework.fields import to_choices_dict, flatten_choices_dict


class MessageLevel(enum.Enum):
Expand Down Expand Up @@ -76,15 +77,29 @@ def from_dict(cls, data):
})


class EnumChoiceField(serializers.ChoiceField):
def __init__(self, choices, **kwargs):
self.choices_enum = choices
super().__init__(choices=list(map(lambda e: e.value, self.choices_enum)), **kwargs)

def to_internal_value(self, data):
return self.choices_enum(super().to_internal_value(data))

def to_representation(self, value):
if isinstance(value, self.choices_enum):
value = value.value
return super().to_representation(value)


class MessageLocationSerializer(serializers.Serializer):
type = serializers.ChoiceField(choices=list(map(lambda v: v.value, MessageLocationType)))
type = EnumChoiceField(choices=MessageLocationType)
id = serializers.CharField(allow_null=True)
name = serializers.CharField(allow_null=True)
path = serializers.CharField(allow_null=True)


class ErrorMessageSerializer(serializers.Serializer):
level = serializers.ChoiceField(choices=list(map(lambda v: v.value, MessageLevel)))
level = EnumChoiceField(choices=MessageLevel)
message = serializers.CharField()
details = serializers.CharField(allow_null=True)
location = MessageLocationSerializer()
2 changes: 1 addition & 1 deletion deploy/.env
Original file line number Diff line number Diff line change
@@ -1 +1 @@
SYSREPTOR_VERSION=0.101
SYSREPTOR_VERSION=0.102

0 comments on commit 935327d

Please sign in to comment.