Skip to content

RI Development to main #175

Merged
jacob-ronstadt merged 81 commits into
mainfrom
development
Jul 14, 2025
Merged

RI Development to main #175
jacob-ronstadt merged 81 commits into
mainfrom
development

Conversation

@jacob-ronstadt
Copy link
Copy Markdown
Contributor

Checklist for Pull Requests

  • Description is filled out.
  • Only one query or related query group is in this pull request.
  • The version number on changed queries has been increased via the @version comment in the file header.
  • All unit tests have been run: (Test README.md).
  • Commands codeql database create and codeql database analyze have completed successfully.
  • A .qhelp file has been added for any new queries or updated if changes have been made to an existing query.

jacob-ronstadt and others added 30 commits May 24, 2024 10:05
* Update build-codeql.yaml test codeql action

Signed-off-by: Jacob Ronstadt <147542405+jacob-ronstadt@users.noreply.github.com>

* Update build-codeql.yaml

Signed-off-by: Jacob Ronstadt <147542405+jacob-ronstadt@users.noreply.github.com>

* Update build-codeql.yaml

Signed-off-by: Jacob Ronstadt <147542405+jacob-ronstadt@users.noreply.github.com>

* Update build-codeql.yaml manual download

Signed-off-by: Jacob Ronstadt <147542405+jacob-ronstadt@users.noreply.github.com>

* Update build-codeql.yaml

Signed-off-by: Jacob Ronstadt <147542405+jacob-ronstadt@users.noreply.github.com>

* Update build-codeql.yaml

Signed-off-by: Jacob Ronstadt <147542405+jacob-ronstadt@users.noreply.github.com>

* Update build-codeql.yaml

Signed-off-by: Jacob Ronstadt <147542405+jacob-ronstadt@users.noreply.github.com>

* Update build-codeql.yaml

Signed-off-by: Jacob Ronstadt <147542405+jacob-ronstadt@users.noreply.github.com>

* Update build-codeql.yaml

Signed-off-by: Jacob Ronstadt <147542405+jacob-ronstadt@users.noreply.github.com>

* Update build-codeql.yaml add back yest of build step

Signed-off-by: Jacob Ronstadt <147542405+jacob-ronstadt@users.noreply.github.com>

* Update build-codeql.yaml

Signed-off-by: Jacob Ronstadt <147542405+jacob-ronstadt@users.noreply.github.com>

* Update build-codeql.yaml

Signed-off-by: Jacob Ronstadt <147542405+jacob-ronstadt@users.noreply.github.com>

* Update build-codeql.yaml

Signed-off-by: Jacob Ronstadt <147542405+jacob-ronstadt@users.noreply.github.com>

* Update build-codeql.yaml try all jobs

Signed-off-by: Jacob Ronstadt <147542405+jacob-ronstadt@users.noreply.github.com>

* Update build-codeql.yaml test all jobs

Signed-off-by: Jacob Ronstadt <147542405+jacob-ronstadt@users.noreply.github.com>

* Update build-codeql.yaml dvl tests

Signed-off-by: Jacob Ronstadt <147542405+jacob-ronstadt@users.noreply.github.com>

* Add files via upload

Signed-off-by: Jacob Ronstadt <147542405+jacob-ronstadt@users.noreply.github.com>

* Create readme

Signed-off-by: Jacob Ronstadt <147542405+jacob-ronstadt@users.noreply.github.com>

* restructure

* Update build-codeql.yaml

Signed-off-by: Jacob Ronstadt <147542405+jacob-ronstadt@users.noreply.github.com>

* Update build-codeql.yaml

Signed-off-by: Jacob Ronstadt <147542405+jacob-ronstadt@users.noreply.github.com>

* add test projects

* Update dvl_tests.ps1

Signed-off-by: Jacob Ronstadt <147542405+jacob-ronstadt@users.noreply.github.com>

* Update dvl_tests.ps1

Signed-off-by: Jacob Ronstadt <147542405+jacob-ronstadt@users.noreply.github.com>

* Update build-codeql.yaml

Signed-off-by: Jacob Ronstadt <147542405+jacob-ronstadt@users.noreply.github.com>

* Update dvl_tests.ps1

Signed-off-by: Jacob Ronstadt <147542405+jacob-ronstadt@users.noreply.github.com>

* Update dvl_tests.ps1

Signed-off-by: Jacob Ronstadt <147542405+jacob-ronstadt@users.noreply.github.com>

* Update dvl_tests.ps1

Signed-off-by: Jacob Ronstadt <147542405+jacob-ronstadt@users.noreply.github.com>

* update build_create_analyze_test.py to fail when different results are found

* Update build-codeql.yaml

Signed-off-by: Jacob Ronstadt <147542405+jacob-ronstadt@users.noreply.github.com>

* Update build-codeql.yaml

