From a0a7fd02970dfff0fa71766e1efa2be01829aabe Mon Sep 17 00:00:00 2001 From: Jordan Borean Date: Thu, 4 Oct 2018 05:55:02 +1000 Subject: [PATCH] ps-lint: ignore rules that are not relevant to Ansible (#46376) (cherry picked from commit ba638f40cfc1c7677c93f06aec70134eb0fd7066) --- lib/ansible/modules/windows/win_user.ps1 | 2 -- test/sanity/pslint/ignore.txt | 34 ------------------------ test/sanity/pslint/settings.psd1 | 10 ++++++- 3 files changed, 9 insertions(+), 37 deletions(-) diff --git a/lib/ansible/modules/windows/win_user.ps1 b/lib/ansible/modules/windows/win_user.ps1 index 8a1cf6e88d7..417d09c0738 100644 --- a/lib/ansible/modules/windows/win_user.ps1 +++ b/lib/ansible/modules/windows/win_user.ps1 @@ -55,8 +55,6 @@ function Get-Group($grp) { } Function Test-LocalCredential { - [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSAvoidUsingUserNameAndPassWordParams", "", Justification="We need to use the plaintext pass in the Win32 call, also the source isn't a secure string to using that is just a waste of time/code")] - [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSAvoidUsingPlainTextForPassword", "", Justification="See above")] param([String]$Username, [String]$Password) $platform_util = @' diff --git a/test/sanity/pslint/ignore.txt b/test/sanity/pslint/ignore.txt index c74e7375e0b..a3fe1a040df 100644 --- a/test/sanity/pslint/ignore.txt +++ b/test/sanity/pslint/ignore.txt @@ -1,11 +1,9 @@ examples/scripts/ConfigureRemotingForAnsible.ps1 PSAvoidUsingCmdletAliases -examples/scripts/ConfigureRemotingForAnsible.ps1 PSUseBOMForUnicodeEncodedFile examples/scripts/upgrade_to_ps3.ps1 PSAvoidUsingWriteHost examples/scripts/upgrade_to_ps3.ps1 PSUseApprovedVerbs lib/ansible/module_utils/powershell/Ansible.ModuleUtils.ArgvParser.psm1 PSUseApprovedVerbs lib/ansible/module_utils/powershell/Ansible.ModuleUtils.CommandUtil.psm1 PSUseApprovedVerbs lib/ansible/module_utils/powershell/Ansible.ModuleUtils.FileUtil.psm1 PSProvideCommentHelp -lib/ansible/module_utils/powershell/Ansible.ModuleUtils.FileUtil.psm1 PSUseOutputTypeCorrectly lib/ansible/module_utils/powershell/Ansible.ModuleUtils.Legacy.psm1 PSAvoidUsingCmdletAliases lib/ansible/module_utils/powershell/Ansible.ModuleUtils.Legacy.psm1 PSAvoidUsingWMICmdlet lib/ansible/module_utils/powershell/Ansible.ModuleUtils.Legacy.psm1 PSUseApprovedVerbs @@ -13,13 +11,8 @@ lib/ansible/module_utils/powershell/Ansible.ModuleUtils.LinkUtil.psm1 PSUseAppro lib/ansible/modules/windows/setup.ps1 PSAvoidUsingCmdletAliases lib/ansible/modules/windows/setup.ps1 PSAvoidUsingEmptyCatchBlock lib/ansible/modules/windows/setup.ps1 PSUseDeclaredVarsMoreThanAssignments -lib/ansible/modules/windows/win_certificate_store.ps1 PSAvoidUsingPlainTextForPassword -lib/ansible/modules/windows/win_chocolatey.ps1 PSAvoidUsingConvertToSecureStringWithPlainText -lib/ansible/modules/windows/win_chocolatey.ps1 PSAvoidUsingPlainTextForPassword -lib/ansible/modules/windows/win_chocolatey.ps1 PSAvoidUsingUserNameAndPassWordParams lib/ansible/modules/windows/win_chocolatey.ps1 PSUseApprovedVerbs lib/ansible/modules/windows/win_chocolatey.ps1 PSUseDeclaredVarsMoreThanAssignments -lib/ansible/modules/windows/win_chocolatey.ps1 PSUseOutputTypeCorrectly lib/ansible/modules/windows/win_copy.ps1 PSUseApprovedVerbs lib/ansible/modules/windows/win_copy.ps1 PSUseDeclaredVarsMoreThanAssignments lib/ansible/modules/windows/win_dns_client.ps1 PSAvoidGlobalVars @@ -27,59 +20,36 @@ lib/ansible/modules/windows/win_dns_client.ps1 PSAvoidUsingCmdletAliases lib/ansible/modules/windows/win_dns_client.ps1 PSAvoidUsingWMICmdlet lib/ansible/modules/windows/win_dns_client.ps1 PSUseApprovedVerbs lib/ansible/modules/windows/win_dns_client.ps1 PSUseDeclaredVarsMoreThanAssignments -lib/ansible/modules/windows/win_domain.ps1 PSAvoidUsingConvertToSecureStringWithPlainText lib/ansible/modules/windows/win_domain.ps1 PSAvoidUsingEmptyCatchBlock lib/ansible/modules/windows/win_domain.ps1 PSUseApprovedVerbs lib/ansible/modules/windows/win_domain.ps1 PSUseDeclaredVarsMoreThanAssignments lib/ansible/modules/windows/win_domain_controller.ps1 PSAvoidGlobalVars -lib/ansible/modules/windows/win_domain_controller.ps1 PSAvoidUsingConvertToSecureStringWithPlainText -lib/ansible/modules/windows/win_domain_controller.ps1 PSAvoidUsingPlainTextForPassword -lib/ansible/modules/windows/win_domain_controller.ps1 PSAvoidUsingUserNameAndPassWordParams lib/ansible/modules/windows/win_domain_controller.ps1 PSAvoidUsingWMICmdlet lib/ansible/modules/windows/win_domain_controller.ps1 PSUseApprovedVerbs lib/ansible/modules/windows/win_domain_controller.ps1 PSUseDeclaredVarsMoreThanAssignments -lib/ansible/modules/windows/win_domain_group.ps1 PSAvoidUsingConvertToSecureStringWithPlainText lib/ansible/modules/windows/win_domain_membership.ps1 PSAvoidGlobalVars -lib/ansible/modules/windows/win_domain_membership.ps1 PSAvoidUsingConvertToSecureStringWithPlainText -lib/ansible/modules/windows/win_domain_membership.ps1 PSAvoidUsingPlainTextForPassword -lib/ansible/modules/windows/win_domain_membership.ps1 PSAvoidUsingUserNameAndPassWordParams lib/ansible/modules/windows/win_domain_membership.ps1 PSAvoidUsingWMICmdlet lib/ansible/modules/windows/win_domain_membership.ps1 PSUseApprovedVerbs lib/ansible/modules/windows/win_domain_membership.ps1 PSUseDeclaredVarsMoreThanAssignments -lib/ansible/modules/windows/win_domain_user.ps1 PSAvoidUsingConvertToSecureStringWithPlainText lib/ansible/modules/windows/win_dsc.ps1 PSAvoidUsingCmdletAliases -lib/ansible/modules/windows/win_dsc.ps1 PSAvoidUsingConvertToSecureStringWithPlainText lib/ansible/modules/windows/win_dsc.ps1 PSAvoidUsingEmptyCatchBlock lib/ansible/modules/windows/win_dsc.ps1 PSUseApprovedVerbs lib/ansible/modules/windows/win_eventlog.ps1 PSUseDeclaredVarsMoreThanAssignments -lib/ansible/modules/windows/win_file_version.ps1 PSUseBOMForUnicodeEncodedFile lib/ansible/modules/windows/win_find.ps1 PSAvoidUsingEmptyCatchBlock lib/ansible/modules/windows/win_find.ps1 PSAvoidUsingWMICmdlet lib/ansible/modules/windows/win_firewall_rule.ps1 PSAvoidUsingCmdletAliases lib/ansible/modules/windows/win_firewall_rule.ps1 PSUseApprovedVerbs -lib/ansible/modules/windows/win_get_url.ps1 PSAvoidUsingPlainTextForPassword lib/ansible/modules/windows/win_get_url.ps1 PSUseApprovedVerbs lib/ansible/modules/windows/win_get_url.ps1 PSUseSupportsShouldProcess lib/ansible/modules/windows/win_hotfix.ps1 PSUseApprovedVerbs -lib/ansible/modules/windows/win_iis_virtualdirectory.ps1 PSUseBOMForUnicodeEncodedFile -lib/ansible/modules/windows/win_iis_webapplication.ps1 PSUseBOMForUnicodeEncodedFile -lib/ansible/modules/windows/win_iis_webapppool.ps1 PSUseBOMForUnicodeEncodedFile lib/ansible/modules/windows/win_iis_webbinding.ps1 PSUseApprovedVerbs -lib/ansible/modules/windows/win_iis_webbinding.ps1 PSUseBOMForUnicodeEncodedFile lib/ansible/modules/windows/win_iis_website.ps1 PSAvoidUsingCmdletAliases lib/ansible/modules/windows/win_iis_website.ps1 PSAvoidUsingPositionalParameters -lib/ansible/modules/windows/win_iis_website.ps1 PSUseBOMForUnicodeEncodedFile lib/ansible/modules/windows/win_iis_website.ps1 PSUseDeclaredVarsMoreThanAssignments -lib/ansible/modules/windows/win_mapped_drive.ps1 PSAvoidUsingConvertToSecureStringWithPlainText lib/ansible/modules/windows/win_nssm.ps1 PSAvoidUsingCmdletAliases lib/ansible/modules/windows/win_nssm.ps1 PSAvoidUsingInvokeExpression -lib/ansible/modules/windows/win_nssm.ps1 PSAvoidUsingPlainTextForPassword -lib/ansible/modules/windows/win_nssm.ps1 PSAvoidUsingUserNameAndPassWordParams lib/ansible/modules/windows/win_nssm.ps1 PSUseApprovedVerbs lib/ansible/modules/windows/win_nssm.ps1 PSUseDeclaredVarsMoreThanAssignments -lib/ansible/modules/windows/win_nssm.ps1 PSUseOutputTypeCorrectly -lib/ansible/modules/windows/win_package.ps1 PSAvoidUsingConvertToSecureStringWithPlainText -lib/ansible/modules/windows/win_package.ps1 PSAvoidUsingPlainTextForPassword lib/ansible/modules/windows/win_package.ps1 PSUseApprovedVerbs lib/ansible/modules/windows/win_package.ps1 PSUsePSCredentialType lib/ansible/modules/windows/win_pagefile.ps1 PSAvoidUsingCmdletAliases @@ -98,20 +68,16 @@ lib/ansible/modules/windows/win_scheduled_task_stat.ps1 PSAvoidUsingCmdletAliase lib/ansible/modules/windows/win_scheduled_task_stat.ps1 PSUseDeclaredVarsMoreThanAssignments lib/ansible/modules/windows/win_security_policy.ps1 PSUseApprovedVerbs lib/ansible/modules/windows/win_security_policy.ps1 PSUseDeclaredVarsMoreThanAssignments -lib/ansible/modules/windows/win_service.ps1 PSAvoidUsingPlainTextForPassword -lib/ansible/modules/windows/win_service.ps1 PSAvoidUsingUserNameAndPassWordParams lib/ansible/modules/windows/win_shell.ps1 PSAvoidUsingCmdletAliases lib/ansible/modules/windows/win_shell.ps1 PSUseApprovedVerbs lib/ansible/modules/windows/win_stat.ps1 PSAvoidUsingWMICmdlet lib/ansible/modules/windows/win_stat.ps1 PSUseApprovedVerbs lib/ansible/modules/windows/win_unzip.ps1 PSAvoidUsingCmdletAliases lib/ansible/modules/windows/win_unzip.ps1 PSUseApprovedVerbs -lib/ansible/modules/windows/win_uri.ps1 PSAvoidUsingConvertToSecureStringWithPlainText lib/ansible/modules/windows/win_uri.ps1 PSAvoidUsingEmptyCatchBlock lib/ansible/modules/windows/win_user.ps1 PSAvoidUsingCmdletAliases lib/ansible/modules/windows/win_wait_for.ps1 PSAvoidUsingEmptyCatchBlock lib/ansible/modules/windows/win_webpicmd.ps1 PSAvoidUsingInvokeExpression -lib/ansible/modules/windows/win_webpicmd.ps1 PSUseOutputTypeCorrectly test/integration/targets/win_audit_rule/library/test_get_audit_rule.ps1 PSAvoidUsingCmdletAliases test/integration/targets/win_dsc/templates/ANSIBLE_xTestResource.psm1 PSAvoidDefaultValueForMandatoryParameter test/integration/targets/win_iis_webbinding/library/test_get_webbindings.ps1 PSUseApprovedVerbs diff --git a/test/sanity/pslint/settings.psd1 b/test/sanity/pslint/settings.psd1 index 7eedc2cfaa6..f4de7c09fea 100644 --- a/test/sanity/pslint/settings.psd1 +++ b/test/sanity/pslint/settings.psd1 @@ -1,6 +1,14 @@ @{ ExcludeRules=@( 'PSPossibleIncorrectComparisonWithNull', - 'PSUseShouldProcessForStateChangingFunctions' + 'PSUseOutputTypeCorrectly', + 'PSUseShouldProcessForStateChangingFunctions', + # We send strings as plaintext so will always come across the 3 issues + 'PSAvoidUsingPlainTextForPassword', + 'PSAvoidUsingConvertToSecureStringWithPlainText', + 'PSAvoidUsingUserNameAndPassWordParams', + # We send the module as a base64 encoded string and a BOM will cause + # issues here + 'PSUseBOMForUnicodeEncodedFile' ) }