Skip to content
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
15453a1
removed info icon + added settings icon
carellamartina Oct 22, 2024
0526423
Merge branch 'develop' into refactor_plugin_config
carellamartina Oct 22, 2024
bccd005
added new plugin config modals
carellamartina Nov 18, 2024
a3a3efa
refactor
carellamartina Nov 18, 2024
01bd1ea
adjusted analyzer and pivot modals
carellamartina Nov 18, 2024
d0e8577
adjusted backend tests
carellamartina Nov 18, 2024
0dc5719
adjusted existing tests
carellamartina Nov 18, 2024
73b29d6
adjusted pivots tests
carellamartina Nov 18, 2024
e2fd761
frontend tests
carellamartina Nov 19, 2024
0ae9a47
adjusted PluginConfigViewSet
carellamartina Nov 20, 2024
ea675f5
prettier
carellamartina Nov 20, 2024
d1c58e2
fixed test
carellamartina Nov 21, 2024
6b640bf
fix
carellamartina Nov 21, 2024
716f5c5
fixes
carellamartina Nov 21, 2024
14805b0
frontend tests
carellamartina Nov 21, 2024
f310fc5
fixed PluginConfigModal
carellamartina Nov 21, 2024
5a35b3b
changes
carellamartina Nov 26, 2024
6906aae
prettier
carellamartina Nov 26, 2024
be463f6
Merge branch 'develop' into refactor_plugin_config
carellamartina Nov 26, 2024
5c7e77d
fixes
carellamartina Nov 27, 2024
bed5df7
adjusted view
carellamartina Nov 27, 2024
65a18e6
fix
carellamartina Nov 28, 2024
9f04d71
Merge branch 'develop' into refactor_plugin_config
carellamartina Nov 28, 2024
00f1b0c
black
carellamartina Nov 28, 2024
02d6302
Merge branch 'develop' into refactor_plugin_config
carellamartina Dec 2, 2024
b043349
fixes
carellamartina Dec 9, 2024
8ff7d96
fix
carellamartina Dec 9, 2024
7cc418d
fix
carellamartina Dec 9, 2024
6b97307
fix
carellamartina Dec 9, 2024
d2fd738
fixes
carellamartina Dec 10, 2024
8154044
prettier
carellamartina Dec 10, 2024
30f8160
fixes
carellamartina Dec 11, 2024
0470ce1
adjusted org note
carellamartina Dec 12, 2024
6a1e697
changes
carellamartina Dec 16, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 1 addition & 37 deletions api_app/analyzers_manager/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
# See the file 'LICENSE' for copying permission.
from rest_framework import serializers as rfs

from ..models import PluginConfig, PythonModule
from ..models import PythonModule
from ..serializers.plugin import (
PluginConfigSerializer,
PythonConfigSerializer,
PythonConfigSerializerForMigration,
)
Expand All @@ -27,9 +26,6 @@ class Meta:


class AnalyzerConfigSerializer(PythonConfigSerializer):
plugin_config = rfs.ListField(
child=rfs.DictField(), write_only=True, required=False
)
python_module = rfs.SlugRelatedField(
queryset=PythonModule.objects.all(), slug_field="module"
)
Expand All @@ -39,38 +35,6 @@ class Meta:
exclude = PythonConfigSerializer.Meta.exclude
list_serializer_class = PythonConfigSerializer.Meta.list_serializer_class

def create(self, validated_data):
plugin_config = validated_data.pop("plugin_config", {})
pc = super().create(validated_data)

# create plugin config
for config in plugin_config:
plugin_config_serializer = PluginConfigSerializer(
data=config, context={"request": self.context["request"]}
)
plugin_config_serializer.is_valid(raise_exception=True)
plugin_config_serializer.save()
return pc

def update(self, instance, validated_data):
plugin_config = validated_data.pop("plugin_config", [])
pc = super().update(instance, validated_data)

# update plugin config
for config in plugin_config:
plugin_config_serializer = PluginConfigSerializer(
data=config, context={"request": self.context["request"]}
)
plugin_config_serializer.is_valid(raise_exception=True)
PluginConfig.objects.filter(
owner=self.context["request"].user,
analyzer_config=plugin_config_serializer.validated_data[
"analyzer_config"
],
parameter=plugin_config_serializer.validated_data["parameter"],
).update_or_create(plugin_config_serializer.validated_data)
return pc


