|
| 1 | +/** |
| 2 | + * Provides classes modeling security-relevant aspects of the `cassandra-driver` PyPI package. |
| 3 | + * See https://pypi.org/project/cassandra-driver/ |
| 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 semmle.python.ApiGraphs |
| 11 | +private import semmle.python.frameworks.PEP249 |
| 12 | + |
| 13 | +/** |
| 14 | + * Provides models for the `cassandra-driver` PyPI package. |
| 15 | + * See https://pypi.org/project/cassandra-driver/ |
| 16 | + */ |
| 17 | +private module CassandraDriver { |
| 18 | + /** |
| 19 | + * A cassandra cluster session. |
| 20 | + * |
| 21 | + * see |
| 22 | + * - https://docs.datastax.com/en/developer/python-driver/3.25/api/cassandra/cluster/#cassandra.cluster.Cluster.connect |
| 23 | + * - https://docs.datastax.com/en/developer/python-driver/3.25/api/cassandra/cluster/#cassandra.cluster.Session |
| 24 | + */ |
| 25 | + API::Node session() { |
| 26 | + result = |
| 27 | + API::moduleImport("cassandra") |
| 28 | + .getMember("cluster") |
| 29 | + .getMember("Cluster") |
| 30 | + .getReturn() |
| 31 | + .getMember("connect") |
| 32 | + .getReturn() |
| 33 | + } |
| 34 | + |
| 35 | + /** |
| 36 | + * see https://docs.datastax.com/en/developer/python-driver/3.25/api/cassandra/cluster/#cassandra.cluster.Session.execute |
| 37 | + */ |
| 38 | + class CassandraSessionExecuteCall extends SqlExecution::Range, API::CallNode { |
| 39 | + CassandraSessionExecuteCall() { this = session().getMember("execute").getACall() } |
| 40 | + |
| 41 | + override DataFlow::Node getSql() { result = this.getParameter(0, "query").asSink() } |
| 42 | + } |
| 43 | + |
| 44 | + /** |
| 45 | + * see https://docs.datastax.com/en/developer/python-driver/3.25/api/cassandra/cluster/#cassandra.cluster.Session.execute_async |
| 46 | + */ |
| 47 | + class CassandraSessionExecuteAsyncCall extends SqlConstruction::Range, API::CallNode { |
| 48 | + CassandraSessionExecuteAsyncCall() { this = session().getMember("execute_async").getACall() } |
| 49 | + |
| 50 | + override DataFlow::Node getSql() { result = this.getParameter(0, "query").asSink() } |
| 51 | + } |
| 52 | + |
| 53 | + /** |
| 54 | + * see https://docs.datastax.com/en/developer/python-driver/3.25/api/cassandra/cluster/#cassandra.cluster.Session.prepare |
| 55 | + */ |
| 56 | + class CassandraSessionPrepareCall extends SqlConstruction::Range, API::CallNode { |
| 57 | + CassandraSessionPrepareCall() { this = session().getMember("prepare").getACall() } |
| 58 | + |
| 59 | + override DataFlow::Node getSql() { result = this.getParameter(0, "query").asSink() } |
| 60 | + } |
| 61 | +} |
0 commit comments