Skip to content

Conversation

@arudell
Copy link
Member

@arudell arudell commented Dec 31, 2025

Description

This pull request refactors several PowerShell scripts to remove the use of Invoke-Expression when executing system commands, replacing it with direct invocation using the call operator (&). This change enhances security, reliability, and readability by avoiding unnecessary command parsing and potential injection risks. Additionally, a minor change in the test initialization script simplifies how configuration data is loaded.

PowerShell command execution refactoring:

  • Replaced Invoke-Expression with the call operator (&) for starting, updating, and stopping ETW trace sessions in Start-EtwTraceSession and Stop-EtwTraceSession functions in src/modules/SdnDiag.Common.psm1. [1] [2] [3]
  • Updated Disable-SdnRasGatewayTracing and Enable-SdnRasGatewayTracing in src/modules/SdnDiag.Gateway.psm1 to use the call operator for netsh commands. [1] [2]
  • Modified Get-OvsdbDatabase, Get-ServerConfigState, and Test-SdnVfpPortTuple in src/modules/SdnDiag.Server.psm1 to use the call operator for their respective command-line tools. [1] [2] [3]

Test script simplification:

  • In tests/online/RunTests.ps1, removed Invoke-Expression from the loading of configuration data, directly assigning the output of Get-Content to the configuration hashtable.

Change type

  • Bug fix (non-breaking change)
  • Code style update (formatting, local variables)
  • New Feature (non-breaking change that adds new functionality without impacting existing)
  • Breaking change (fix or feature that may cause functionality impact)
  • Other

Checklist:

  • My code follows the style and contribution guidelines of this project.
  • I have tested and validated my code changes.

@arudell arudell requested a review from a team as a code owner December 31, 2025 16:49
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.

2 participants