Skip to content

Commit ad60851

Browse files
committed
Merge branch 'azureDev' into zaevansDev
2 parents 111867e + 50f768e commit ad60851

32 files changed

+1389
-43
lines changed

AzurePowershell.Test.targets

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
<AsmXUnitTests Include=".\src\ServiceManagement\Network\Commands.Network.Test\bin\Debug\Microsoft.WindowsAzure.Commands.ServiceManagement.Network.Test.dll"/>
6767
</ItemGroup>
6868
<ItemGroup Condition=" '$(scope)' == 'all' ">
69+
<XUnitTests Include=".\tools\StaticAnalysis\StaticAnalysis.Test\bin\Debug\StaticAnalysis.Test.dll"/>
6970
<XUnitTests Include=".\src\ResourceManager\SiteRecovery\Commands.SiteRecovery.Test\bin\Debug\Microsoft.Azure.Commands.SiteRecovery.Test.dll"/>
7071
<XUnitTests Include=".\src\ResourceManager\Sql\Commands.Sql.Test\bin\Debug\Microsoft.Azure.Commands.Sql.Test.dll"/>
7172
<XUnitTests Include=".\src\ResourceManager\Resources\Commands.Resources.Test\bin\Debug\Microsoft.Azure.Commands.Resources.Test.dll"/>

build.proj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,9 @@
137137
<!-- Restore packages -->
138138
<Exec Command="$(NuGetCommand) restore %(CmdletSolutionsToBuild.FullPath) $(NuGetRestoreConfigSwitch)"
139139
ContinueOnError="false" />
140+
<!-- Restore packages for static analysis-->
141+
<Exec Command="$(NuGetCommand) restore %(StaticAnalysis.FullPath) $(NuGetRestoreConfigSwitch)"
142+
ContinueOnError="false" />
140143

141144
<!--Restore the xunit runner needed to run unit tests-->
142145
<Exec Command="$(NuGetCommand) restore $(MSBuildProjectDirectory)\packages.config -PackagesDirectory $(MSBuildProjectDirectory)\packages" />

src/ResourceManager/Compute/Commands.Compute/Extension/DSC/SetAzureVMDscExtensionCommand.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -190,23 +190,23 @@ public class SetAzureVMDscExtensionCommand : VirtualMachineExtensionBaseCmdlet
190190
///
191191
/// The DSC Azure Extension depends on DSC features that are only available in
192192
/// the WMF updates. This parameter specifies which version of the update to
193-
/// install on the VM. The possible values are "4.0","latest" and "5.0PP".
193+
/// install on the VM. The possible values are "4.0","latest" and "5.0".
194194
///
195195
/// A value of "4.0" will install KB3000850
196196
/// (http://support.microsoft.com/kb/3000850) on Windows 8.1 or Windows Server
197197
/// 2012 R2, or WMF 4.0
198198
/// (http://www.microsoft.com/en-us/download/details.aspx?id=40855) on other
199199
/// versions of Windows if a newer version isnt already installed.
200200
///
201-
/// A value of "5.0PP" will install the latest release of WMF 5.0PP
202-
/// (http://go.microsoft.com/fwlink/?LinkId=398175).
201+
/// A value of "5.0" will install the latest release of WMF 5.0
202+
/// (https://www.microsoft.com/en-us/download/details.aspx?id=50395).
203203
///
204-
/// A value of "latest" will install the latest WMF, currently WMF 5.0PP
204+
/// A value of "latest" will install the latest WMF, currently WMF 5.0
205205
///
206206
/// The default value is "latest"
207207
/// </summary>
208208
[Parameter(ValueFromPipelineByPropertyName = true)]
209-
[ValidateSetAttribute(new[] { "4.0", "latest", "5.0PP" })]
209+
[ValidateSetAttribute(new[] { "4.0", "latest", "5.0PP", "5.0" })]
210210
public string WmfVersion { get; set; }
211211

212212
/// <summary>

