diff --git a/python/ql/lib/semmle/python/frameworks/Streamlit.qll b/python/ql/lib/semmle/python/frameworks/Streamlit.qll index d73a8dacb07..1531a99587b 100644 --- a/python/ql/lib/semmle/python/frameworks/Streamlit.qll +++ b/python/ql/lib/semmle/python/frameworks/Streamlit.qll @@ -44,4 +44,14 @@ module Streamlit { override DataFlow::Node getSql() { result in [this.getArg(0), this.getArgByName("sql")] } } +private class StreamlitConnection extends SqlAlchemy::Connection::InstanceSource { + StreamlitConnection() { + this = + API::moduleImport("streamlit") + .getMember("connection") + .getReturn() + .getMember("connect") + .getACall() + } + } } diff --git a/python/ql/test/library-tests/frameworks/streamlit/test.py b/python/ql/test/library-tests/frameworks/streamlit/test.py index 0b827fde83d..fb6dc5c7137 100644 --- a/python/ql/test/library-tests/frameworks/streamlit/test.py +++ b/python/ql/test/library-tests/frameworks/streamlit/test.py @@ -10,3 +10,8 @@ conn = st.connection("postgresql", type="sql") # SQL injection sink q = conn.query("some sql") # $ getSql="some sql" + +# SQLAlchemy connection +c = conn.connect() + +c.execute("other sql") # $ getSql="other sql"