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

PatchWork AutoFix #16

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ services:

redis:
image: redis:alpine
security_opt:
- no-new-privileges:true
read_only: true

sqli:
build:
Expand Down
11 changes: 4 additions & 7 deletions sqli/dao/student.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ async def get_many(conn: Connection, limit: Optional[int] = None,
q = 'SELECT id, name FROM students'
params = {}
if limit is not None:
q += ' LIMIT + %(limit)s '
q += ' LIMIT %s '
params['limit'] = limit
if offset is not None:
q += ' OFFSET + %(offset)s '
q += ' OFFSET %s '
params['offset'] = offset
async with conn.cursor() as cur:
await cur.execute(q, params)
Expand All @@ -39,9 +39,6 @@ async def get_many(conn: Connection, limit: Optional[int] = None,

@staticmethod
async def create(conn: Connection, name: str):
q = ("INSERT INTO students (name) "
"VALUES ('%(name)s')" % {'name': name})
q = "INSERT INTO students (name) VALUES (%s)"
async with conn.cursor() as cur:
await cur.execute(q)


await cur.execute(q, (name,))
4 changes: 2 additions & 2 deletions sqli/dao/user.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from hashlib import md5
from hashlib import sha256
from typing import NamedTuple, Optional

from aiopg import Connection
Expand Down Expand Up @@ -38,4 +38,4 @@ async def get_by_username(conn: Connection, username: str):
return User.from_raw(await cur.fetchone())

def check_password(self, password: str):
return self.pwd_hash == md5(password.encode('utf-8')).hexdigest()
return self.pwd_hash == sha256(password.encode('utf-8')).hexdigest()