class AnalyzerConfigSerializerForMigration(PythonConfigSerializerForMigration):
class Meta:
Expand Down
11 changes: 10 additions & 1 deletion api_app/analyzers_manager/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@
from django.urls import include, path
from rest_framework import routers

from .views import AnalyzerActionViewSet, AnalyzerConfigViewSet
from .views import (
AnalyzerActionViewSet,
AnalyzerConfigViewSet,
AnalyzerPluginConfigViewSet,
)

# Routers provide an easy way of automatically determining the URL conf.
router = routers.DefaultRouter(trailing_slash=False)
Expand All @@ -14,6 +18,11 @@
basename="analyzerreport",
)
router.register(r"analyzer", AnalyzerConfigViewSet, basename="analyzer")
router.register(
r"analyzer/(?P<name>\w+)",
AnalyzerPluginConfigViewSet,
basename="plugin-config-analyzer",
)


urlpatterns = [
Expand Down
6 changes: 5 additions & 1 deletion api_app/analyzers_manager/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from rest_framework import mixins

from ..permissions import isPluginActionsPermission
from ..views import PythonConfigViewSet, PythonReportActionViewSet
from ..views import PluginConfigViewSet, PythonConfigViewSet, PythonReportActionViewSet
from .filters import AnalyzerConfigFilter
from .models import AnalyzerConfig, AnalyzerReport
from .serializers import AnalyzerConfigSerializer
Expand Down Expand Up @@ -41,3 +41,7 @@ class AnalyzerActionViewSet(PythonReportActionViewSet):
@property
def report_model(cls):
return AnalyzerReport


class AnalyzerPluginConfigViewSet(PluginConfigViewSet):
queryset = AnalyzerConfig.objects.all()
11 changes: 10 additions & 1 deletion api_app/connectors_manager/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@
from django.urls import include, path
from rest_framework import routers

from .views import ConnectorActionViewSet, ConnectorConfigViewSet
from .views import (
ConnectorActionViewSet,
ConnectorConfigViewSet,
ConnectorPluginConfigViewSet,
)

# Routers provide an easy way of automatically determining the URL conf.
router = routers.DefaultRouter(trailing_slash=False)
Expand All @@ -14,6 +18,11 @@
basename="connectorreport",
)
router.register(r"connector", ConnectorConfigViewSet, basename="connector")
router.register(
r"connector/(?P<name>\w+)",
ConnectorPluginConfigViewSet,
basename="plugin-config-connector",
)

