From d6223c16eb8f789274fe80bc939b61e41069416b Mon Sep 17 00:00:00 2001 From: "Raghu Shantha [MSFT]" Date: Mon, 31 Aug 2015 14:22:24 -0700 Subject: [PATCH 1/4] Update CHANGELOG.MD --- CHANGELOG.MD | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/CHANGELOG.MD b/CHANGELOG.MD index b81273723..b76321056 100644 --- a/CHANGELOG.MD +++ b/CHANGELOG.MD @@ -1,3 +1,24 @@ +## Released v1.1.0 (Sep.1, 2015) +###Features: +- Support for using ScriptAnalyzer as a .net library - ScriptAnalyzer APIs +- Support for ScriptAnalyzer Profiles +- Documentation for using Inline Rule Suppression +- Added about help topic file as part of the module + + +###Rules: +- Rule to checks for UTF8 encoding in help file +- Deprecate Uninitialized Variable rule as per community feedback + + +###Fixes: +- Fix false positive for UsingInternalURL +- WriteVerbose only when analyzing valid powershell files +- DSCClass rules not being applied when exclude rule is used +- Add host to list of initialized variable +- Exclude external non-powershell applications (Console/GUI) from Positional Parameter rule application +- Additional heuristics for detecting psavoidusingplaintextforpassword rule violation + ## Released v1.0.2 (June.24, 2015) ###Features: - Perf improvements in the Engine to execute rules concurrently. From f7229757caad6cc6b2ffab1305dfd9940ffe98c8 Mon Sep 17 00:00:00 2001 From: "Raghu Shantha [MSFT]" Date: Mon, 31 Aug 2015 14:22:56 -0700 Subject: [PATCH 2/4] Update PSScriptAnalyzer.psd1 --- Engine/PSScriptAnalyzer.psd1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Engine/PSScriptAnalyzer.psd1 b/Engine/PSScriptAnalyzer.psd1 index 7a1a109db..7061f8c6d 100644 --- a/Engine/PSScriptAnalyzer.psd1 +++ b/Engine/PSScriptAnalyzer.psd1 @@ -11,7 +11,7 @@ Author = 'Microsoft Corporation' RootModule = 'Microsoft.Windows.PowerShell.ScriptAnalyzer.dll' # Version number of this module. -ModuleVersion = '1.0.2' +ModuleVersion = '1.1.0' # ID used to uniquely identify this module GUID = '324fc715-36bf-4aee-8e58-72e9b4a08ad9' From 5fa4d99343b1af7d70599de342ef2cffaa757a35 Mon Sep 17 00:00:00 2001 From: "Raghu Shantha [MSFT]" Date: Tue, 1 Sep 2015 11:20:52 -0700 Subject: [PATCH 3/4] Update README.md --- README.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/README.md b/README.md index 0de5ddc6c..9a2d3a0d3 100644 --- a/README.md +++ b/README.md @@ -118,6 +118,26 @@ To match all functions/variables/parameters/objects, use `*` as the value of the ) +Profile support in ScriptAnalyzer +======================================== + +Profiles that describe ScriptAnalyzer rules to include/exclude based on `Severity` can be created and supplied to `Invoke-ScriptAnalyzer` using the `-profile` parameter. This enables a user to create custom configuration for a specific environment. + +Using Profile support: + +```powershell +$myProfile = @{ + Severity='Warning' + IncludeRules=@('PSAvoidUsingCmdletAliases', + 'PSAvoidUsingPositionalParameters', + 'PSAvoidUsingInternalURLs' + 'PSAvoidUninitializedVariable') + ExcludeRules=@('PSAvoidUsingCmdletAliases' + 'PSAvoidUninitializedVariable') +} + +Invoke-ScriptAnalyzer -path MyScript.ps1 -Profile $myProfile +``` Building the Code From b00bfffa74c5ad0a51ee3ca9fee69ffedb8208fd Mon Sep 17 00:00:00 2001 From: "Raghu Shantha [MSFT]" Date: Tue, 1 Sep 2015 11:39:43 -0700 Subject: [PATCH 4/4] Update README.md --- README.md | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/README.md b/README.md index 9a2d3a0d3..5a71b127c 100644 --- a/README.md +++ b/README.md @@ -39,6 +39,7 @@ If you have previous version of PSScriptAnalyzer installed on your machine, you To confirm installation: run ```Get-ScriptAnalyzerRule``` in the PowerShell console to obtain the built-in rules + Suppressing Rules ================= @@ -118,6 +119,7 @@ To match all functions/variables/parameters/objects, use `*` as the value of the ) + Profile support in ScriptAnalyzer ======================================== @@ -139,6 +141,32 @@ $myProfile = @{ Invoke-ScriptAnalyzer -path MyScript.ps1 -Profile $myProfile ``` +ScriptAnalyzer as a .net library +================================ + +ScriptAnalyzer engine and functionality can now be directly consumed as a library. + +Here are the public interfaces: + +```c# +using Microsoft.Windows.PowerShell.ScriptAnalyzer; + +public void Initialize(System.Management.Automation.Runspaces.Runspace runspace, +Microsoft.Windows.PowerShell.ScriptAnalyzer.IOutputWriter outputWriter, +[string[] customizedRulePath = null], +[string[] includeRuleNames = null], +[string[] excludeRuleNames = null], +[string[] severity = null], +[bool suppressedOnly = false], +[string profile = null]) + +public System.Collections.Generic.IEnumerable AnalyzePath(string path, +[bool searchRecursively = false]) + +public System.Collections.Generic.IEnumerable GetRule(string[] moduleNames, +string[] ruleNames) +``` + Building the Code =================