Skip to content

Python: modeling of hdbcli #19444

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 1, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/codeql/reusables/supported-frameworks.rst
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ and the CodeQL library pack ``codeql/python-all`` (`changelog <https://github.co
cassandra-driver, Database
clickhouse-driver, Database
cx_Oracle, Database
hdbcli, Database
mysql-connector, Database
mysql-connector-python, Database
MySQL-python, Database
Expand Down
4 changes: 4 additions & 0 deletions python/ql/lib/change-notes/2025-05-01-hdbcli.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
category: minorAnalysis
---
* Added modeling for the `hdbcli` PyPI package as a database library implementing PEP 249.
1 change: 1 addition & 0 deletions python/ql/lib/semmle/python/Frameworks.qll
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ private import semmle.python.frameworks.FlaskAdmin
private import semmle.python.frameworks.FlaskSqlAlchemy
private import semmle.python.frameworks.Genshi
private import semmle.python.frameworks.Gradio
private import semmle.python.frameworks.Hdbcli
private import semmle.python.frameworks.Httpx
private import semmle.python.frameworks.Idna
private import semmle.python.frameworks.Invoke
Expand Down
24 changes: 24 additions & 0 deletions python/ql/lib/semmle/python/frameworks/Hdbcli.qll
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/**
* Provides classes modeling security-relevant aspects of the `hdbcli` PyPI package.
* See https://pypi.org/project/hdbcli/
*/

private import python
private import semmle.python.dataflow.new.RemoteFlowSources
private import semmle.python.Concepts
private import semmle.python.ApiGraphs
private import semmle.python.frameworks.PEP249

/**
* Provides models for the `hdbcli` PyPI package.
* See https://pypi.org/project/hdbcli/
*/
private module Hdbcli {
/**
* A model of `hdbcli` as a module that implements PEP 249, providing ways to execute SQL statements
* against a database.
*/
class HdbcliPEP249 extends PEP249::PEP249ModuleApiNode {
HdbcliPEP249() { this = API::moduleImport("hdbcli").getMember("dbapi") }
}
}
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import python
import experimental.meta.ConceptsTest
9 changes: 9 additions & 0 deletions python/ql/test/library-tests/frameworks/hdbcli/pep249.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from hdbcli import dbapi

conn = dbapi.connect(address="hostname", port=300, user="username", password="password")
cursor = conn.cursor()

cursor.execute("some sql", (42,)) # $ getSql="some sql"
cursor.executemany("some sql", (42,)) # $ getSql="some sql"

cursor.close()