src/ResourceManager/Compute/Commands.Compute/Microsoft.Azure.Commands.Compute.dll-Help.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13493,9 +13493,9 @@ Set-AzureRmVMDiskEncryptionExtension -ResourceGroupName $rgname -VMName $vmName
1349313493
<maml:name>WmfVersion</maml:name>
1349413494
<maml:description>
1349513495
<maml:para>
13496-
Specifies the version of the Windows Management Framework (WMF) to install on the VM. The DSC Azure Extension depends on DSC features that are only available in the WMF updates. This parameter specifies which version of the update to install on the VM. The possible values are &quot;4.0&quot;,&quot;latest&quot; and &quot;5.0PP&quot;.
13496+
Specifies the version of the Windows Management Framework (WMF) to install on the VM. The DSC Azure Extension depends on DSC features that are only available in the WMF updates. This parameter specifies which version of the update to install on the VM. The possible values are &quot;4.0&quot;,&quot;latest&quot; and &quot;5.0&quot;.
1349713497
A value of &quot;4.0&quot; will install KB3000850 (http://support.microsoft.com/kb/3000850) on Windows 8.1 or Windows Server 2012 R2, or WMF 4.0 (http://www.microsoft.com/en-us/download/details.aspx?id=40855) on other versions of Windows if a newer version isnt already installed.
13498-
A value of &quot;5.0PP&quot; will install the latest release of WMF 5.0PP (http://go.microsoft.com/fwlink/?LinkId=398175). A value of &quot;latest&quot; will install the latest WMF, currently WMF 5.0PP. The default value is &quot;latest&quot;</maml:para>
13498+
A value of &quot;5.0&quot; will install the latest release of WMF 5.0 (https://www.microsoft.com/en-us/download/details.aspx?id=50395). A value of &quot;latest&quot; will install the latest WMF, currently WMF 5.0. The default value is &quot;latest&quot;</maml:para>
1349913499
</maml:description>
1350013500
<command:parameterValue required="true" variableLength="false">String</command:parameterValue>
1350113501
</command:parameter>
@@ -13721,9 +13721,9 @@ Set-AzureRmVMDiskEncryptionExtension -ResourceGroupName $rgname -VMName $vmName
1372113721
<maml:name>WmfVersion</maml:name>
1372213722
<maml:description>
1372313723
<maml:para>
13724-
Specifies the version of the Windows Management Framework (WMF) to install on the VM. The DSC Azure Extension depends on DSC features that are only available in the WMF updates. This parameter specifies which version of the update to install on the VM. The possible values are &quot;4.0&quot;,&quot;latest&quot; and &quot;5.0PP&quot;.
13724+
Specifies the version of the Windows Management Framework (WMF) to install on the VM. The DSC Azure Extension depends on DSC features that are only available in the WMF updates. This parameter specifies which version of the update to install on the VM. The possible values are &quot;4.0&quot;,&quot;latest&quot; and &quot;5.0&quot;.
1372513725
A value of &quot;4.0&quot; will install KB3000850 (http://support.microsoft.com/kb/3000850) on Windows 8.1 or Windows Server 2012 R2, or WMF 4.0 (http://www.microsoft.com/en-us/download/details.aspx?id=40855) on other versions of Windows if a newer version isnt already installed.
13726-
A value of &quot;5.0PP&quot; will install the latest release of WMF 5.0PP (http://go.microsoft.com/fwlink/?LinkId=398175). A value of &quot;latest&quot; will install the latest WMF, currently WMF 5.0PP. The default value is &quot;latest&quot;</maml:para>
13726+
A value of &quot;5.0&quot; will install the latest release of WMF 5.0 (https://www.microsoft.com/en-us/download/details.aspx?id=50395). A value of &quot;latest&quot; will install the latest WMF, currently WMF 5.0. The default value is &quot;latest&quot;</maml:para>
1372713727
</maml:description>
1372813728
<command:parameterValue required="true" variableLength="false">String</command:parameterValue>
1372913729
<dev:type>

src/ServiceManagement/Compute/Commands.ServiceManagement/IaaS/Extensions/DSC/SetAzureVMDscExtension.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -138,23 +138,23 @@ public class SetAzureVMDscExtension : VirtualMachineExtensionCmdletBase
138138
///
139139
/// The DSC Azure Extension depends on DSC features that are only available in
140140
/// the WMF updates. This parameter specifies which version of the update to
141-
/// install on the VM. The possible values are "4.0","latest" and "5.0PP".
141+
/// install on the VM. The possible values are "4.0","latest" and "5.0".
142142
///
143143
/// A value of "4.0" will install KB3000850
144144
/// (http://support.microsoft.com/kb/3000850) on Windows 8.1 or Windows Server
145145
/// 2012 R2, or WMF 4.0
146146
/// (http://www.microsoft.com/en-us/download/details.aspx?id=40855) on other
147147
/// versions of Windows if a newer version isnt already installed.
148148
///
149-
/// A value of "5.0PP" will install the latest release of WMF 5.0PP
150-
/// (http://go.microsoft.com/fwlink/?LinkId=398175).
149+
/// A value of "5.0" will install the latest release of WMF 5.0
150+
/// (https://www.microsoft.com/en-us/download/details.aspx?id=50395).
151151
///
152-
/// A value of "latest" will install the latest WMF, currently WMF 5.0PP
152+
/// A value of "latest" will install the latest WMF, currently WMF 5.0
153153
///
154154
/// The default value is "latest"
155155
/// </summary>
156156
[Parameter(ValueFromPipelineByPropertyName = true)]
157-
[ValidateSetAttribute(new[] { "4.0", "latest", "5.0PP" })]
157+
[ValidateSetAttribute(new[] { "4.0", "latest", "5.0PP", "5.0" })]
158158
public string WmfVersion { get; set; }
159159

160160
/// <summary>

src/ServiceManagement/Compute/Commands.ServiceManagement/Microsoft.WindowsAzure.Commands.ServiceManagement.dll-Help.xml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36552,6 +36552,16 @@ PS C:\&gt; Update-AzureVM -ServiceName $Service_Name -Name $VM_Name -VM $VM_Upda
3655236552
</maml:description>
3655336553
<command:parameterValue required="true" variableLength="false">IPersistentVM</command:parameterValue>
3655436554
</command:parameter>
36555+
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="true (ByPropertyName)" position="named">
36556+
<maml:name>WmfVersion</maml:name>
36557+
<maml:description>
36558+
<maml:para>
36559+
Specifies the version of the Windows Management Framework (WMF) to install on the VM. The DSC Azure Extension depends on DSC features that are only available in the WMF updates. This parameter specifies which version of the update to install on the VM. The possible values are &quot;4.0&quot;,&quot;latest&quot; and &quot;5.0&quot;.
36560+
A value of &quot;4.0&quot; will install KB3000850 (http://support.microsoft.com/kb/3000850) on Windows 8.1 or Windows Server 2012 R2, or WMF 4.0 (http://www.microsoft.com/en-us/download/details.aspx?id=40855) on other versions of Windows if a newer version isnt already installed.
36561+
A value of &quot;5.0&quot; will install the latest release of WMF 5.0 (https://www.microsoft.com/en-us/download/details.aspx?id=50395). A value of &quot;latest&quot; will install the latest WMF, currently WMF 5.0. The default value is &quot;latest&quot;</maml:para>
36562+
</maml:description>
36563+
<command:parameterValue required="true" variableLength="false">String</command:parameterValue>
36564+
</command:parameter>
3655536565
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
3655636566
<maml:name>DataCollection</maml:name>
3655736567
<maml:description>
@@ -36726,6 +36736,21 @@ PS C:\&gt; Update-AzureVM -ServiceName $Service_Name -Name $VM_Name -VM $VM_Upda
3672636736
</dev:type>
3672736737
<dev:defaultValue>none</dev:defaultValue>
3672836738
</command:parameter>
36739+
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="true (ByPropertyName)" position="named">
36740+
<maml:name>WmfVersion</maml:name>
36741+
<maml:description>
36742+
<maml:para>
36743+
Specifies the version of the Windows Management Framework (WMF) to install on the VM. The DSC Azure Extension depends on DSC features that are only available in the WMF updates. This parameter specifies which version of the update to install on the VM. The possible values are &quot;4.0&quot;,&quot;latest&quot; and &quot;5.0&quot;.
36744+
A value of &quot;4.0&quot; will install KB3000850 (http://support.microsoft.com/kb/3000850) on Windows 8.1 or Windows Server 2012 R2, or WMF 4.0 (http://www.microsoft.com/en-us/download/details.aspx?id=40855) on other versions of Windows if a newer version isnt already installed.
36745+
A value of &quot;5.0&quot; will install the latest release of WMF 5.0 (https://www.microsoft.com/en-us/download/details.aspx?id=50395). A value of &quot;latest&quot; will install the latest WMF, currently WMF 5.0. The default value is &quot;latest&quot;</maml:para>
36746+
</maml:description>
36747+
<command:parameterValue required="true" variableLength="false">String</command:parameterValue>
36748+
<dev:type>
36749+
<maml:name>String</maml:name>
36750+
<maml:uri/>
36751+
</dev:type>
36752+
<dev:defaultValue>latest</dev:defaultValue>
36753+
</command:parameter>
3672936754
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
3673036755
<maml:name>DataCollection</maml:name>
3673136756
<maml:description>

tools/StaticAnalysis/AnalysisLogger.cs

Lines changed: 54 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,27 @@ namespace StaticAnalysis
2626
public abstract class AnalysisLogger
2727
{
2828
string _baseDirectory;
29+
string _exceptionsDirectory;
2930

3031
/// <summary>
3132
/// Create an analysis logger that will write reports to the given directory
3233
/// </summary>
33-
/// <param name="baseDirectory"></param>
34+
/// <param name="baseDirectory">The base directory for reports</param>
35+
/// <param name="exceptionsDirectory">The directory containing exceptions form static analysis rules.</param>
36+
public AnalysisLogger(string baseDirectory, string exceptionsDirectory)
37+
{
38+
_baseDirectory = baseDirectory;
39+
_exceptionsDirectory = exceptionsDirectory;
40+
}
41+
42+
/// <summary>
43+
/// Create an analysis logger without exceptions
44+
/// </summary>
45+
/// <param name="baseDirectory">The base directory for reports</param>
3446
public AnalysisLogger(string baseDirectory)
3547
{
3648
_baseDirectory = baseDirectory;
49+
_exceptionsDirectory = null;
3750
}
3851

3952
IList<ReportLogger> _loggers = new List<ReportLogger>();
@@ -86,15 +99,27 @@ public virtual void WriteWarning(string format, params object[] args)
8699
/// <param name="fileName">The filename (without file path) where the report will be written</param>
87100
/// <returns>The given logger. Analyzer may write records to this logger and they will be written to
88101
/// the report file.</returns>
89-
public virtual ReportLogger<T> CreateLogger<T>(string fileName) where T : IReportRecord, new()
102+
public virtual ReportLogger<T> CreateLogger<T>(string fileName) where T : class, IReportRecord, new()
90103
{
91104
if (string.IsNullOrWhiteSpace(fileName))
92105
{
93106
throw new ArgumentNullException("fileName");
94107
}
95108

96109
var filePath = Path.Combine(_baseDirectory, fileName);
97-
var logger = new ReportLogger<T>(filePath, this);
110+
ReportLogger<T> logger;
111+
if (_exceptionsDirectory != null && Directory.Exists(_exceptionsDirectory))
112+
{
113+
var exceptionsPath = Path.Combine(_exceptionsDirectory, fileName);
114+
WriteWarning("Using exceptions file {0}", exceptionsPath);
115+
logger = new ReportLogger<T>(filePath, exceptionsPath, this);
116+
}
117+
else
118+
{
119+
WriteWarning("Using no exceptions file.");
120+
logger = new ReportLogger<T>(filePath, this);
121+
}
122+
98123
Loggers.Add(logger);
99124
return logger;
100125
}
@@ -116,5 +141,31 @@ public void WriteReports()
116141
WriteReport(logger.FileName, reportText.ToString());
117142
}
118143
}
144+
145+
public void CheckForIssues(int maxSeverity)
146+
{
147+
var hasErrors = false;
148+
foreach (var logger in Loggers.Where(l => l.Records.Any(r => r.Severity < maxSeverity)))
149+
{
150+
hasErrors = true;
151+
StringBuilder errorText = new StringBuilder();
152+
errorText.AppendLine(logger.Records.First().PrintHeaders());
153+
foreach (var reportRecord in logger.Records)
154+
{
155+
errorText.AppendLine(reportRecord.FormatRecord());
156+
}
157+
158+
WriteError("{0} Errors", logger.FileName);
159+
WriteError(errorText.ToString());
160+
WriteError("");
161+
}
162+
163+
if (hasErrors)
164+
{
165+
throw new InvalidOperationException(string.Format("One or more errors occurred in validation. " +
166+
"See the analysis repots at {0} for details",
167+
_baseDirectory));
168+
}
169+
}
119170
}
120171
}

tools/StaticAnalysis/ConsoleLogger.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,15 @@ namespace StaticAnalysis
2323
public class ConsoleLogger : AnalysisLogger
2424
{
2525

26+
public ConsoleLogger(string baseDirectory, string exceptionsDirectory)
27+
: base(baseDirectory, exceptionsDirectory)
28+
{
29+
}
30+
2631
public ConsoleLogger(string baseDirectory)
2732
: base(baseDirectory)
2833
{
2934
}
30-
3135
public override void WriteError(string error)
3236
{
3337
Console.WriteLine("### ERROR {0}", error);

tools/StaticAnalysis/DependencyAnalyzer/AssemblyRecord.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,12 @@ public override string ToString()
114114

115115
}
116116

117+
public override int GetHashCode()
118+
{
119+
return string.Format("{0}-{1}-{2}", AssemblyName, AssemblyFileMajorVersion, AssemblyFileMinorVersion).GetHashCode();
120+
}
121+
122+
117123
/// <summary>
118124
/// Get all the ancestors in the ancestor tree
119125
/// </summary>

tools/StaticAnalysis/DependencyAnalyzer/AssemblyVersionConflict.cs

Lines changed: 46 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
// ----------------------------------------------------------------------------------
1414

1515
using System;
16+
using System.IO;
17+
using System.Text.RegularExpressions;
1618

1719
namespace StaticAnalysis.DependencyAnalyzer
1820
{
@@ -46,6 +48,11 @@ public class AssemblyVersionConflict : IReportRecord
4648
/// </summary>
4749
public string ParentAssembly { get; set; }
4850

51+
/// <summary>
52+
/// Machine readable identity of the problem
53+
/// </summary>
54+
public int ProblemId { get; set; }
55+
4956
/// <summary>
5057
/// A textual description of the problem
5158
/// </summary>
@@ -62,16 +69,52 @@ public string PrintHeaders()
6269
{
6370
return
6471
"\"Directory\",\"AssemblyName\",\"Expected Version\",\"Actual Version\",\"Parent Assembly\",\"Severity\"," +
65-
"\"Description\",\"Remediation\"";
72+
"\"ProblemId\",\"Description\",\"Remediation\"";
6673
}
6774

6875
public string FormatRecord()
6976
{
7077
return
7178
string.Format(
72-
"\"{0}\",\"{1}\",\"{2}\",\"{3}\",\"{4}\",\"{5}\",\"{6}\",\"{7}\"",
79+
"\"{0}\",\"{1}\",\"{2}\",\"{3}\",\"{4}\",\"{5}\",\"{6}\",\"{7}\",\"{8}\"",
7380
Directory, AssemblyName, ExpectedVersion, ActualVersion, ParentAssembly, Severity,
74-
Description, Remediation);
81+
ProblemId, Description, Remediation);
82+
}
83+
public bool Match(IReportRecord other)
84+
{
85+
var result = false;
86+
var record = other as AssemblyVersionConflict;
87+
if (record != null)
88+
{
89+
result = string.Equals(EnvironmentHelpers.GetDirectoryName(record.Directory),
90+
EnvironmentHelpers.GetDirectoryName(Directory), StringComparison.OrdinalIgnoreCase)
91+
&& string.Equals(record.AssemblyName, AssemblyName, StringComparison.OrdinalIgnoreCase)
92+
&& string.Equals(record.ParentAssembly, ParentAssembly, StringComparison.OrdinalIgnoreCase)
93+
&&record.ProblemId == ProblemId;
94+
}
95+
96+
return result;
97+
}
98+
99+
public IReportRecord Parse(string line)
100+
{
101+
var matcher = "\"([^\"]+)\",\"([^\"]+)\",\"([^\"]+)\",\"([^\"]+)\",\"([^\"]+)\",\"([^\"]+)\",\"([^\"]+)\",\"([^\"]+)\",\"([^\"]+)\"";
102+
var match = Regex.Match(line, matcher);
103+
if (!match.Success || match.Groups.Count < 10)
104+
{
105+
throw new InvalidOperationException(string.Format("Could not parse '{0}' as AssemblyVersionConflict record", line));
106+
}
107+
108+
Directory = match.Groups[1].Value;
109+
AssemblyName = match.Groups[2].Value;
110+
ExpectedVersion = Version.Parse(match.Groups[3].Value);
111+
ActualVersion = Version.Parse(match.Groups[4].Value);
112+
ParentAssembly = match.Groups[5].Value;
113+
Severity = int.Parse(match.Groups[6].Value);
114+
ProblemId = int.Parse(match.Groups[7].Value);
115+
Description = match.Groups[8].Value;
116+
Remediation = match.Groups[9].Value;
117+
return this;
75118
}
76119

77120
public override string ToString()

0 commit comments

Comments
 (0)