Skip to content

Commit 9741ddb

Browse files
Add remoteflowsoucre test
1 parent bfd2e43 commit 9741ddb

File tree

3 files changed

+31
-19
lines changed

3 files changed

+31
-19
lines changed
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: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,2 @@
11
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>
2+
import experimental.meta.RemoteFlowSourceTest

python/ql/test/library-tests/frameworks/streamlit/test.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,13 @@
1515
c = conn.connect()
1616

1717
c.execute("other sql") # $ getSql="other sql"
18+
19+
# SQL Alchemy session
20+
s = conn.session
21+
22+
s.execute("yet another sql") # $ getSql="yet another sql"
23+
24+
# SQL Alchemy engine
25+
e = st.connection("postgresql", type="sql")
26+
27+
e.engine.connect().execute("yet yet another sql") # $ getSql="yet yet another sql"

0 commit comments

Comments
 (0)