mirror of
https://github.com/github/codeql.git
synced 2026-04-25 08:45:14 +02:00
Merge pull request #17080 from sylwia-budzynska/streamlit
Python: Add Streamlit models
This commit is contained in:
20
python/ql/test/experimental/meta/RemoteFlowSourceTest.qll
Normal file
20
python/ql/test/experimental/meta/RemoteFlowSourceTest.qll
Normal file
@@ -0,0 +1,20 @@
|
||||
import python
|
||||
import semmle.python.dataflow.new.RemoteFlowSources
|
||||
import TestUtilities.InlineExpectationsTest
|
||||
private import semmle.python.dataflow.new.internal.PrintNode
|
||||
|
||||
module SourceTest implements TestSig {
|
||||
string getARelevantTag() { result = "source" }
|
||||
|
||||
predicate hasActualResult(Location location, string element, string tag, string value) {
|
||||
exists(location.getFile().getRelativePath()) and
|
||||
exists(RemoteFlowSource rfs |
|
||||
location = rfs.getLocation() and
|
||||
element = rfs.toString() and
|
||||
value = prettyNode(rfs) and
|
||||
tag = "source"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
import MakeTest<SourceTest>
|
||||
@@ -1,20 +1,2 @@
|
||||
import python
|
||||
import semmle.python.dataflow.new.RemoteFlowSources
|
||||
import TestUtilities.InlineExpectationsTest
|
||||
private import semmle.python.dataflow.new.internal.PrintNode
|
||||
|
||||
module SourceTest implements TestSig {
|
||||
string getARelevantTag() { result = "source" }
|
||||
|
||||
predicate hasActualResult(Location location, string element, string tag, string value) {
|
||||
exists(location.getFile().getRelativePath()) and
|
||||
exists(RemoteFlowSource rfs |
|
||||
location = rfs.getLocation() and
|
||||
element = rfs.toString() and
|
||||
value = prettyNode(rfs) and
|
||||
tag = "source"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
import MakeTest<SourceTest>
|
||||
import experimental.meta.RemoteFlowSourceTest
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
testFailures
|
||||
failures
|
||||
@@ -0,0 +1,2 @@
|
||||
import python
|
||||
import experimental.meta.ConceptsTest
|
||||
@@ -0,0 +1,2 @@
|
||||
testFailures
|
||||
failures
|
||||
@@ -0,0 +1,2 @@
|
||||
import python
|
||||
import experimental.meta.RemoteFlowSourceTest
|
||||
27
python/ql/test/library-tests/frameworks/streamlit/test.py
Normal file
27
python/ql/test/library-tests/frameworks/streamlit/test.py
Normal file
@@ -0,0 +1,27 @@
|
||||
import streamlit as st
|
||||
|
||||
# Streamlit sources
|
||||
inp = st.text_input("Query the database") # $ source=st.text_input(..)
|
||||
area = st.text_area("Area") # $ source=st.text_area(..)
|
||||
chat = st.chat_input("Chat") # $ source=st.chat_input(..)
|
||||
|
||||
# Initialize connection.
|
||||
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"
|
||||
|
||||
# SQL Alchemy session
|
||||
s = conn.session
|
||||
|
||||
s.execute("yet another sql") # $ getSql="yet another sql"
|
||||
|
||||
# SQL Alchemy engine
|
||||
e = st.connection("postgresql", type="sql")
|
||||
|
||||
e.engine.connect().execute("yet yet another sql") # $ getSql="yet yet another sql"
|
||||
Reference in New Issue
Block a user