File tree Expand file tree Collapse file tree 4 files changed +37
-2
lines changed
test/experimental/library-tests/frameworks/pymysql Expand file tree Collapse file tree 4 files changed +37
-2
lines changed Original file line number Diff line number Diff line change 1+ lgtm,codescanning
2+ * Added model of ` PyMySQL ` PyPI package as a SQL interface following PEP249, resulting in additional sinks for ` py/sql-injection ` .
Original file line number Diff line number Diff line change @@ -7,8 +7,9 @@ private import semmle.python.frameworks.Django
77private import semmle.python.frameworks.Fabric
88private import semmle.python.frameworks.Flask
99private import semmle.python.frameworks.Invoke
10- private import semmle.python.frameworks.MySQLdb
1110private import semmle.python.frameworks.MysqlConnectorPython
11+ private import semmle.python.frameworks.MySQLdb
1212private import semmle.python.frameworks.Psycopg2
13+ private import semmle.python.frameworks.PyMySQL
1314private import semmle.python.frameworks.Stdlib
1415private import semmle.python.frameworks.Yaml
Original file line number Diff line number Diff line change 1+ /**
2+ * Provides classes modeling security-relevant aspects of the `PyMySQL` PyPI package.
3+ * See https://pypi.org/project/PyMySQL/
4+ */
5+
6+ private import python
7+ private import semmle.python.dataflow.new.DataFlow
8+ private import semmle.python.dataflow.new.RemoteFlowSources
9+ private import semmle.python.Concepts
10+ private import PEP249
11+
12+ /**
13+ * Provides models for the `PyMySQL` PyPI package.
14+ * See https://pypi.org/project/PyMySQL/
15+ */
16+ private module PyMySQL {
17+ /** Gets a reference to the `pymysql` module. */
18+ private DataFlow:: Node pymysql ( DataFlow:: TypeTracker t ) {
19+ t .start ( ) and
20+ result = DataFlow:: importNode ( "pymysql" )
21+ or
22+ exists ( DataFlow:: TypeTracker t2 | result = pymysql ( t2 ) .track ( t2 , t ) )
23+ }
24+
25+ /** Gets a reference to the `pymysql` module. */
26+ DataFlow:: Node pymysql ( ) { result = pymysql ( DataFlow:: TypeTracker:: end ( ) ) }
27+
28+ /** PyMySQL implements PEP 249, providing ways to execute SQL statements against a database. */
29+ class PyMySQLPEP249 extends PEP249Module {
30+ PyMySQLPEP249 ( ) { this = pymysql ( ) }
31+ }
32+ }
Original file line number Diff line number Diff line change 22connection = pymysql .connect (host = "localhost" , user = "user" , password = "passwd" )
33
44cursor = connection .cursor ()
5- cursor .execute ("some sql" , (42 ,)) # $ MISSING: getSql="some sql"
5+ cursor .execute ("some sql" , (42 ,)) # $ getSql="some sql"
You can’t perform that action at this time.
0 commit comments