PowerShell / PowerShell/PSScriptAnalyzer
PSUseUsingScopeModifierInNewRunspaces has false positive when using -ArgumentList on Invoke-Command
オープン
まだ誰も着手していません。
Issue - Enhancement
Up-for-Grabs
- 主要言語
- C#
- スター
- 2.2k
- フォーク
- 414
- 平均マージ
- 13時間 1分
- マージ済み PR(30日)
- 2
説明
Steps to reproduce
# $sb = {
Invoke-Command -Session $psSession -ArgumentList $path -ErrorAction Stop -ScriptBlock {
Param ($Foo)
return $Foo
}}
# Invoke-ScriptAnalyzer -ScriptDefinition [scriptblock]$sb | ft -a
RuleName Severity ScriptName Line Message
-------- -------- ---------- ---- -------
PSUseUsingScopeModifierInNewRunspaces Warning 3 The variable '$Foo' is not declared within this ScriptBlock, and is missing the 'Using:' scope modifier.
PSUseUsingScopeModifierInNewRunspaces Warning 5 The variable '$Foo' is not declared within this ScriptBlock, and is missing the 'Using:' scope modifier.
Expected behavior
$Foo should not get flagged
Actual behavior
$Foo is being flagged violating PSUseUsingScopeModifierInNewRunspaces.
Environment data
# $PSVersionTable
Name Value
---- -----
PSVersion 5.1.18362.752
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.18362.752
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
# (Get-Module -ListAvailable PSScriptAnalyzer).Version | ForEach-Object { $_.ToString() }
1.19.0
@mattpwhite
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず、PSScriptAnalyzer 1.19.0 を使用し、Invoke-Command、-ArgumentList、およびパラメーター化された ScriptBlock で警告を再現してから、PSUseUsingScopeModifierInNewRunspaces ルールの実装とそのテストを見つけます。完了の条件は、-ArgumentList を介して渡された $Foo パラメーターが Using: スコープ修飾子の欠落として報告されなくなり、既存の警告が引き続きカバーされることです。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- csharp, powershell
- 領域
- devtools
- issue の種類
- バグ
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100