PowerShell / PowerShell/PSScriptAnalyzer
Check whether a module references itself in 'NestedModules' field in the .psd1 file
Nessuno ha ancora preso questa issue.
- Lingua principale
- C#
- Stelle
- 2.2k
- Fork
- 414
- Merge medio
- 13h 1m
- PR unite (30g)
- 2
Descrizione
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.
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia riproducendo l’esempio di modulo annidato circolare con il contenuto .psd1 mostrato e analizza come PSScriptAnalyzer rileva e segnala i problemi dei moduli. La modifica è completata quando un modulo il cui campo NestedModules fa riferimento a se stesso produce un avviso, mentre le dichiarazioni valide di moduli annidati rimangono inalterate; il payload non nomina file di implementazione né test.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- powershell
- Ambito
- devtools
- Tipo di issue
- Funzionalità
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 35/100