Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Server/Ticket78/Fix interface api calls on the server side. #79 #87

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
17 changes: 9 additions & 8 deletions server/alpha/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,16 @@ FROM python:3.5
MAINTAINER Leonid Logvinov <[email protected]>
RUN mkdir /dpcs
WORKDIR /dpcs
ADD . /dpcs
ENV DJANGO_SETTINGS_MODULE 'server_django.prod_settings'
ADD ./requirements/ /dpcs/requirements/
RUN pip install -r requirements/requirements.common
RUN pip install -r requirements/requirements.prod
RUN apt-get update && apt-get install -y \
ca-certificates \
nginx \
gettext-base \
&& rm -rf /var/lib/apt/lists/*
ADD . /dpcs
RUN python manage.py check --deploy
RUN python manage.py makemigrations
RUN python manage.py migrate
Expand All @@ -14,16 +20,11 @@ RUN python manage.py migrate alpha
RUN python manage.py collectstatic -v0 --no-input
RUN echo "from django.contrib.auth.models import User; User.objects.create_superuser('admin', '[email protected]', 'pass')" | python manage.py shell

RUN apt-get update && apt-get install -y \
ca-certificates \
nginx \
gettext-base \
&& rm -rf /var/lib/apt/lists/*

COPY nginx.conf /etc/nginx/nginx.conf

EXPOSE 80

RUN nginx

CMD ["gunicorn", "-c", "gunicorn_conf.py", "--chdir", "/dpcs", "server_django.wsgi", "--reload"]
CMD ["gunicorn", "-c", "gunicorn_conf.py", "--chdir", "/dpcs", "server_django.wsgi", "--reload"]

22 changes: 18 additions & 4 deletions server/alpha/alpha/views.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import ast
from rest_framework import status
from rest_framework.decorators import api_view
from rest_framework.response import Response
Expand Down Expand Up @@ -128,8 +129,17 @@ def crash_group_detail(request, pk):
@api_view(['GET', 'POST'])
def crash_report_list(request):
if request.method == 'GET':
reports = CrashReport.objects.all()
serializer = CrashReportSerializer(reports, many=True)
search_string = (request.GET.get('search_string', '')).strip('"')
application_filter = request.GET.get('application_filter', '[]')
# possibly BIG security issue
application_filter = ast.literal_eval(application_filter)
reports_filtered = []
for report in CrashReport.objects.all():
if search_string in report.stderr_output and \
(len(application_filter) == 0 or \
report.application.name in application_filter):
reports_filtered.append(report)
serializer = CrashReportSerializer(reports_filtered, many=True)
return Response(serializer.data)

elif request.method == 'POST':
Expand Down Expand Up @@ -265,8 +275,12 @@ def solution_list(request):
json_resp["solution_ack"]["solution_url"] = solutions_url + str(sol.solution_id)
return Response(json_resp, status=status.HTTP_201_CREATED)
elif request.method == 'GET':
solutions = Solution.objects.all()
serializer = SolutionSerializer(solutions, many=True)
search_string = request.GET.get('search_string', '').strip('"')
filtered_solutions = []
for solution in Solution.objects.all():
if search_string in solution.shell_script:
filtered_solutions.append(solution)
serializer = SolutionSerializer(filtered_solutions, many=True)
return Response(serializer.data)


Expand Down