Skip to content

Commit 8a675a7

Browse files
committed
Merge pull request #137 from PowerShell/BugFixes
Merge BugFixes to Master
2 parents 7a29d19 + 6c388d1 commit 8a675a7

5 files changed

+51
-6
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#AvoidUsingConvertToSecureStringWithPlainTextNoViolations
2+
**Severity Level: Error**
3+
4+
5+
##Description
6+
7+
Information in the script should be protected properly. Using ConvertTo-SecureString with plain text will expose secure information.
8+
9+
##How to Fix
10+
11+
To fix a violation of this rule, please use a standard encrypted variable to do the conversion.
12+
13+
##Example
14+
15+
Wrong:
16+
17+
```
18+
$notsecure = convertto-securestring "abc" -asplaintext -force
19+
20+
New-Object System.Management.Automation.PSCredential -ArgumentList "username", (ConvertTo-SecureString "notsecure" -AsPlainText -Force)
21+
22+
```
23+
24+
Correct:
25+
26+
```
27+
$secure = read-host -assecurestring
28+
$encrypted = convertfrom-securestring -securestring $secure
29+
convertto-securestring -string $encrypted
30+
```

Rules/UseIdenticalMandatoryParametersDSC.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public IEnumerable<DiagnosticRecord> AnalyzeDSCResource(Ast ast, string fileName
9898
{
9999
List<string> functionsNotContainingParam = expectedTargetResourceFunctionNames.Except(mandatoryParameters[paramName]).ToList();
100100
yield return new DiagnosticRecord(string.Format(CultureInfo.InvariantCulture, Strings.UseIdenticalMandatoryParametersDSCError, paramName, string.Join(", ", functionsNotContainingParam.ToArray())),
101-
ast.Extent, GetName(), DiagnosticSeverity.Information, fileName);
101+
ast.Extent, GetName(), DiagnosticSeverity.Error, fileName);
102102
}
103103

104104
}
@@ -159,7 +159,7 @@ public SourceType GetSourceType()
159159
/// <returns></returns>
160160
public RuleSeverity GetSeverity()
161161
{
162-
return RuleSeverity.Information;
162+
return RuleSeverity.Error;
163163
}
164164

165165
/// <summary>

Rules/UseIdenticalParametersDSC.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public IEnumerable<DiagnosticRecord> AnalyzeDSCResource(Ast ast, string fileName
6767
|| !CompareParamAsts(paramAst, paramNames[paramAst.Name.VariablePath.UserPath]))
6868
{
6969
yield return new DiagnosticRecord(string.Format(CultureInfo.CurrentCulture, Strings.UseIdenticalParametersDSCError),
70-
paramAst.Extent, GetName(), DiagnosticSeverity.Information, fileName);
70+
paramAst.Extent, GetName(), DiagnosticSeverity.Error, fileName);
7171
}
7272
}
7373
}
@@ -166,7 +166,7 @@ public SourceType GetSourceType()
166166
/// <returns></returns>
167167
public RuleSeverity GetSeverity()
168168
{
169-
return RuleSeverity.Warning;
169+
return RuleSeverity.Error;
170170
}
171171

172172
/// <summary>

Rules/UseStandardDSCFunctionsInResource.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public IEnumerable<DiagnosticRecord> AnalyzeDSCResource(Ast ast, string fileName
5454
if (!targetResourceFunctionNamesInAst.Contains(expectedTargetResourceFunctionName, StringComparer.CurrentCultureIgnoreCase))
5555
{
5656
yield return new DiagnosticRecord(string.Format(CultureInfo.CurrentCulture, Strings.UseStandardDSCFunctionsInResourceError, expectedTargetResourceFunctionName),
57-
ast.Extent, GetName(), DiagnosticSeverity.Information, fileName);
57+
ast.Extent, GetName(), DiagnosticSeverity.Error, fileName);
5858
}
5959
}
6060
}
@@ -85,7 +85,7 @@ item is TypeDefinitionAst
8585
if (!functions.Any(function => String.Equals(resourceFunctionName, (function as FunctionMemberAst).Name)))
8686
{
8787
yield return new DiagnosticRecord(string.Format(CultureInfo.CurrentCulture, Strings.UseStandardDSCFunctionsInClassError, resourceFunctionName),
88-
dscClass.Extent, GetName(), DiagnosticSeverity.Information, fileName);
88+
dscClass.Extent, GetName(), DiagnosticSeverity.Error, fileName);
8989
}
9090
}
9191
}

build.cmd

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
@echo off
2+
setlocal
3+
if "%VS120COMNTOOLS%"=="" GOTO NOTOOLS
4+
call "%VS120COMNTOOLS%\VsDevCmd.bat"
5+
msbuild .\PSScriptAnalyzer.sln /p:Configuration=Debug /l:FileLogger,Microsoft.Build.Engine;logfile=PSScriptAnalyzer_Build.log;append=true
6+
if NOT [%ERRORLEVEL%]==[0] pause
7+
8+
GOTO END
9+
10+
:NOTOOLS
11+
echo The Visual Studio 2013 tools are not installed
12+
pause
13+
14+
:END
15+
endlocal

0 commit comments

Comments
 (0)