File tree Expand file tree Collapse file tree 3 files changed +27
-1
lines changed
src/semmle/python/frameworks
test/experimental/library-tests/frameworks/stdlib Expand file tree Collapse file tree 3 files changed +27
-1
lines changed Original file line number Diff line number Diff line change 1+ lgtm,codescanning
2+ * Added model of ` sqlite3 ` as SQL interface following PEP249, resulting in additional sinks for ` py/sql-injection ` .
Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ private import semmle.python.dataflow.new.DataFlow
88private import semmle.python.dataflow.new.TaintTracking
99private import semmle.python.dataflow.new.RemoteFlowSources
1010private import semmle.python.Concepts
11+ private import PEP249
1112
1213/** Provides models for the Python standard library. */
1314private module Stdlib {
@@ -1032,6 +1033,29 @@ private module Stdlib {
10321033
10331034 override string getFormat ( ) { result = "JSON" }
10341035 }
1036+
1037+ // ---------------------------------------------------------------------------
1038+ // sqlite3
1039+ // ---------------------------------------------------------------------------
1040+ /** Gets a reference to the `sqlite3` module. */
1041+ private DataFlow:: Node sqlite3 ( DataFlow:: TypeTracker t ) {
1042+ t .start ( ) and
1043+ result = DataFlow:: importNode ( "sqlite3" )
1044+ or
1045+ exists ( DataFlow:: TypeTracker t2 | result = sqlite3 ( t2 ) .track ( t2 , t ) )
1046+ }
1047+
1048+ /** Gets a reference to the `sqlite3` module. */
1049+ DataFlow:: Node sqlite3 ( ) { result = sqlite3 ( DataFlow:: TypeTracker:: end ( ) ) }
1050+
1051+ /**
1052+ * sqlite3 implements PEP 249, providing ways to execute SQL statements against a database.
1053+ *
1054+ * See https://devdocs.io/python~3.9/library/sqlite3
1055+ */
1056+ class Sqlite3 extends PEP249Module {
1057+ Sqlite3 ( ) { this = sqlite3 ( ) }
1058+ }
10351059}
10361060
10371061// ---------------------------------------------------------------------------
Original file line number Diff line number Diff line change 55db .execute ("some sql" , (42 ,)) # $ MISSING: getSql="some sql"
66
77cursor = db .cursor ()
8- cursor .execute ("some sql" , (42 ,)) # $ MISSING: getSql="some sql"
8+ cursor .execute ("some sql" , (42 ,)) # $ getSql="some sql"
You can’t perform that action at this time.
0 commit comments