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

pi zeugs, db zeugs und aiocoap server #13

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

m1sosoba
Copy link
Collaborator

pi zeugs, db zeugs und aiocoap server



if __name__ == '__main__':
asyncio.run(main())
Copy link
Collaborator

Choose a reason for hiding this comment

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

Misses newline at EOF


con = await Context.create_server_context(root,bind=("0.0.0.0",5555))

request = Message(code=GET, uri="coap://127.0.0.1:5683/resource-lookup/", observe=0)
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: Move host/port into a configuration or as constant at the top of the file

@@ -1,10 +1,10 @@
from coapthon.client.helperclient import HelperClient
host = "127.0.0.1"
host = "2001:db8::814c:35fc:fd31:5fde"
port = 5683
Copy link
Collaborator

@Teufelchen1 Teufelchen1 May 17, 2022

Choose a reason for hiding this comment

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

nit: Configuration constants are usually all uppercase, reference pep8 or use a linter.
E.g. from pep8:

Constants are usually defined on a module level and written in all capital letters with underscores separating
words. Examples include MAX_OVERFLOW and TOTAL.

try:
conn = connect_to_db()
cur = conn.cursor()
cur.execute("INSERT INTO rooms (name) VALUES ('{}')".format(room))
Copy link
Collaborator

Choose a reason for hiding this comment

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

First off, I have no idea how your framework works - so please excuse me if this is dumb;
if I call add_room('my room \'); DROP TABLE *;(\''), wouldn't this exploit the DB?

Copy link

Choose a reason for hiding this comment

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

as discussed offline, I would recommend to use an ORM (e.g SQLAlchemy). Besides simplifying the database workflow (avoiding connections, cursors, raw SQL instructions and post processing), the ORM adds implicitly adds a layer of security that avoid this kind of issues.


/Rooms/room/puzzle (GET)
-> Returns info about puzzle in room
{'name': text, 'room': text, 'state': text}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Top of the Readme is outdated (not touched in this PR)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants