diff --git a/server/alpha/Dockerfile b/server/alpha/Dockerfile index f48a4af..5a7c399 100644 --- a/server/alpha/Dockerfile +++ b/server/alpha/Dockerfile @@ -2,10 +2,16 @@ FROM python:3.5 MAINTAINER Leonid Logvinov 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 @@ -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', 'admin@example.com', '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"] \ No newline at end of file +CMD ["gunicorn", "-c", "gunicorn_conf.py", "--chdir", "/dpcs", "server_django.wsgi", "--reload"] + diff --git a/server/alpha/alpha/views.py b/server/alpha/alpha/views.py index ef9e3ac..2a7f9ea 100644 --- a/server/alpha/alpha/views.py +++ b/server/alpha/alpha/views.py @@ -1,3 +1,4 @@ +import ast from rest_framework import status from rest_framework.decorators import api_view from rest_framework.response import Response @@ -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': @@ -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)