-
Notifications
You must be signed in to change notification settings - Fork 1.7k
C++: Add more Win32 flow sources #19591
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 more Win32 flow sources #19591
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
Adds Win32-specific dataflow tests and models for file reading and memory mapping APIs.
- Extends
windows.cpp
test suite with ReadFile, ReadFileEx, NtReadFile, and various MapViewOfFile calls. - Updates
sources.expected
andflow.expected
to include flows from the new APIs. - Adds new entries in
Windows.model.yml
and documents the feature in change notes.
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
File | Description |
---|---|
cpp/ql/test/library-tests/dataflow/external-models/windows.cpp | Added tests for ReadFile, ReadFileEx, NtReadFile, and MapViewOfFile* |
cpp/ql/test/library-tests/dataflow/external-models/sources.expected | Added expected source entries for the new Win32 APIs |
cpp/ql/test/library-tests/dataflow/external-models/flow.expected | Updated provenance entries for the added test flows |
cpp/ql/lib/ext/Windows.model.yml | Defined new flow source models for ReadFile, memory mapping, and NtReadFile |
cpp/ql/lib/change-notes/2025-05-27-windows-sources-2.md | Documented the addition of the new flow source models |
Comments suppressed due to low confidence (1)
cpp/ql/test/library-tests/dataflow/external-models/windows.cpp:158
- [nitpick] The variable name 'p' is ambiguous; a more descriptive name like 'bufferPtr' would improve readability.
char* p = reinterpret_cast<char*>(overlapped.hEvent);
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.
LGTM is DCA is happy. Just some minor nits about documenting where the functions are coming from.
using HANDLE = void*; | ||
using DWORD = unsigned long; | ||
using LPVOID = void*; | ||
using LPDWORD = unsigned long*; | ||
using PVOID = void*; | ||
using ULONG_PTR = unsigned long*; | ||
using SIZE_T = decltype(sizeof(0)); |
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.
We should probably also use these higher up in this file. We can do that as a follow-up.
Co-authored-by: Jeroen Ketema <93738568+jketema@users.noreply.github.com>
Co-authored-by: Jeroen Ketema <93738568+jketema@users.noreply.github.com>
Co-authored-by: Jeroen Ketema <93738568+jketema@users.noreply.github.com>
char* p = reinterpret_cast<char*>(overlapped.hEvent); | ||
sink(p); | ||
sink(*p); // $ MISSING: ir |
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.
Is this still relevant with the hEvent
model removed?
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.
I guess there's still flow at runtime, right? buffer
and overlapped.hEvent
alias, so the call to ReadFileEx
will also write user-controlled data to overlapped.hEvent
. So if we had proper alias support in dataflow (which we don't) we should get this flow.
DCA was uneventful. Merging! |
This PR adds Win32 specific flow sources related to reading/memory mapping files.