Skip to content

Commit

Permalink
removed drf spectacular
Browse files Browse the repository at this point in the history
  • Loading branch information
mlodic committed Sep 2, 2024
1 parent 1b83ae5 commit 81bce6a
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 29 deletions.
19 changes: 0 additions & 19 deletions api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,8 @@
from django.db.models import Count, Q
from django.db.models.functions import Trunc
from django.http import HttpResponse, HttpResponseServerError, StreamingHttpResponse
from drf_spectacular.utils import extend_schema as add_docs
from drf_spectacular.utils import inline_serializer
from greedybear.consts import FEEDS_LICENSE, GET, PAYLOAD_REQUEST, SCANNER
from greedybear.models import IOC, GeneralHoneypot, Statistics, viewType
from rest_framework import serializers as rfs
from rest_framework import status, viewsets
from rest_framework.decorators import action, api_view, authentication_classes, permission_classes
from rest_framework.permissions import IsAuthenticated
Expand All @@ -42,8 +39,6 @@ def write(self, value):
return value


# The Doc does not work as intended. We should refactor this by correctly leveraging DRF
@add_docs(description="Extract Structured IOC Feeds from GreedyBear")
@api_view([GET])
def feeds(request, feed_type, attack_type, age, format_):
"""
Expand Down Expand Up @@ -255,20 +250,6 @@ def feeds_response(request, iocs, feed_type, format_, dict_only=False):
return Response(resp_data, status=status.HTTP_200_OK)


# The Doc does not work as intended. We should refactor this by correctly leveraging DRF
@add_docs(
description="Request if a specific observable (domain or IP address) has been listed by GreedyBear",
request=inline_serializer(
name="EnrichmentSerializerRequest",
fields={"query": rfs.CharField()},
),
responses={
200: inline_serializer(
name="EnrichmentSerializerResponse",
fields={"found": rfs.BooleanField(), "ioc": IOCSerializer},
),
},
)
@api_view([GET])
@authentication_classes([CookieTokenAuthentication])
@permission_classes([IsAuthenticated])
Expand Down
11 changes: 2 additions & 9 deletions greedybear/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
print("you are in production mode: closing the application")
exit(9)

if ELASTIC_ENDPOINT:
if ELASTIC_ENDPOINT and STAGE != STAGE_CI:
ELASTIC_CLIENT = Elasticsearch(
ELASTIC_ENDPOINT,
maxsize=20,
Expand All @@ -51,11 +51,6 @@
DEFAULT_SLACK_CHANNEL = os.environ.get("DEFAULT_SLACK_CHANNEL", "")

VERSION = os.environ.get("REACT_APP_GREEDYBEAR_VERSION", "")
# drf-spectacular
SPECTACULAR_SETTINGS = {
"TITLE": "GreedyBear API specification",
"VERSION": VERSION,
}

CSRF_COOKIE_SAMESITE = "Strict"
CSRF_COOKIE_HTTPONLY = True
Expand All @@ -78,7 +73,6 @@
"django.contrib.postgres",
# rest framework libs
"rest_framework",
"drf_spectacular",
"api.apps.ApiConfig",
# certego libs
"durin",
Expand All @@ -90,7 +84,7 @@
"greedybear.apps.GreedyBearConfig",
"authentication",
# auth
"" "rest_email_auth",
"rest_email_auth",
]

# required by the certego-saas, but GreedyBear doesn't use the recaptcha, for this reason is filled with a placeholder
Expand All @@ -102,7 +96,6 @@
"EXCEPTION_HANDLER": "certego_saas.ext.exceptions.custom_exception_handler",
# Auth
"DEFAULT_AUTHENTICATION_CLASSES": ["certego_saas.apps.auth.backend.CookieTokenAuthentication"],
"DEFAULT_SCHEMA_CLASS": "drf_spectacular.openapi.AutoSchema",
# Pagination
"DEFAULT_PAGINATION_CLASS": "certego_saas.ext.pagination.CustomPageNumberPagination",
"PAGE_SIZE": 10,
Expand Down
1 change: 0 additions & 1 deletion requirements/project-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ djangorestframework==3.15.2
django-rest-email-auth==4.0.3
django-ses==4.1.1

drf-spectacular==0.26.2
psycopg2-binary==2.9.9

certego-saas==0.7.11
Expand Down

0 comments on commit 81bce6a

Please sign in to comment.