urlpatterns = [
path(r"", include(router.urls)),
Expand Down
8 changes: 6 additions & 2 deletions api_app/connectors_manager/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

import logging

from ..views import PythonConfigViewSet, PythonReportActionViewSet
from .models import ConnectorReport
from ..views import PluginConfigViewSet, PythonConfigViewSet, PythonReportActionViewSet
from .models import ConnectorConfig, ConnectorReport
from .serializers import ConnectorConfigSerializer

logger = logging.getLogger(__name__)
Expand All @@ -25,3 +25,7 @@ class ConnectorActionViewSet(PythonReportActionViewSet):
@property
def report_model(cls):
return ConnectorReport


class ConnectorPluginConfigViewSet(PluginConfigViewSet):
queryset = ConnectorConfig.objects.all()
10 changes: 9 additions & 1 deletion api_app/ingestors_manager/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,18 @@
from rest_framework import routers

# Routers provide an easy way of automatically determining the URL conf.
from api_app.ingestors_manager.views import IngestorConfigViewSet
from api_app.ingestors_manager.views import (
IngestorConfigViewSet,
IngestorPluginConfigViewSet,
)

router = routers.DefaultRouter(trailing_slash=False)
router.register(r"ingestor", IngestorConfigViewSet, basename="ingestor")
router.register(
r"ingestor/(?P<name>\w+)",
IngestorPluginConfigViewSet,
basename="plugin-config-ingestor",
)

urlpatterns = [
# Viewsets
Expand Down
7 changes: 6 additions & 1 deletion api_app/ingestors_manager/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
from rest_framework import status
from rest_framework.response import Response

from api_app.ingestors_manager.models import IngestorConfig
from api_app.ingestors_manager.serializers import IngestorConfigSerializer
from api_app.views import PythonConfigViewSet
from api_app.views import PluginConfigViewSet, PythonConfigViewSet

logger = logging.getLogger(__name__)

Expand All @@ -20,3 +21,7 @@ def disable_in_org(self, request, pk=None):

def enable_in_org(self, request, pk=None):
return Response(status=status.HTTP_404_NOT_FOUND)


class IngestorPluginConfigViewSet(PluginConfigViewSet):
queryset = IngestorConfig.objects.all()
12 changes: 0 additions & 12 deletions api_app/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1025,18 +1025,6 @@ def plugin_name(self):
"""Returns the name of the plugin associated with this configuration."""
return self.config.name

@property
def type(self):
"""Returns the type of the plugin associated with this configuration."""
# TODO retrocompatibility
return self.config.plugin_type

@property
def config_type(self):
"""Returns the type of the configuration (1 or 2)."""
# TODO retrocompatibility
return "2" if self.is_secret() else "1"


class OrganizationPluginConfiguration(models.Model):
"""
Expand Down
38 changes: 1 addition & 37 deletions api_app/pivots_manager/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@

from api_app.analyzers_manager.models import AnalyzerConfig
from api_app.connectors_manager.models import ConnectorConfig
from api_app.models import Job, PluginConfig, PythonModule
from api_app.models import Job, PythonModule
from api_app.pivots_manager.models import PivotConfig, PivotMap, PivotReport
from api_app.playbooks_manager.models import PlaybookConfig
from api_app.serializers.plugin import (
PluginConfigSerializer,
PythonConfigSerializer,
PythonConfigSerializerForMigration,
)
Expand Down Expand Up @@ -77,9 +76,6 @@ class PivotConfigSerializer(PythonConfigSerializer):
python_module = rfs.SlugRelatedField(
queryset=PythonModule.objects.all(), slug_field="module"
)
plugin_config = rfs.ListField(
child=rfs.DictField(), write_only=True, required=False
)

class Meta:
model = PivotConfig
Expand All @@ -99,38 +95,6 @@ def validate(self, attrs):
)
return attrs

def create(self, validated_data):
plugin_config = validated_data.pop("plugin_config", {})
pc = super().create(validated_data)

# create plugin config
for config in plugin_config:
plugin_config_serializer = PluginConfigSerializer(
data=config, context={"request": self.context["request"]}
)
plugin_config_serializer.is_valid(raise_exception=True)
plugin_config_serializer.save()
return pc

def update(self, instance, validated_data):
plugin_config = validated_data.pop("plugin_config", [])
pc = super().update(instance, validated_data)

# update plugin config
for config in plugin_config:
plugin_config_serializer = PluginConfigSerializer(
data=config, context={"request": self.context["request"]}
)
plugin_config_serializer.is_valid(raise_exception=True)
PluginConfig.objects.filter(
owner=self.context["request"].user,
analyzer_config=plugin_config_serializer.validated_data[
"analyzer_config"
],
parameter=plugin_config_serializer.validated_data["parameter"],
).update_or_create(plugin_config_serializer.validated_data)
return pc


class PivotConfigSerializerForMigration(PythonConfigSerializerForMigration):
related_analyzer_configs = rfs.SlugRelatedField(
Expand Down
9 changes: 8 additions & 1 deletion api_app/pivots_manager/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,18 @@
from rest_framework import routers

# Routers provide an easy way of automatically determining the URL conf.
from api_app.pivots_manager.views import PivotConfigViewSet, PivotMapViewSet
from api_app.pivots_manager.views import (
PivotConfigViewSet,
PivotMapViewSet,
PivotPluginConfigViewSet,
)

router = routers.DefaultRouter(trailing_slash=False)
router.register(r"pivot", PivotConfigViewSet, basename="pivot")
router.register(r"pivot_map", PivotMapViewSet, basename="pivot_map")
router.register(
r"pivot/(?P<name>\w+)", PivotPluginConfigViewSet, basename="plugin-config-pivot"
)

urlpatterns = [
path(r"", include(router.urls)),
Expand Down
10 changes: 9 additions & 1 deletion api_app/pivots_manager/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@
PivotOwnerPermission,
)
from api_app.pivots_manager.serializers import PivotConfigSerializer, PivotMapSerializer
from api_app.views import PythonConfigViewSet, PythonReportActionViewSet
from api_app.views import (
PluginConfigViewSet,
PythonConfigViewSet,
PythonReportActionViewSet,
)


class PivotConfigViewSet(
Expand Down Expand Up @@ -55,3 +59,7 @@ class PivotMapViewSet(viewsets.ReadOnlyModelViewSet):
serializer_class = PivotMapSerializer
lookup_field = "pk"
queryset = PivotMap.objects.all()


class PivotPluginConfigViewSet(PluginConfigViewSet):
queryset = PivotConfig.objects.all()
Loading
Loading