Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
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()