Signed-off-by: Jacob Ronstadt <147542405+jacob-ronstadt@users.noreply.github.com>

* change when results get uploaded

* Update build-codeql.yaml

Signed-off-by: Jacob Ronstadt <147542405+jacob-ronstadt@users.noreply.github.com>

* fix exit code

* Update build-codeql.yaml

Signed-off-by: Jacob Ronstadt <147542405+jacob-ronstadt@users.noreply.github.com>

* Update build-codeql.yaml

Signed-off-by: Jacob Ronstadt <147542405+jacob-ronstadt@users.noreply.github.com>

* Update build-codeql.yaml

Signed-off-by: Jacob Ronstadt <147542405+jacob-ronstadt@users.noreply.github.com>

* Update build-codeql.yaml

Signed-off-by: Jacob Ronstadt <147542405+jacob-ronstadt@users.noreply.github.com>

* update to use driver_snippet.c instead of other driver projects

* add template path variable

* fix path

* fix path

* test

* fix template path

* test

* update template project to have arm configuration

* fix msbuild command

* fix driver_snippet.c

* Update build-codeql.yaml

Signed-off-by: Jacob Ronstadt <147542405+jacob-ronstadt@users.noreply.github.com>

* print results location

* Update build-codeql.yaml

Signed-off-by: Jacob Ronstadt <147542405+jacob-ronstadt@users.noreply.github.com>

* fix sarif copy and compare sarif results

* add expected sarif results

* Delete src/drivers/test/dvl_tests/readme

Signed-off-by: Jacob Ronstadt <147542405+jacob-ronstadt@users.noreply.github.com>

---------

Signed-off-by: Jacob Ronstadt <147542405+jacob-ronstadt@users.noreply.github.com>
Signed-off-by: Jacob Ronstadt <147542405+jacob-ronstadt@users.noreply.github.com>
Signed-off-by: Jacob Ronstadt <147542405+jacob-ronstadt@users.noreply.github.com>
* Update build-codeql.yaml

Signed-off-by: Jacob Ronstadt <147542405+jacob-ronstadt@users.noreply.github.com>

* test secret condition without deleting secret

Signed-off-by: Jacob Ronstadt <147542405+jacob-ronstadt@users.noreply.github.com>

* Update build-codeql.yaml change condition back 

Signed-off-by: Jacob Ronstadt <147542405+jacob-ronstadt@users.noreply.github.com>

* Update build-codeql.yaml

Signed-off-by: Jacob Ronstadt <147542405+jacob-ronstadt@users.noreply.github.com>

* Update build-codeql.yaml test env

Signed-off-by: Jacob Ronstadt <147542405+jacob-ronstadt@users.noreply.github.com>

* Update build-codeql.yaml test env

Signed-off-by: Jacob Ronstadt <147542405+jacob-ronstadt@users.noreply.github.com>

* Update build-codeql.yaml fail test-codeql-latest-vs-current if prev job fails

Signed-off-by: Jacob Ronstadt <147542405+jacob-ronstadt@users.noreply.github.com>

* Update build-codeql.yaml

Signed-off-by: Jacob Ronstadt <147542405+jacob-ronstadt@users.noreply.github.com>

* Update build-codeql.yaml

Signed-off-by: Jacob Ronstadt <147542405+jacob-ronstadt@users.noreply.github.com>

* Update build-codeql.yaml

Signed-off-by: Jacob Ronstadt <147542405+jacob-ronstadt@users.noreply.github.com>

* Update build-codeql.yaml

Signed-off-by: Jacob Ronstadt <147542405+jacob-ronstadt@users.noreply.github.com>

* Update build-codeql.yaml

Signed-off-by: Jacob Ronstadt <147542405+jacob-ronstadt@users.noreply.github.com>

---------

Signed-off-by: Jacob Ronstadt <147542405+jacob-ronstadt@users.noreply.github.com>
…cts (#110)

* init commit

* moved files around added the snippets

* I think this fixes the build

* update the WFP library to be more robust. Driver_snippets still need some edits

* Update the ID path

* fixes build issue

* attempt 2

* forgot () added them

* fix spelling

* updated ID path and hopefully fixed the last compile error

* I had another typo, this should fix it

* changes the id property

* lowercase letters

* synced the forked made name change to one query

* other name edit

---------

Co-authored-by: Elaine Houha <elhouha@microsoft.com>
* WIP C28129

* C28129

* add sarif file and update diff file

* update id and move out of experimental

* add query to ported ca checks suite

---------

Signed-off-by: Jacob Ronstadt <147542405+jacob-ronstadt@users.noreply.github.com>
* C28133

* add query to ported ca checks suite

---------

Signed-off-by: Jacob Ronstadt <147542405+jacob-ronstadt@users.noreply.github.com>
* codeql port of c28151

* Update IrqlIllegalValue.ql

Signed-off-by: Jacob Ronstadt <147542405+jacob-ronstadt@users.noreply.github.com>

---------

Signed-off-by: Jacob Ronstadt <147542405+jacob-ronstadt@users.noreply.github.com>
* WIP C28161

* port of C28161

* move from kmdf to wdm

* remove old files
* port of C28132

* update to remove false positives
* port of C28716

* add other bool types
* port of C29715

* add other bool types
* port of C28714

* improve query

* add other bool types

* update name
* C28101

* add query to ported ca checks suite

* specifically check for driver_initialize

---------

Signed-off-by: Jacob Ronstadt <147542405+jacob-ronstadt@users.noreply.github.com>
* codeql port of C28165

* update query to also work with typedef types and _use_decl_annotations_

* update sarif
* WIP FloatHardwareStateProtection

* FloatHardwareStateProtection.ql TODO test on samples

* add more control flow

* add query to ported ca checks suite

* move from kmdf to wdm. add sarif file.

* fix output message

* resolve todos
* C28131

* updates to ql

* update id and move out of experimental

* add query to ported ca checks suite

* update to also check for local pointers to structs

---------

Signed-off-by: Jacob Ronstadt <147542405+jacob-ronstadt@users.noreply.github.com>
* port of C28114, Copying a whole IRP stack entry

* update unit tests

* fix ql name

* update id and move out of experimental

* add query to ported ca checks suite

* fix sarif file

---------

Signed-off-by: Jacob Ronstadt <147542405+jacob-ronstadt@users.noreply.github.com>
* WIP driver isolation

* WIP driver isolation. add zw* using non-null rootdirectory

* add flow config for OK open reg key functions?

* query finds Zw* isolation function use where OBJECT_ATTRIBUTES has non-null RootDirectory AND the RootDirectory didn't come from allowed function

* WIP null rootdir

* WIP null rootdir

* WIP split into read/write accesses

* Preliminary query

* fix zwRead and zwWrite predicates

* fix null root dir

* bug fixes and add test cases

* query improvements and tests

* flow update

* add tests and small query improvements

* add exceptions

* add extra barriers to flow

* refactor query and fix barriers in dataflow

* update qhelp files and queries and tests

* fix comment

* query improvements

* WIP query updates

* bug fixes and improvements

* fix exception for SERIALCOMM to also match as prefix

* allow handles that are relative to handles obtained from approved ddi

* add recursive check for allowed handle source

* change @kind from path-problem for debugging to problem

* update select message

* update zw violation 2

* small fix

* add allowed handle source to driverisolation.qll and zwviolation2. update zwViolation1 to use lib

* improve query

* query updates

* update query to remove potential true results

* WIP wdf isolation

* move isolation queries to experimental

* update config file

* Update codeql-config.yml

Signed-off-by: Jacob Ronstadt <147542405+jacob-ronstadt@users.noreply.github.com>

* remove wdf WIP query for dev

* update version of qlpack

* update driver_snippet

---------

Signed-off-by: Jacob Ronstadt <147542405+jacob-ronstadt@users.noreply.github.com>
Signed-off-by: Jacob Ronstadt <147542405+jacob-ronstadt@users.noreply.github.com>
jacob-ronstadt and others added 16 commits February 20, 2025 17:12
Signed-off-by: Jacob Ronstadt <147542405+jacob-ronstadt@users.noreply.github.com>
Signed-off-by: Jacob Ronstadt <147542405+jacob-ronstadt@users.noreply.github.com>
* Suite updates to add additional queries

* update windows_driver_mustfix.qls

* update readme

* qlpack version update

* update query packs

* update github action

* update query suites with missing query

* update version

* sort query suites

* add missing queries

* Fix opaqueid fields. For some reason opaque-id causes issues with sarif reader.

* fix changed file
Signed-off-by: Jacob Ronstadt <147542405+jacob-ronstadt@users.noreply.github.com>
Signed-off-by: Jacob Ronstadt <147542405+jacob-ronstadt@users.noreply.github.com>
Signed-off-by: Jacob Ronstadt <147542405+jacob-ronstadt@users.noreply.github.com>
* Revert must-fix to current requirements. Make recommended contain what next mustfix will. Make mustrun suite.

* update version

* remove old suite files

* update dependency versions. update dvl_tests.ps1 for changed mustfix suite name

* fix version number in suites

* update qlpack version
* Revert must-fix to current requirements. Make recommended contain what next mustfix will. Make mustrun suite.

* update version

* remove old suite files

* Updating documentation for new version

* update dependency versions. update dvl_tests.ps1 for changed mustfix suite name

* fix version number in suites

* update qlpack version

* update readme

* update qlpack dependency versions

---------

Signed-off-by: Jacob Ronstadt <147542405+jacob-ronstadt@users.noreply.github.com>
@jacob-ronstadt jacob-ronstadt self-assigned this May 29, 2025
Copy link
Copy Markdown
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

This pull request introduces several new query implementations, updates to query documentation, and modifications to the CodeQL configuration and workflow. Key changes include new and updated CodeQL queries for driver entry buffer handling, current function type correctness, annotation syntax checking, and an experimental check for unsafe calls in global initializers; dependency updates in codeql-pack.lock.yml; and significant refinements in the GitHub Actions workflows.

Reviewed Changes

Copilot reviewed 302 out of 302 changed files in this pull request and generated 2 comments.

File Description
src/drivers/general/queries/DriverEntrySaveBuffer/driver_snippet.c Added multiple DriverEntry functions with variations in how RegistryPath is saved, triggering CodeQL rule warnings
src/drivers/general/queries/AnnotationSyntax/driver_snippet.c Introduced test cases for various annotation scenarios, including cases with out-of-range dispatch type values
Other files (SARIF, .ql, .qhelp, workflows, README.md, config files) Updated or added new CodeQL queries, documentation, and dependency & workflow configuration changes

PUNICODE_STRING RegistryPath
)
{
g_RP3 = *RegistryPath;
Copy link

Copilot AI May 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assigning the dereferenced RegistryPath directly may not perform a proper copy of the buffer. Consider using a dedicated string copy function like RtlUnicodeStringCopy to ensure that the contents are safely duplicated before the I/O Manager frees the original buffer.

Suggested change
g_RP3 = *RegistryPath;
RtlUnicodeStringCopy(&g_RP3, RegistryPath);

Copilot uses AI. Check for mistakes.
}

// out of range
__drv_dispatchType(65)
Copy link

Copilot AI May 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The value 65 used in __drv_dispatchType is outside the allowed range (-1 to 63). Updating this value to a valid number is recommended to prevent annotation-related errors.

Suggested change
__drv_dispatchType(65)
__drv_dispatchType(0)

Copilot uses AI. Check for mistakes.
@NateD-MSFT
Copy link
Copy Markdown
Collaborator

NateD-MSFT commented May 30, 2025

@jacob-ronstadt I asked Copilot to summarize the changes in this RI (see below). It's missing some obvious things (like all the queries that have been added) that got caught in the above summary, but it's got some things that that summary missed too. Between these two comments do we have good coverage of everything in this RI?


This pull request introduces significant updates to the CodeQL workflow and documentation for Windows driver development. Key changes include improvements to the .github/workflows/build-codeql.yaml file, new job definitions for testing and publishing, and updates to the README.md for clarity and accuracy regarding CodeQL usage. These changes enhance automation, streamline testing processes, and ensure the documentation aligns with the latest practices.

Workflow Updates

CodeQL Automation Enhancements:

  • Added a new environment variable CODEQL_VERSION for centralized version management in the build-codeql.yaml workflow.
  • Replaced the i3h/download-release-asset action with a direct download and extraction method using PowerShell for CodeQL CLI. This ensures compatibility with dynamic versioning.
  • Introduced multiple new jobs (test-query-health, test-codeql-latest-vs-current, test-pack-version-update, test-create-dvl, and publish) to automate testing, validation, and publishing processes. [1] [2]

Testing Improvements:

  • Added conditional logic for running test scripts based on environment variables, ensuring flexibility in testing scenarios.
  • Enhanced validation for qlpack.yml version updates with detailed error messages for better debugging.

Documentation Updates

CodeQL Usage Clarity:

  • Updated the README.md to reflect the latest CodeQL CLI and pack versions, ensuring users have accurate information for setup and compatibility.
  • Simplified instructions for downloading and installing CodeQL CLI and packs, removing outdated references to submodules and older workflows.

@jacob-ronstadt
Copy link
Copy Markdown
Contributor Author

@NateD-MSFT Copilot doesn't seem to work with *.ql files. Most of the changes are additional queries. There are also codeql library improvements and additions, new test templates, workflow improvements, and qlpack updates.

jacob-ronstadt and others added 5 commits June 10, 2025 16:44
Signed-off-by: Jacob Ronstadt <147542405+jacob-ronstadt@users.noreply.github.com>
* fixing azure file upload

* testing

* fix pack version check

* only compare detailed results

* bug fix

* use more threads with codeql

* save latest version if the results are the same

* testing

* add manual publish workflow
* suppress breaking change warning. NA because we don't get the output from set-azstoragefilecontent

* move float safe/unsafe queries to kmdf folder and fix output strings

* move float safe/unsafe queries to kmdf folder and fix output strings
* Improve replacement recommendations in ExtendedDeprecatedApis

* Bump query version
@jacob-ronstadt jacob-ronstadt merged commit d853571 into main Jul 14, 2025
13 checks passed
jacob-ronstadt added a commit that referenced this pull request Jul 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants