Skip to content

Commit 6d1c007

Browse files
Add tests and change note
1 parent 221c189 commit 6d1c007

File tree

6 files changed

+41
-0
lines changed

6 files changed

+41
-0
lines changed

python/ql/lib/semmle/python/Frameworks.qll

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ private import semmle.python.frameworks.Simplejson
7373
private import semmle.python.frameworks.SqlAlchemy
7474
private import semmle.python.frameworks.Starlette
7575
private import semmle.python.frameworks.Stdlib
76+
private import semmle.python.frameworks.Streamlit
7677
private import semmle.python.frameworks.Toml
7778
private import semmle.python.frameworks.Torch
7879
private import semmle.python.frameworks.Tornado
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
category: minorAnalysis
3+
---
4+
* Added models of `streamlit` PyPI package.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
import python
2+
import experimental.meta.ConceptsTest
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
testFailures
2+
failures
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import python
2+
import semmle.python.dataflow.new.RemoteFlowSources
3+
import TestUtilities.InlineExpectationsTest
4+
private import semmle.python.dataflow.new.internal.PrintNode
5+
6+
module SourceTest implements TestSig {
7+
string getARelevantTag() { result = "source" }
8+
9+
predicate hasActualResult(Location location, string element, string tag, string value) {
10+
exists(location.getFile().getRelativePath()) and
11+
exists(RemoteFlowSource rfs |
12+
location = rfs.getLocation() and
13+
element = rfs.toString() and
14+
value = prettyNode(rfs) and
15+
tag = "source"
16+
)
17+
}
18+
}
19+
20+
import MakeTest<SourceTest>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import streamlit as st
2+
3+
# Streamlit sources
4+
inp = st.text_input("Query the database") # $ source=st.text_input(..)
5+
area = st.text_area("Area") # $ source=st.text_area(..)
6+
chat = st.chat_input("Chat") # $ source=st.chat_input(..)
7+
8+
# Initialize connection.
9+
conn = st.connection("postgresql", type="sql")
10+
11+
# SQL injection sink
12+
q = conn.query("some sql") # $ getSql="some sql"

0 commit comments

Comments
 (0)