Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@MathiasVP
Copy link
Contributor

This PR adds Win32 specific flow sources related to reading/memory mapping files.

Copilot AI review requested due to automatic review settings May 27, 2025 10:38
@MathiasVP MathiasVP requested a review from a team as a code owner May 27, 2025 10:38
Copy link
Contributor

Copilot AI left a 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 and flow.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);

jketema
jketema previously approved these changes May 27, 2025
Copy link
Contributor

@jketema jketema left a 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.

Comment on lines +33 to +39
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));
Copy link
Contributor

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.

Comment on lines +158 to +160
char* p = reinterpret_cast<char*>(overlapped.hEvent);
sink(p);
sink(*p); // $ MISSING: ir
Copy link
Contributor

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?

Copy link
Contributor Author

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.

@MathiasVP
Copy link
Contributor Author

DCA was uneventful. Merging!

@MathiasVP MathiasVP merged commit 8595bd8 into github:main May 27, 2025
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants