Skip to content

createprojectpackage update#73

Merged
YanVugenfirer merged 3 commits intomasterfrom
package-no-sign
Mar 1, 2026
Merged

createprojectpackage update#73
YanVugenfirer merged 3 commits intomasterfrom
package-no-sign

Conversation

@kostyanf14
Copy link
Contributor

No description provided.

Copilot AI review requested due to automatic review settings February 27, 2026 15:55
@gemini-code-assist
Copy link

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the createprojectpackage PowerShell function by integrating a crucial step to remove digital signatures from driver files prior to packaging. It also introduces a robust error and message reporting mechanism, allowing the function to capture and output detailed action messages and an overall error status, particularly when generating JSON output. This improves the transparency and reliability of the packaging process.

Highlights

  • Enhanced ProjectPackage Object: The New-ProjectPackage function was updated to include iserror status and a messages array, allowing for better error and action reporting.
  • Driver Signature Removal: The createprojectpackage function now automatically removes digital signatures from driver files (.sys, .dll, .exe) using Signtool.exe before packaging.
  • Improved JSON Output: Error and warning messages generated during the packaging process are now captured and included in the JSON output, providing more comprehensive feedback.
  • Comprehensive Error Reporting: The final JSON output of createprojectpackage now reports the overall iserror status and a detailed list of actionMessages.
Changelog
  • tools/toolsHCK.ps1
    • Modified the New-ProjectPackage function to accept and store iserror (boolean) and actionMessages (array of strings) properties.
    • Initialized $actionMessages as an empty array and $iserror as false within the createprojectpackage function.
    • Added logic to iterate through driver files (.sys, .dll, .exe) and remove their digital signatures using Signtool.exe before adding them to the package.
    • Implemented error handling for the Signtool.exe process, setting $iserror to true and logging messages if signature removal fails.
    • Updated the AddDriverResult and AddSupplementalFiles blocks to append relevant messages to $actionMessages and set $iserror if an issue occurs, specifically when $json output is enabled.
    • Modified the final JSON output of createprojectpackage to include the new iserror status and actionMessages array from the New-ProjectPackage object.
    • Adjusted Write-Output statements to also append messages to $actionMessages when $json is true for consistency.
Activity
  • No human activity (comments, reviews, etc.) has been recorded for this pull request yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@kostyanf14
Copy link
Contributor Author

@zjmletang Please review. Is this ok for you?

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request updates the createprojectpackage function to provide more detailed output, especially for JSON consumers. It introduces a mechanism to collect action messages and an error status. The changes are generally good, but I have a few suggestions to improve maintainability and robustness:

  • There is an unused variable that should be removed.
  • A file path has a hardcoded processor architecture which could be problematic.
  • There is significant code duplication and some inconsistencies in logging within the new logic, which could be refactored.
  • There's a minor code style inconsistency in one of the new blocks.

Please see my detailed comments for specifics.

Get-ChildItem -Path $driver -Filter *.pdb -Recurse | ForEach-Object { Move-Item -Path $_.FullName -Destination $symbolPath -Force }

# Remove driver signatures before packaging to avoid embedded company signatures
$driverunsigned = $true

Choose a reason for hiding this comment

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

medium

The variable $driverunsigned is assigned the value $true but is never used afterwards. It should be removed to improve code clarity.

$actionMessages += "Removing signature from file '$($_.FullName)' before packaging"
}

$process = Start-Process -Wait -FilePath "$env:WTTSTDIO\..\Tests\amd64\Signtool.exe" -ArgumentList 'remove', '/s', $_.FullName -PassThru

Choose a reason for hiding this comment

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

medium

The path to Signtool.exe includes a hardcoded amd64 architecture. This might make the script less portable or fail on systems with different architectures. It would be more robust to determine the architecture dynamically if possible.

Comment on lines 2228 to 2246
if (-Not $json) {
if ($AddDriverResult) {
Write-Output "Driver added to package from $driver"
} else {
$iserror = $true
Write-Output "Warning: Driver signability check did not pass"
foreach ($err in $ErrorMessages) { Write-Output " Error: $err" }
foreach ($warn in $WarningMessages) { Write-Output " Warning: $warn" }
}
} else {
if ($AddDriverResult) {
$actionMessages += "Driver added to package from $driver"
} else {
$iserror = $true
$actionMessages += "Driver signability check did not pass"
foreach ($err in $ErrorMessages) { $actionMessages += "Error: $err" }
foreach ($warn in $WarningMessages) { $actionMessages += "Warning: $warn" }
}
}

Choose a reason for hiding this comment

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

medium

This block of code for handling the result of AddDriver has significant duplication between the if (-Not $json) and else branches. This reduces maintainability.

Additionally, there are inconsistencies in the messages being logged:

  • When $AddDriverResult is false, Write-Output prefixes the message with "Warning:", but the message added to $actionMessages does not.
  • The error and warning messages from $ErrorMessages and $WarningMessages are prefixed with two spaces ( ) for Write-Output, but not for $actionMessages.

Consider refactoring this to a single logic path that prepares the messages, and then either prints them or adds them to the array based on the $json flag. This would improve consistency and make the code easier to maintain.

Copy link

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 enhances the createprojectpackage function in the toolsHCK PowerShell script to support error tracking and detailed messaging in JSON output mode. The main purpose is to provide better visibility into package creation operations, particularly around driver signature removal and other actions.

Changes:

  • Extended New-ProjectPackage function to include iserror flag and actionMessages array for tracking errors and operation messages
  • Added automatic signature removal from driver files (.sys, .dll, .exe) before packaging to avoid embedded company signatures
  • Enhanced JSON output mode to capture and return detailed action messages and error status

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 2242 to 2244
$actionMessages += "Driver signability check did not pass"
foreach ($err in $ErrorMessages) { $actionMessages += "Error: $err" }
foreach ($warn in $WarningMessages) { $actionMessages += "Warning: $warn" }
Copy link

Copilot AI Feb 27, 2026

Choose a reason for hiding this comment

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

There is an inconsistency in message formatting between JSON and non-JSON modes. In non-JSON mode (line 2219), the message includes the "Warning:" prefix, but in JSON mode (line 2221), this prefix is omitted. Similarly, lines 2234-2235 include indentation (" Error:", " Warning:") which is absent from the JSON mode version (lines 2243-2244). Consider keeping the same message format for both modes to ensure consistency, or ensure that the JSON consumer is aware that message prefixes and formatting may be missing.

Suggested change
$actionMessages += "Driver signability check did not pass"
foreach ($err in $ErrorMessages) { $actionMessages += "Error: $err" }
foreach ($warn in $WarningMessages) { $actionMessages += "Warning: $warn" }
$actionMessages += "Warning: Driver signability check did not pass"
foreach ($err in $ErrorMessages) { $actionMessages += " Error: $err" }
foreach ($warn in $WarningMessages) { $actionMessages += " Warning: $warn" }

Copilot uses AI. Check for mistakes.
Comment on lines 2206 to 2224
# Remove driver signatures before packaging to avoid embedded company signatures
$driverunsigned = $true
Get-ChildItem -Path $driver -Include *.sys, *.dll, *.exe -Recurse | ForEach-Object {
if (-Not $json) {
Write-Output "Removing signature from file '$($_.FullName)' before packaging"
} else {
$actionMessages += "Removing signature from file '$($_.FullName)' before packaging"
}

$process = Start-Process -Wait -FilePath "$env:WTTSTDIO\..\Tests\amd64\Signtool.exe" -ArgumentList 'remove', '/s', $_.FullName -PassThru
if ($process.ExitCode -ne 0) {
$iserror = $true
if (-Not $json) {
Write-Output "Warning: Failed to remove signature from file '$($_.FullName)'. Signtool exit code: $($process.ExitCode)"
} else {
$actionMessages += "Failed to remove signature from file '$($_.FullName)'. Signtool exit code: $($process.ExitCode)"
}
}
}
Copy link

Copilot AI Feb 27, 2026

Choose a reason for hiding this comment

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

The signature removal operation modifies driver files in place at the path provided by the user. This could permanently alter the original driver files. Consider adding a warning in the function documentation or comments about this destructive operation, or alternatively, copy the driver files to a temporary location before removing signatures to preserve the originals.

Copilot uses AI. Check for mistakes.
Get-ChildItem -Path $driver -Filter *.pdb -Recurse | ForEach-Object { Move-Item -Path $_.FullName -Destination $symbolPath -Force }

# Remove driver signatures before packaging to avoid embedded company signatures
$driverunsigned = $true
Copy link

Copilot AI Feb 27, 2026

Choose a reason for hiding this comment

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

The variable $driverunsigned is assigned but never used anywhere in the function. Consider removing this unused variable declaration.

Suggested change
$driverunsigned = $true

Copilot uses AI. Check for mistakes.
Comment on lines 2268 to 2269
if (-Not $json)
{
Copy link

Copilot AI Feb 27, 2026

Choose a reason for hiding this comment

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

The opening brace placement is inconsistent with the rest of the codebase. Throughout this file, the pattern is if (condition) { with the opening brace on the same line. This should be changed to if (-Not $json) { on line 2268 with the opening brace on the same line, removing the standalone brace on line 2269.

Suggested change
if (-Not $json)
{
if (-Not $json) {

Copilot uses AI. Check for mistakes.
$actionMessages += "Removing signature from file '$($_.FullName)' before packaging"
}

$process = Start-Process -Wait -FilePath "$env:WTTSTDIO\..\Tests\amd64\Signtool.exe" -ArgumentList 'remove', '/s', $_.FullName -PassThru
Copy link

Copilot AI Feb 27, 2026

Choose a reason for hiding this comment

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

The code assumes Signtool.exe exists at the path "$env:WTTSTDIO..\Tests\amd64\Signtool.exe" without validating this first. If the tool is missing or the path is incorrect, Start-Process will fail with an error that may not be handled gracefully. Consider adding a Test-Path check before attempting to use Signtool, or wrap the Start-Process call in a try-catch block to handle missing executable scenarios more gracefully.

Copilot uses AI. Check for mistakes.
@zjmletang
Copy link
Contributor

zjmletang commented Feb 28, 2026

@zjmletang Please review. Is this ok for you?

Hi @kostyanf14 ,thanks for this improvement!
I might be missing some context here, so please correct me if I'm wrong.

Right now the code unconditionally removes all Authenticode signatures from .sys/.dll/.exe files before packaging. For some workflows this makes sense, but for others it can actually break the expected signing flow.

Example – commercial vendor scenario (e.g. Alibaba‑like environment):
In a typical enterprise driver workflow, the driver is:
Signed with the company’s production EV code signing certificate (not a test certificate), e.g.
CN=Alibaba (China) Co., Ltd
Submitted to Microsoft for WHQL.
Microsoft adds its WHQL signature on top of the existing vendor signature.
In this model we rely on dual‑signing (vendor EV signature + Microsoft WHQL), not on “only keep Microsoft’s signature and strip the vendor one”.
image

By contrast, in some open‑source or internal test scenarios, drivers may be signed with a test certificate or self‑signed cert just to load on test machines. In those cases, removing the test signature before packaging can indeed be useful.

Suggestion: make signature removal opt‑in

@kostyanf14
Copy link
Contributor Author

@zjmletang Thanks for the updates. This is different from how RedHat sign drivers. We remove vendor EV signature and keep MSFT WHQL signature only.

Based on your comment, I will make this part optional.

- Extend New-ProjectPackage with iserror and messages properties
- Collect action messages and set iserror when createprojectpackage runs with -json
- Include driver add result, supplemental files, and playlist unload in messages
- Lets JSON consumers get operation result without parsing stdout

Signed-off-by: Kostiantyn Kostiuk <kkostiuk@redhat.com>
…SON output

Made-with: Cursor
Signed-off-by: Kostiantyn Kostiuk <kkostiuk@redhat.com>
Made-with: Cursor
Signed-off-by: Kostiantyn Kostiuk <kkostiuk@redhat.com>
@kostyanf14
Copy link
Contributor Author

@zjmletang feel free to test and review

@zjmletang
Copy link
Contributor

@kostyanf14 The code looks fine to me. I'll test it on Monday and let you know the results

@YanVugenfirer YanVugenfirer merged commit 8d64564 into master Mar 1, 2026
1 check passed
@kostyanf14
Copy link
Contributor Author

@zjmletang we want to see your results independent of merging

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