Add remoteflowsoucre test

This commit is contained in:
Sylwia Budzynska
2024-07-30 17:20:14 +02:00
parent bfd2e4350b
commit 9741ddb926
3 changed files with 31 additions and 19 deletions

View 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>

View File

@@ -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

View File

@@ -15,3 +15,13 @@ q = conn.query("some sql") # $ getSql="some sql"
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"