Skip to content
Open
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
46 changes: 46 additions & 0 deletions sql.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
@csrf_exempt
def injection_sql_lab(request):
if request.user.is_authenticated:
name=request.POST.get(‘name’)
password=request.POST.get(‘pass’)
print(name)
print(password)
if name:
sql_query = “SELECT * FROM introduction_sql_lab_table WHERE id=’“+name+“‘AND password=‘“+password+“’”
sql_instance = sql_lab_table(id=“admin”, password=“65079b006e85a7e798abecb99e47c154”)
sql_instance.save()
sql_instance = sql_lab_table(id=“jack”, password=“jack”)
sql_instance.save()
sql_instance = sql_lab_table(id=“slinky”, password=“b4f945433ea4c369c12741f62a23ccc0”)
sql_instance.save()
sql_instance = sql_lab_table(id=“bloke”, password=“f8d1ce191319ea8f4d1d26e65e130dd5”)
sql_instance.save()
print(sql_query)
try:
user = sql_lab_table.objects.raw(sql_query)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Security control: Static Code Analysis Python Semgrep

Type: Gitlab.Bandit.B611

Description: You should be very careful whenever you write raw SQL. Consider using Django ORM before raw SQL. See https://docs.djangoproject.com/en/3.0/topics/db/sql/#passing-parameters-into-raw

Severity: HIGH

Learn more about this issue



Jit Bot commands and options (e.g., ignore issue)

You can trigger Jit actions by commenting on this PR review:

  • #jit_ignore_fp Ignore and mark this specific single instance of finding as “False Positive”
  • #jit_ignore_accept Ignore and mark this specific single instance of finding as “Accept Risk”
  • #jit_ignore_type_in_file Ignore any finding of type "gitlab.bandit.B611" in sql.py; future occurrences will also be ignored.
  • #jit_undo_ignore Undo ignore command

user = user[0].id
print(user)
except:
return render(
request,
‘Lab_2021/A3_Injection/sql_lab.html’,
{
“wrongpass”:password,
“sql_error”:sql_query
})
if user:
return render(request, ‘Lab_2021/A3_Injection/sql_lab.html’,{“user1":user})
else:
return render(
request,
‘Lab_2021/A3_Injection/sql_lab.html’,
{
“wrongpass”:password,
“sql_error”:sql_query
})
else:
return render(request, ‘Lab_2021/A3_Injection/sql_lab.html’)
else:
return redirect(‘login’)
##----------------------------------------------------------------------------------------------------------
##----------------------------------------------------------------------------------------------------------