diff --git a/RuleDocumentation/AvoidUsingConvertToSecureStringWithPlainTextNoViolations.md b/RuleDocumentation/AvoidUsingConvertToSecureStringWithPlainTextNoViolations.md new file mode 100644 index 000000000..1b5fa2edd --- /dev/null +++ b/RuleDocumentation/AvoidUsingConvertToSecureStringWithPlainTextNoViolations.md @@ -0,0 +1,30 @@ +#AvoidUsingConvertToSecureStringWithPlainTextNoViolations +**Severity Level: Error** + + +##Description + +Information in the script should be protected properly. Using ConvertTo-SecureString with plain text will expose secure information. + +##How to Fix + +To fix a violation of this rule, please use a standard encrypted variable to do the conversion. + +##Example + +Wrong: + +``` +$notsecure = convertto-securestring "abc" -asplaintext -force + +New-Object System.Management.Automation.PSCredential -ArgumentList "username", (ConvertTo-SecureString "notsecure" -AsPlainText -Force) + +``` + +Correct: + +``` +$secure = read-host -assecurestring +$encrypted = convertfrom-securestring -securestring $secure +convertto-securestring -string $encrypted +``` diff --git a/Rules/UseIdenticalMandatoryParametersDSC.cs b/Rules/UseIdenticalMandatoryParametersDSC.cs index 93309e30d..b2aaa3c16 100644 --- a/Rules/UseIdenticalMandatoryParametersDSC.cs +++ b/Rules/UseIdenticalMandatoryParametersDSC.cs @@ -98,7 +98,7 @@ public IEnumerable AnalyzeDSCResource(Ast ast, string fileName { List functionsNotContainingParam = expectedTargetResourceFunctionNames.Except(mandatoryParameters[paramName]).ToList(); yield return new DiagnosticRecord(string.Format(CultureInfo.InvariantCulture, Strings.UseIdenticalMandatoryParametersDSCError, paramName, string.Join(", ", functionsNotContainingParam.ToArray())), - ast.Extent, GetName(), DiagnosticSeverity.Information, fileName); + ast.Extent, GetName(), DiagnosticSeverity.Error, fileName); } } @@ -159,7 +159,7 @@ public SourceType GetSourceType() /// public RuleSeverity GetSeverity() { - return RuleSeverity.Information; + return RuleSeverity.Error; } /// diff --git a/Rules/UseIdenticalParametersDSC.cs b/Rules/UseIdenticalParametersDSC.cs index ff33d03c7..8318c6155 100644 --- a/Rules/UseIdenticalParametersDSC.cs +++ b/Rules/UseIdenticalParametersDSC.cs @@ -67,7 +67,7 @@ public IEnumerable AnalyzeDSCResource(Ast ast, string fileName || !CompareParamAsts(paramAst, paramNames[paramAst.Name.VariablePath.UserPath])) { yield return new DiagnosticRecord(string.Format(CultureInfo.CurrentCulture, Strings.UseIdenticalParametersDSCError), - paramAst.Extent, GetName(), DiagnosticSeverity.Information, fileName); + paramAst.Extent, GetName(), DiagnosticSeverity.Error, fileName); } } } @@ -166,7 +166,7 @@ public SourceType GetSourceType() /// public RuleSeverity GetSeverity() { - return RuleSeverity.Warning; + return RuleSeverity.Error; } /// diff --git a/Rules/UseStandardDSCFunctionsInResource.cs b/Rules/UseStandardDSCFunctionsInResource.cs index 60e729cde..67e9728df 100644 --- a/Rules/UseStandardDSCFunctionsInResource.cs +++ b/Rules/UseStandardDSCFunctionsInResource.cs @@ -54,7 +54,7 @@ public IEnumerable AnalyzeDSCResource(Ast ast, string fileName if (!targetResourceFunctionNamesInAst.Contains(expectedTargetResourceFunctionName, StringComparer.CurrentCultureIgnoreCase)) { yield return new DiagnosticRecord(string.Format(CultureInfo.CurrentCulture, Strings.UseStandardDSCFunctionsInResourceError, expectedTargetResourceFunctionName), - ast.Extent, GetName(), DiagnosticSeverity.Information, fileName); + ast.Extent, GetName(), DiagnosticSeverity.Error, fileName); } } } @@ -85,7 +85,7 @@ item is TypeDefinitionAst if (!functions.Any(function => String.Equals(resourceFunctionName, (function as FunctionMemberAst).Name))) { yield return new DiagnosticRecord(string.Format(CultureInfo.CurrentCulture, Strings.UseStandardDSCFunctionsInClassError, resourceFunctionName), - dscClass.Extent, GetName(), DiagnosticSeverity.Information, fileName); + dscClass.Extent, GetName(), DiagnosticSeverity.Error, fileName); } } } diff --git a/build.cmd b/build.cmd new file mode 100644 index 000000000..e51842115 --- /dev/null +++ b/build.cmd @@ -0,0 +1,15 @@ +@echo off +setlocal +if "%VS120COMNTOOLS%"=="" GOTO NOTOOLS +call "%VS120COMNTOOLS%\VsDevCmd.bat" +msbuild .\PSScriptAnalyzer.sln /p:Configuration=Debug /l:FileLogger,Microsoft.Build.Engine;logfile=PSScriptAnalyzer_Build.log;append=true +if NOT [%ERRORLEVEL%]==[0] pause + +GOTO END + +:NOTOOLS +echo The Visual Studio 2013 tools are not installed +pause + +:END +endlocal \ No newline at end of file