Skip to content

Commit

Permalink
Added some tests for sql injection
Browse files Browse the repository at this point in the history
  • Loading branch information
nsearls-bu committed Apr 11, 2024
1 parent 8e1c69e commit 3993393
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion backend/testing/test_injection.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,19 @@
from uuid import UUID, uuid4
import time
class Test_Analyser(FlaskTests):
def test_user_injection(self):
data = {}
data['file'] = (BytesIO(b"--"), 'test.txt')
# Test with SQL comment. This should make the code crash if not properly sanitized.
response = self.client.post("/create_document", data=data, content_type='multipart/form-data',)
assert response.status_code == 201

response = self.client.post("/create_user", query_string={
"username": "; DROP TABLE USERS",
"email": "joe@bu.edu",
"age": "24",
"first_name": "Joe",
"last_name": "Smith"
})
assert response.status_code == 201

def test_user_uploading(self):
Binary file modified rpc_backend/dump.rdb
Binary file not shown.

0 comments on commit 3993393

Please sign in to comment.