Python: Rewrite ClickHouse SQL lib modeling

This did turn into a few changes, that maybe could have been split into
separate PRs 🤷

* Rename `ClickHouseDriver` => `ClickhouseDriver`, to better follow
  import name in `.qll` name
* Rewrote modeling to use API graphs
* Split modeling of `aioch` into separate `.qll` file, which does re-use
  the `getExecuteMethodName` predicate. I feel that sharing code between
  the modeling like this was the best approach, and stuck the
  `INTERNAL: Do not use.` labels on both modules.
* I also added handling of keyword arguments (see change in .py files)
This commit is contained in:
Rasmus Wriedt Larsen
2021-05-25 16:13:31 +02:00
parent c9a9535dbc
commit eb1da152a0
7 changed files with 128 additions and 96 deletions

View File

@@ -1,3 +1,3 @@
import python
import experimental.meta.ConceptsTest
import experimental.semmle.python.frameworks.ClickHouseDriver
import experimental.semmle.python.frameworks.Aioch

View File

@@ -8,13 +8,13 @@ async def aioch_test():
client = aioch.Client("localhost")
await client.execute(SQL) # $ getSql=SQL
await client.execute(query=SQL) # $ MISSING: getSql=SQL
await client.execute(query=SQL) # $ getSql=SQL
await client.execute_with_progress(SQL) # $ getSql=SQL
await client.execute_with_progress(query=SQL) # $ MISSING: getSql=SQL
await client.execute_with_progress(query=SQL) # $ getSql=SQL
await client.execute_iter(SQL) # $ getSql=SQL
await client.execute_iter(query=SQL) # $ MISSING: getSql=SQL
await client.execute_iter(query=SQL) # $ getSql=SQL
# Using custom client (this has been seen done for the blocking version in

View File

@@ -1,3 +1,3 @@
import python
import experimental.meta.ConceptsTest
import experimental.semmle.python.frameworks.ClickHouseDriver
import experimental.semmle.python.frameworks.ClickhouseDriver

View File

@@ -7,14 +7,14 @@ SQL = "SOME SQL"
# Normal operation
client = clickhouse_driver.client.Client("localhost")
client.execute(SQL) # $ MISSING: getSql=SQL
client.execute(query=SQL) # $ MISSING: getSql=SQL
client.execute(SQL) # $ getSql=SQL
client.execute(query=SQL) # $ getSql=SQL
client.execute_with_progress(SQL) # $ MISSING: getSql=SQL
client.execute_with_progress(query=SQL) # $ MISSING: getSql=SQL
client.execute_with_progress(SQL) # $ getSql=SQL
client.execute_with_progress(query=SQL) # $ getSql=SQL
client.execute_iter(SQL) # $ MISSING: getSql=SQL
client.execute_iter(query=SQL) # $ MISSING: getSql=SQL
client.execute_iter(SQL) # $ getSql=SQL
client.execute_iter(query=SQL) # $ getSql=SQL
# commonly used alias