Skip to content

feat(powershell): add rtk powershell command family for Windows cmdlets#2881

Open
phatphamhong-tech wants to merge 1 commit into
rtk-ai:developfrom
phatphamhong-tech:feat/powershell-cmdlets
Open

feat(powershell): add rtk powershell command family for Windows cmdlets#2881
phatphamhong-tech wants to merge 1 commit into
rtk-ai:developfrom
phatphamhong-tech:feat/powershell-cmdlets

Conversation

@phatphamhong-tech

Copy link
Copy Markdown

Summary

  • Adds rtk powershell <Cmdlet> [args...], filtering output for 16 commonly-used
    PowerShell 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.
  • 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 ($env:RTK_PS_ARG_<n>) instead of being
    interpolated into the -Command string.
  • Registers a per-cmdlet hook rewrite pattern in src/discover/rules.rs (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.

Test plan

  • cargo fmt --all && cargo clippy --all-targets && cargo test — all green (2442 passed)
  • Manual testing: verified rtk powershell <Cmdlet> output against real PowerShell 5.1, and confirmed the hook rewrite (Get-Processrtk powershell Get-Process) works without colliding with existing ls/cat/ps/grep rules

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.
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

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