PowerShell / PowerShell/PSScriptAnalyzer
Check whether a module references itself in 'NestedModules' field in the .psd1 file
Chưa có ai nhận issue này.
- 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ả
This feature ask is per discussion in https://github.com/PowerShell/PowerShell/pull/6843#discussion_r187123774.
Importing a ill-structured module could result in a circular nested module. For example, for the following code, you will see 'True' as the output.
$testdir = Join-Path $env:TEMP test
$testpsm1 = Join-Path $testdir test.psm1
$testpsd1 = Join-Path $testdir test.psd1
mkdir $testdir > $null
Set-Content $testpsm1 -Value "function bar {}"
Set-Content $testpsd1 -Value "@{ ModuleVersion = '0.0.1'; RootModule = 'test'; NestedModules = @('test') }"
$m = Import-Module $testpsd1 -Pass
$m -eq $m.NestedModules[0]
> True
So maybe a rule can be written to check the bold part of test.psd1 "@{ ModuleVersion = '0.0.1'; RootModule = 'test'; NestedModules = @('test') }", to make sure the author is warned when a module like test.psd1 has itself as a nested module.
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Bắt đầu bằng cách tái hiện ví dụ về mô-đun lồng nhau vòng với nội dung .psd1 được hiển thị và kiểm tra cách PSScriptAnalyzer phát hiện cũng như báo cáo các vấn đề của mô-đun. Thay đổi được hoàn tất khi một mô-đun có trường NestedModules tham chiếu đến chính nó tạo ra cảnh báo, trong khi các khai báo mô-đun lồng nhau hợp lệ vẫn không bị ảnh hưởng; payload không nêu tên tệp triển khai hoặc các bài kiểm thử.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- powershell
- Lĩnh vực
- devtools
- Loại issue
- Tính năng
- Độ 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