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

chore: put ruleid annotation alone on its own line for tainted-sql-string.py #3467

Merged
merged 1 commit into from
Sep 5, 2024
Merged
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
18 changes: 12 additions & 6 deletions python/django/security/injection/tainted-sql-string.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ class Person(models.Model):
##### True Positives #########
def get_user_age1(request):
user_name = request.POST.get("user_name")
user_age = Person.objects.raw( # ruleid: tainted-sql-string
user_age = Person.objects.raw(
# ruleid: tainted-sql-string
"SELECT user_age FROM myapp_person where user_name = %s" % user_name
)
html = "<html><body>User Age %s.</body></html>" % user_age
Expand All @@ -19,7 +20,8 @@ def get_user_age1(request):

def get_user_age2(request):
user_name = request.POST.get("user_name")
user_age = Person.objects.raw( # ruleid: tainted-sql-string
user_age = Person.objects.raw(
# ruleid: tainted-sql-string
f"SELECT user_age FROM myapp_person where user_name = {user_name}"
)
html = "<html><body>User Age %s.</body></html>" % user_age
Expand All @@ -28,7 +30,8 @@ def get_user_age2(request):

def get_user_age3(request):
user_name = request.POST.get("user_name")
user_age = Person.objects.raw( # ruleid: tainted-sql-string
user_age = Person.objects.raw(
# ruleid: tainted-sql-string
"SELECT user_age FROM myapp_person where user_name = %s".format(user_name)
)
html = "<html><body>User Age %s.</body></html>" % user_age
Expand All @@ -37,7 +40,8 @@ def get_user_age3(request):

def get_user_age4(request):
user_name = request.POST.get("user_name")
user_age = Person.objects.raw( # ruleid: tainted-sql-string
user_age = Person.objects.raw(
# ruleid: tainted-sql-string
"SELECT user_age FROM myapp_person where user_name = " + user_name
)
html = "<html><body>User Age %s.</body></html>" % user_age
Expand All @@ -63,7 +67,8 @@ def get_user_age6(request):

def get_users1(request):
client_id = request.headers.get("client_id")
users = Person.objects.raw( # ruleid: tainted-sql-string
users = Person.objects.raw(
# ruleid: tainted-sql-string
"SELECT * FROM myapp_person where client_id = %s" % client_id
)
html = "<html><body>Users %s.</body></html>" % users
Expand All @@ -72,7 +77,8 @@ def get_users1(request):

def get_users2(request):
client_id = request.headers.get("client_id")
users = Person.objects.raw( # ruleid: tainted-sql-string
users = Person.objects.raw(
# ruleid: tainted-sql-string
f"SELECT * FROM myapp_person where client_id = {client_id}"
)
html = "<html><body>Users %s.</body></html>" % users
Expand Down
Loading