{"id":17775,"date":"2015-08-06T12:55:55","date_gmt":"2015-08-06T20:55:55","guid":{"rendered":"http:\/\/devblogs.microsoft.com\/powershell\/?p=17775"},"modified":"2022-05-23T09:47:03","modified_gmt":"2022-05-23T17:47:03","slug":"powershell-gallery-new-security-scan","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/powershell\/powershell-gallery-new-security-scan\/","title":{"rendered":"PowerShell Gallery \u2013 New Security Scan"},"content":{"rendered":"<div class=\"WordSection1\">\n<p class=\"MsoTitle\">Quality and trust of PowerShell Gallery content have been a concern since the beginning.&nbsp; These issues were somewhat addressed with peer-monitoring via the Report Abuse and Contact Support links on each module details page.&nbsp; We even implemented a new cmdlet, Save-Module, which allowed users to assess a module&rsquo;s contents before installing it.&nbsp; However, all these scenarios put the onus on the consumer to determine if a module is safe and of high quality.<\/p>\n<p class=\"MsoTitle\">To improve further, we have begun checking that all modules on the Gallery meet a basic quality bar.<\/p>\n<p class=\"MsoTitle\">Starting June 26, 2015, all modules in the Gallery are being scanned and assessed against defined safety and quality best practices.<\/p>\n<p class=\"MsoTitle\">The scan performs the following:<\/p>\n<p class=\"MsoListParagraphCxSpFirst\" style=\"margin-left: 43.5pt; mso-add-space: auto; text-indent: -25.5pt; mso-list: l0 level1 lfo2;\"><span style=\"mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;\"><span style=\"mso-list: Ignore;\">1.<span style=\"font: 7.0pt 'Times New Roman';\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><\/span><\/span>Installs the module by using PowerShellGet.&nbsp;<\/p>\n<p class=\"MsoListParagraphCxSpMiddle\" style=\"margin-left: 43.5pt; mso-add-space: auto; text-indent: -25.5pt; mso-list: l0 level1 lfo2;\"><span style=\"mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;\"><span style=\"mso-list: Ignore;\">2.<span style=\"font: 7.0pt 'Times New Roman';\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><\/span><\/span>Runs an antivirus scan by using System Center Endpoint Protection.<\/p>\n<p class=\"MsoListParagraphCxSpLast\" style=\"margin-left: 43.5pt; mso-add-space: auto; text-indent: -25.5pt; mso-list: l0 level1 lfo2;\"><span style=\"mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;\"><span style=\"mso-list: Ignore;\">3.<span style=\"font: 7.0pt 'Times New Roman';\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><\/span><\/span>Runs the module through PowerShell Script Analyzer.&nbsp; We apply the following error-level rules from the newest PowerShell Script Analyzer module in the PowerShell Gallery:<\/p>\n<p class=\"MsoNormal\">&nbsp;<\/p>\n<table class=\"MsoNormalTable\" style=\"margin-left: 35.75pt; border-collapse: collapse; mso-yfti-tbllook: 1184; mso-padding-alt: 0in 0in 0in 0in;\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr style=\"mso-yfti-irow: 0; mso-yfti-firstrow: yes;\">\n<td style=\"width: 216.95pt; border: solid windowtext 1.0pt; padding: 0in 5.4pt 0in 5.4pt;\" valign=\"top\" width=\"289\">\n<p class=\"MsoNormal\">Rule Name<\/p>\n<\/td>\n<td style=\"width: 214.8pt; border: solid windowtext 1.0pt; border-left: none; padding: 0in 5.4pt 0in 5.4pt;\" valign=\"top\" width=\"286\">\n<p class=\"MsoNormal\">Description<\/p>\n<\/td>\n<\/tr>\n<tr style=\"mso-yfti-irow: 1;\">\n<td style=\"width: 216.95pt; border: solid windowtext 1.0pt; border-top: none; padding: 0in 5.4pt 0in 5.4pt;\" valign=\"top\" width=\"289\">\n<p class=\"MsoNormal\"><span class=\"SpellE\">PSAvoidUsingUserNameAndPassWordParams<\/span><\/p>\n<\/td>\n<td style=\"width: 214.8pt; border-top: none; border-left: none; border-bottom: solid windowtext 1.0pt; border-right: solid windowtext 1.0pt; padding: 0in 5.4pt 0in 5.4pt;\" valign=\"top\" width=\"286\">\n<p class=\"MsoNormal\">Functions should only take in a credential parameter of type <span class=\"SpellE\">PSCredential<\/span> instead of username and password parameters.<\/p>\n<\/td>\n<\/tr>\n<tr style=\"mso-yfti-irow: 2;\">\n<td style=\"width: 216.95pt; border: solid windowtext 1.0pt; border-top: none; padding: 0in 5.4pt 0in 5.4pt;\" valign=\"top\" width=\"289\">\n<p class=\"MsoNormal\"><span class=\"SpellE\">PSAvoidUsingComputerNameHardcoded<\/span><\/p>\n<\/td>\n<td style=\"width: 214.8pt; border-top: none; border-left: none; border-bottom: solid windowtext 1.0pt; border-right: solid windowtext 1.0pt; padding: 0in 5.4pt 0in 5.4pt;\" valign=\"top\" width=\"286\">\n<p class=\"MsoNormal\">The <span class=\"SpellE\">ComputerName<\/span> parameter of a cmdlet should not be hardcoded as this will expose sensitive information about the system.<\/p>\n<\/td>\n<\/tr>\n<tr style=\"mso-yfti-irow: 3;\">\n<td style=\"width: 216.95pt; border: solid windowtext 1.0pt; border-top: none; padding: 0in 5.4pt 0in 5.4pt;\" valign=\"top\" width=\"289\">\n<p class=\"MsoNormal\"><span class=\"SpellE\">PSAvoidUsingConvertToSecureStringWithPlainText<\/span><\/p>\n<\/td>\n<td style=\"width: 214.8pt; border-top: none; border-left: none; border-bottom: solid windowtext 1.0pt; border-right: solid windowtext 1.0pt; padding: 0in 5.4pt 0in 5.4pt;\" valign=\"top\" width=\"286\">\n<p class=\"MsoNormal\">Using <span class=\"SpellE\">ConvertTo-SecureString<\/span> with plain text will expose secure information.<\/p>\n<\/td>\n<\/tr>\n<tr style=\"mso-yfti-irow: 4;\">\n<td style=\"width: 216.95pt; border: solid windowtext 1.0pt; border-top: none; padding: 0in 5.4pt 0in 5.4pt;\" valign=\"top\" width=\"289\">\n<p class=\"MsoNormal\"><span class=\"SpellE\">PSDSCUseIdenticalMandatoryParametersForDsc<\/span><\/p>\n<\/td>\n<td style=\"width: 214.8pt; border-top: none; border-left: none; border-bottom: solid windowtext 1.0pt; border-right: solid windowtext 1.0pt; padding: 0in 5.4pt 0in 5.4pt;\" valign=\"top\" width=\"286\">\n<p class=\"MsoNormal\">The Get\/Test\/Set <span class=\"SpellE\">TargetResource<\/span> functions of DSC resource must have the same mandatory parameters.<\/p>\n<\/td>\n<\/tr>\n<tr style=\"mso-yfti-irow: 5;\">\n<td style=\"width: 216.95pt; border: solid windowtext 1.0pt; border-top: none; padding: 0in 5.4pt 0in 5.4pt;\" valign=\"top\" width=\"289\">\n<p class=\"MsoNormal\"><span class=\"SpellE\">PSDSCUseIdenticalParametersForDSC<\/span><\/p>\n<\/td>\n<td style=\"width: 214.8pt; border-top: none; border-left: none; border-bottom: solid windowtext 1.0pt; border-right: solid windowtext 1.0pt; padding: 0in 5.4pt 0in 5.4pt;\" valign=\"top\" width=\"286\">\n<p class=\"MsoNormal\">The Test and Set-<span class=\"SpellE\">TargetResource<\/span> functions of DSC Resource must have the same parameters.<\/p>\n<\/td>\n<\/tr>\n<tr style=\"mso-yfti-irow: 6; mso-yfti-lastrow: yes;\">\n<td style=\"width: 216.95pt; border: solid windowtext 1.0pt; border-top: none; padding: 0in 5.4pt 0in 5.4pt;\" valign=\"top\" width=\"289\">\n<p class=\"MsoNormal\"><span class=\"SpellE\">PSDSCStandardDSCFunctionsInResource<\/span><\/p>\n<\/td>\n<td style=\"width: 214.8pt; border-top: none; border-left: none; border-bottom: solid windowtext 1.0pt; border-right: solid windowtext 1.0pt; padding: 0in 5.4pt 0in 5.4pt;\" valign=\"top\" width=\"286\">\n<p class=\"MsoNormal\">DSC Resource must implement Get, Set and Test-<span class=\"SpellE\">TargetResource<\/span> functions. DSC Class must implement Get, Set and Test functions.<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p class=\"MsoNormal\">&nbsp;<\/p>\n<p class=\"MsoNormal\">A module is flagged as noncompliant if the module cannot be installed for any reason, or if PowerShell Script Analyzer returns error-level results or parse errors.&nbsp; Owners of noncompliant modules will receive emails containing the results of the scan, and asking them to unlist the module, resolve the issues, and republish.&nbsp;<\/p>\n<p class=\"MsoNormal\">&nbsp;<\/p>\n<p class=\"MsoNormal\">A module fails compliance with high priority if the module contains anything that could damage or compromise a user&rsquo;s computer (such as viruses, malicious software or code, etc.).&nbsp; High-priority noncompliant modules are manually unlisted, and deleted after two weeks, if the issue cannot be resolved with the module owner.&nbsp;<\/p>\n<p class=\"MsoNormal\">&nbsp;<\/p>\n<p class=\"MsoNormal\">PowerShell Script Analyzer is new and evolving.&nbsp; As a result, there are very few rules we will require to pass, while we take comments on both the tool and on this process.&nbsp; If you would like to provide feedback to PowerShell Script Analyzer, please visit their GitHub website: <a href=\"https:\/\/github.com\/PowerShell\/PSScriptAnalyzer\">https:\/\/github.com\/PowerShell\/PSScriptAnalyzer<\/a> .If you are planning to publish a new module, you should run it through PowerShell Script Analyzer yourself.&nbsp; You can download the module from the PowerShell Gallery using <strong style=\"mso-bidi-font-weight: normal;\">Install-Module <span class=\"SpellE\">PSScriptAnalyzer<\/span><\/strong>.<\/p>\n<p class=\"MsoNormal\">&nbsp;<\/p>\n<p class=\"MsoNormal\">Our main goal is to help consumers of the Gallery content know that the modules on the Gallery have passed basic tests, so that they feel more comfortable downloading them. In the future, we intend to publish the results of the scans we run on the Module page, so that consumers of the module will know what to expect when they run Script Analyzer on the items they acquire.<\/p>\n<p class=\"MsoNormal\">&nbsp;<\/p>\n<p class=\"MsoNormal\">After today&rsquo;s announcement, we expect contributors to rise to the challenge and meet, if not exceed, this quality bar.&nbsp; This security scan is the first step in shaping the PowerShell Gallery to contain high quality and trusted modules that all users will feel confident using.<\/p>\n<p class=\"MsoNormal\">&nbsp;<\/p>\n<p class=\"MsoNormal\">As always, we are open to your comments and feedback.<\/p>\n<p class=\"MsoNormal\">&nbsp;<\/p>\n<p class=\"MsoNormal\">Thanks,<\/p>\n<p class=\"MsoNormal\">Rebecca Roenitz [MSFT]<\/p>\n<p class=\"MsoNormal\">PowerShell Gallery Team<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Quality and trust of PowerShell Gallery content have been a concern since the beginning.&nbsp; These issues were somewhat addressed with peer-monitoring via the Report Abuse and Contact Support links on each module details page.&nbsp; We even implemented a new cmdlet, Save-Module, which allowed users to assess a module&rsquo;s contents before installing it.&nbsp; However, all these [&hellip;]<\/p>\n","protected":false},"author":600,"featured_media":13641,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[248,259,3182],"class_list":["post-17775","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-powershell","tag-powershell","tag-powershell-gallery","tag-psscriptanalyzer"],"acf":[],"blog_post_summary":"<p>Quality and trust of PowerShell Gallery content have been a concern since the beginning.&nbsp; These issues were somewhat addressed with peer-monitoring via the Report Abuse and Contact Support links on each module details page.&nbsp; We even implemented a new cmdlet, Save-Module, which allowed users to assess a module&rsquo;s contents before installing it.&nbsp; However, all these [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/posts\/17775","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/users\/600"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/comments?post=17775"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/posts\/17775\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/media\/13641"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/media?parent=17775"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/categories?post=17775"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/tags?post=17775"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}