feat(powershell): add rtk powershell command family for Windows cmdlets#2881
Open
phatphamhong-tech wants to merge 1 commit into
Open
feat(powershell): add rtk powershell command family for Windows cmdlets#2881phatphamhong-tech wants to merge 1 commit into
phatphamhong-tech wants to merge 1 commit into
Conversation
Adds `rtk powershell <Cmdlet> [args...]`, filtering output for 16 commonly-used cmdlets (Get-ChildItem, Get-Process, Get-Service, Get-Content, Select-String, Get-WinEvent, Get-EventLog, Get-ItemProperty, Test-NetConnection, Get-NetAdapter, Get-NetTCPConnection, Get-ComputerInfo, Get-Package, Get-Counter, Install-Package, Get-Item) with the same header+capped-rows / essential-properties approach used elsewhere in rtk. Cmdlets with already-minimal or side-effecting output pass straight through unfiltered, like `rtk proxy`. Untrusted input never reaches the PowerShell script as text: the unknown-cmdlet passthrough path allowlists cmdlet names against the shape of a real cmdlet/function/alias, and every argument value is passed to the child process via an environment variable and referenced in the script as $env:RTK_PS_ARG_<n> rather than being interpolated into the -Command string. Registers a per-cmdlet hook rewrite pattern in src/discover/rules.rs so raw PowerShell invocations are auto-rewritten (short aliases that collide with existing rules like ls/cat/ps/grep are deliberately not registered), and adds force_tee_hint/force_tee_tail_hint truncation recovery to every capped list, matching every other filter module's convention.
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
rtk powershell <Cmdlet> [args...], filtering output for 16 commonly-usedPowerShell cmdlets (Get-ChildItem, Get-Process, Get-Service, Get-Content,
Select-String, Get-WinEvent, Get-EventLog, Get-ItemProperty, Test-NetConnection,
Get-NetAdapter, Get-NetTCPConnection, Get-ComputerInfo, Get-Package, Get-Counter,
Install-Package, Get-Item), same header+capped-rows / essential-properties
approach as the rest of rtk. Cmdlets with already-minimal or side-effecting
output pass straight through unfiltered, like
rtk proxy.passthrough path allowlists cmdlet names against the shape of a real
cmdlet/function/alias, and every argument value is passed to the child process
via an environment variable (
$env:RTK_PS_ARG_<n>) instead of beinginterpolated into the
-Commandstring.src/discover/rules.rs(shortaliases that collide with existing rules like
ls/cat/ps/greparedeliberately not registered), and adds
force_tee_hint/force_tee_tail_hinttruncation recovery to every capped list.
Test plan
cargo fmt --all && cargo clippy --all-targets && cargo test— all green (2442 passed)rtk powershell <Cmdlet>output against real PowerShell 5.1, and confirmed the hook rewrite (Get-Process→rtk powershell Get-Process) works without colliding with existingls/cat/ps/greprules