-
-
Notifications
You must be signed in to change notification settings - Fork 244
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Poweshell_Formatter error when using .powershell-psscriptanalyzer.psd1 file #2229
Comments
@TommyE123 it seems powershell does not succeed to parse your |
Thanks for coming back to me so quickly. I'm using the template you have saved in MegaLinter and just changed it from PSMissingModuleManifestField to PSAvoidUsingWriteHost https://github.com/oxsecurity/megalinter/blob/main/TEMPLATES/.powershell-psscriptanalyzer.psd1 This worked fine on version v6.16.0 and the file was being used for POWERSHELL_POWERSHELL previously and hasnt been changed. Disabling POWERSHELL_POWERSHELL_FORMATTER in the MegaLinter config then passes. Unchanged template (correctly errors): Changed template (correctly passes): So in conclusion. I think the file is ok judging by this testing? 🙂 |
* Change name of config file for powershell formatter Fixes #2229 * Update max dev CI time to 120mn * Add typing-extensions pip package
@TommyE123 please can you confirm it's now ok with beta version of MegaLinter ? |
Hi, so it’s much better now using the beta branch thank you!
Thanks again and sorry for all the questions and suggestions! |
@TommyE123 I moved this conversation in a new issue as this one is solved :) |
Describe the bug
Hi,
I believe there is a bug in the new Poweshell_Formatter linter when using the template to create your own .powershell-psscriptanalyzer.psd1 file.
To Reproduce
Using an Azure devops yml pipeline with a powershell script that requires linting and the default template copied to the rules folder.
When no .powershell-psscriptanalyzer.psd1 file is present in the rules folder then defaulting to the mega-linter template works correctly with or without errors.
When using your own template to use custom rules it seems to work if there’s no errors in the file or no rules that need to be used to exclude something.
When using your own template and there is a rule that needs to be implemented it fails with an error:
[powershell_formatter] _Pipelines/LinterRules/.powershell-psscriptanalyzer.psd1 - ERROR - 1 error(s)
--Error detail:
Invoke-Formatter: Settings file '/tmp/lint/_Pipelines/LinterRules/.powershell-psscriptanalyzer.psd1' is invalid because it does not contain a hashtable.
Expected behavior
I would expect to see Mega-Linter report the error or pass using the rule to exclude it in the config file.
Additional context
Any other information required please don’t hesitate to ask.
Thanks again for all your continued work getting this great application where it is today.
Tom
The text was updated successfully, but these errors were encountered: