PowerShell / PowerShell/PSScriptAnalyzer

SuppressMessageAttribute is not recognized by PSA with "using namespace" import

Đang mở
#1,295 3 bình luận 1 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Area - Engine Up-for-Grabs
Ngôn ngữ chính
C#
Star
2.2k
Fork
414
Merge trung bình
13 giờ 1 phút
Pull request đã merge (30 ngày)
2

Mô tả

Before submitting a bug report:

  • Make sure you are able to repro it on the latest released version
  • Perform a quick search for existing issues to check if this bug has already been reported

Steps to reproduce

#requires -version 6.1

using namespace Diagnostics.CodeAnalysis;

[SuppressMessage("PSAvoidUsingPlainTextForPassword", "", Justification="Azure Pipelines will obscure the password")]
[CmdletBinding()]
param(
    [Parameter(Mandatory)]
    [ValidateNotNullOrEmpty()]
    [string]$Password, # will be obfuscated by Azure Pipelines

Expected behavior

PSA should not highlight $Password as an violation.

Actual behavior

PSA highlights parameter as being in violation. Using long form [Diagnostics.CodeAnalysis.SuppressMessageAttribute(...)] works as expected.

Environment data

> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      6.2.2
PSEdition                      Core
GitCommitId                    6.2.2
OS                             Microsoft Windows 10.0.17763 
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

> (Get-Module -ListAvailable PSScriptAnalyzer).Version | ForEach-Object { $_.ToString() }
1.18.0

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Chạy bản tái hiện PowerShell được cung cấp với PSScriptAnalyzer và so sánh dạng thuộc tính using-namespace với dạng được định danh đầy đủ. Truy vết cách PSScriptAnalyzer phân giải SuppressMessageAttribute; hoàn tất khi dạng rút gọn suppress PSAvoidUsingPlainTextForPassword cho tham số Password.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
csharp, powershell
Lĩnh vực
tooling
Loại issue
Lỗi
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
35/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.