Python: Fix minor problems in security examples

This commit is contained in:
Rasmus Wriedt Larsen
2020-01-31 11:33:11 +01:00
parent 5bc592514a
commit 27a7d09c94
2 changed files with 1 additions and 3 deletions

View File

@@ -11,7 +11,6 @@ urlpatterns = [
def user_picture1(request):
"""A view that is vulnerable to malicious file access."""
base_path = '/server/static/images'
filename = request.GET.get('p')
# BAD: This could read any file on the file system
data = open(filename, 'rb').read()

View File

@@ -20,5 +20,4 @@ def command_execution_safe(request):
if request.method == 'POST':
action = request.POST.get('action', '')
#GOOD -- Use a whitelist
subprocess.call(["application", COMMAND[action]])
subprocess.call(["application", COMMANDS[action]])