-
Notifications
You must be signed in to change notification settings - Fork 1.8k
C++: Add ComPtr
MaD models
#20301
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
C++: Add ComPtr
MaD models
#20301
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 MaD (Modeling as Data) models for Microsoft's ComPtr
template class, which is a smart pointer used extensively in Windows development. The models enable proper data flow tracking through ComPtr
operations, resulting in an ~11% increase in summary local flow steps on Microsoft codebases.
- Adds comprehensive MaD models for
ComPtr
constructors, methods, and operations - Includes test coverage with taint flow scenarios for various
ComPtr
operations - Updates expected test results to reflect the new data flow capabilities
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
Show a summary per file
File | Description |
---|---|
cpp/ql/lib/ext/ComPtr.model.yml | Defines MaD models for ComPtr constructors, methods like Get/Detach/CopyTo, and data flow patterns |
cpp/ql/test/library-tests/dataflow/taint-tests/atl.cpp | Adds comprehensive test cases for ComPtr taint tracking scenarios |
cpp/ql/test/library-tests/dataflow/taint-tests/localTaint.expected | Updates expected results for local taint flow tests |
cpp/ql/test/library-tests/dataflow/taint-tests/test_mad-signatures.expected | Updates expected MaD signature matching results |
cpp/ql/test/library-tests/dataflow/external-models/validatemodels.expected | Updates model validation results |
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.
One small comment. Otherwise this LGTM, assuming DCA is happy.
int x = source<int>(); | ||
Microsoft::WRL::ComPtr<int> p1(new int(x)); | ||
int *raw = nullptr; | ||
p1.CopyTo(&raw); |
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.
This is using the template version right? I seem to be missing a test for the non-template, 1 argument version?
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.
DCA was uneventful (as expected since we dont have a lot of these things covered in DCA) |
This is (unsurprisingly) quite an important model to Microsoft.
I've tested it on a random Microsoft database I had locally, and the number of summary local flow steps goes up by ~11% 🎉