-
Notifications
You must be signed in to change notification settings - Fork 27
FIX: S360 Resolve [CodeQL.SM02986] 'Cast from char* to wchar_t* #309
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds suppression comments for CodeQL static analysis warnings (SM02986) related to reinterpret_cast operations when converting raw byte buffers to wide character types (SQLWCHAR* and wchar_t*) in the LOB data fetching function.
Key changes:
- Added inline comments justifying the safety of three
reinterpret_castoperations - Comments explain alignment guarantees from
std::vectorand ODBC driver behavior
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
📊 Code Coverage Report
Diff CoverageDiff: main...HEAD, staged and unstaged changes
Summary
📋 Files Needing Attention📉 Files with overall lowest coverage (click to expand)mssql_python.pybind.ddbc_bindings.cpp: 70.9%
mssql_python.pybind.connection.connection_pool.cpp: 78.9%
mssql_python.ddbc_bindings.py: 79.6%
mssql_python.pybind.connection.connection.cpp: 81.2%
mssql_python.connection.py: 82.9%
mssql_python.auth.py: 87.1%
mssql_python.pooling.py: 87.7%
mssql_python.helpers.py: 88.9%
mssql_python.__init__.py: 90.7%
mssql_python.exceptions.py: 92.1%🔗 Quick Links
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor comment addition request
| if (isWideChar) { | ||
| #if defined(_WIN32) | ||
| std::wstring wstr(reinterpret_cast<const wchar_t*>(buffer.data()), buffer.size() / sizeof(wchar_t)); | ||
| size_t wcharCount = buffer.size() / sizeof(wchar_t); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we add some comments around the changes? also, can add a pointer referencing a small description of the s360 issue.
Work Item / Issue Reference
Summary
This pull request adds explanatory comments to several
reinterpret_caststatements in theFetchLobColumnDatafunction withinmssql_python/pybind/ddbc_bindings.cpp, clarifying the safety of these casts for CodeQL static analysis. The comments explain why casting fromstd::vectordata to wide character pointers is safe in this context.Code safety and documentation improvements:
reinterpret_cast<const SQLWCHAR*>(chunk.data())and similar casts, explaining alignment guarantees and safe usage for CodeQL [SM02986] in both Windows and Linux/macOS code paths. [1] [2]