From 28444739552b31fa42906657f854a6bca7ea915b Mon Sep 17 00:00:00 2001 From: Andrew Grant Date: Sat, 25 Jul 2020 07:27:20 -0400 Subject: [PATCH] Automatically start tests where both SHAs match an already approved engine. This introduces two potential vectors for abuse: 1) Griefing by setting High Prio / TP 2) IF Engine Options exist which could be used maliciously. --- OpenBench/views.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/OpenBench/views.py b/OpenBench/views.py index 76b0e8f..6279148 100644 --- a/OpenBench/views.py +++ b/OpenBench/views.py @@ -396,7 +396,9 @@ def newTest(request): # # # POST : Enabled Users may create new tests. Fields are error checked. # # If an error is found, the creation is aborted and the list of # - # errors is prestented back to the User on the homepage # + # errors is prestented back to the User on the homepage. If both # + # versions of the Engine in the Test have been seen, then we will # + # automatically approve the Test # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # @@ -418,6 +420,18 @@ def newTest(request): username = request.user.username LogEvent.objects.create(data="CREATE", author=username, test=test) + + approved = Test.objects.filter(approved=True) + A = approved.filter( dev__sha=test.dev.sha).exists() + B = approved.filter(base__sha=test.dev.sha).exists() + C = approved.filter( dev__sha=test.base.sha).exists() + D = approved.filter(base__sha=test.base.sha).exists() + + if (A or B) and (C or D): + test.approved = True; test.save() + action = "AUTOAPP P={0} TP={1}".format(test.priority, test.throughput) + LogEvent.objects.create(data=action, author=username, test=test) + return django.http.HttpResponseRedirect('/index/')