Skip to content

Commit

Permalink
Merge pull request #946 from Microsoft/merge_develop_to_master(prep_2.8)
Browse files Browse the repository at this point in the history
Merge develop to master(prep 2.8)
  • Loading branch information
TimothyMothra authored Oct 9, 2018
2 parents 25cd320 + 9ccfcd0 commit ca969ec
Show file tree
Hide file tree
Showing 42 changed files with 991 additions and 211 deletions.
4 changes: 3 additions & 1 deletion ApplicationInsightsSDKRules.ruleset
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
<Rule Id="CA1049" Action="Warning" />
<Rule Id="CA1060" Action="Warning" />
<Rule Id="CA1061" Action="Warning" />
<Rule Id="CA1063" Action="Warning" />
<!-- Disabling this check "CA1063: Implement IDisposable correctly".
This analyzer has a bug which fails the build, https://github.com/dotnet/roslyn-analyzers/issues/1815 -->
<Rule Id="CA1063" Action="None" />
<Rule Id="CA1065" Action="Warning" />
<Rule Id="CA1304" Action="Warning" />
<Rule Id="CA1305" Action="Warning" />
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

This changelog will be used to generate documentation on [release notes page](http://azure.microsoft.com/documentation/articles/app-insights-release-notes-dotnet/).

## Version 2.8.0
- [New API to store/retrieve any raw objects on TelemetryContext to enable AutoCollectors to pass additional information for use by TelemetryInitializers.](https://github.com/Microsoft/ApplicationInsights-dotnet/issues/937)
- Perf Improvements
https://github.com/Microsoft/ApplicationInsights-dotnet/issues/927
https://github.com/Microsoft/ApplicationInsights-dotnet/issues/930
https://github.com/Microsoft/ApplicationInsights-dotnet/issues/934
- Fix: [Response code shouldn't be overwritten to 200 if not set](https://github.com/Microsoft/ApplicationInsights-dotnet/pull/918)

## Version 2.8.0-beta2
- [TelemetryProcessors (sampling, autocollectedmetricaggregator), TelemetryChannel (ServerTelemetryChannel) added automatically to the default ApplicationInsights.config are moved under the default telemetry sink.](https://github.com/Microsoft/ApplicationInsights-dotnet/issues/907)
If you are upgrading, and have added/modified TelemetryProcessors/TelemetryChannel, make sure to copy them to the default sink section.
Expand Down
3 changes: 1 addition & 2 deletions Common.props
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@
<PropertyGroup Condition="'$(Configuration)' == 'Release'">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<!-- Need to disable WarningsAsErrors until all FxCop issues are fixed. -->
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<DefineConstants>$(DefineConstants);TRACE</DefineConstants>
</PropertyGroup>

Expand Down
2 changes: 1 addition & 1 deletion GlobalStaticVersion.props
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<SemanticVersionMinor>8</SemanticVersionMinor>
<SemanticVersionPatch>0</SemanticVersionPatch>
<!--Valid values: beta1, beta2, EMPTY for stable -->
<PreReleaseMilestone>beta2</PreReleaseMilestone>
<PreReleaseMilestone></PreReleaseMilestone>
<!--
Date when Semantic Version was changed.
Update for every public release.
Expand Down
1 change: 1 addition & 0 deletions Microsoft.ApplicationInsights.sln
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
dirs.proj = dirs.proj
GlobalStaticVersion.props = GlobalStaticVersion.props
NuGet.config = NuGet.config
Nupkg.props = Nupkg.props
Package.targets = Package.targets
README.md = README.md
Signing.props = Signing.props
Expand Down
Binary file modified NuGet.exe
Binary file not shown.
318 changes: 318 additions & 0 deletions NugetAudit.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,318 @@

# This script checks the Authoring Requirements listed here:
# Full Requirements: https://microsoft.sharepoint.com/teams/NuGet/MicrosoftWiki/MicrosoftPackages.aspx
# Authoring Requirements: https://microsoft.sharepoint.com/teams/NuGet/MicrosoftWiki/AuthoringRequirements.aspx
# Signing Requirements: https://microsoft.sharepoint.com/teams/NuGet/MicrosoftWiki/SigningMicrosoftPackages.aspx
Param(
[Parameter(Mandatory=$true,HelpMessage="Path to Artifact files (nupkg):")]
[string]
$path,
[Parameter(Mandatory=$true,HelpMessage="Full Log?:")] #Include Pass with Fail output?
[bool]
$verboseLog
)


$requiredCopyright = "$([char]0x00A9) Microsoft Corporation. All rights reserved.";#"© Microsoft Corporation. All rights reserved.";
$expectedProjectUrl = "https://go.microsoft.com/fwlink/?LinkId=392727"; # Application Insights Project Url
$expectedLicenseUrl = "https://go.microsoft.com/fwlink/?LinkID=510709"; # Application Insights license Url
$expectedOwner = "AppInsightsSdk"; # Application Insights Nuget Account
$expectedTags = @("Azure","Monitoring");

$sb = [System.Text.StringBuilder]::new();

$script:isValid = $true;


# Get the latest Nuget.exe from here:
if (!(Test-Path ".\Nuget.exe")) {

Write-Host "Nuget.exe not found. Attempting download...";
Write-Host "Start time:" (Get-Date -Format G);
$downloadNugetUrl = "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe";
$saveFile = "$PSScriptRoot\Nuget.exe";
(New-Object System.Net.WebClient).DownloadFile($downloadNugetUrl, $saveFile);
Write-Host "Finish time:" (Get-Date -Format G);

if (!(Test-Path ".\Nuget.exe")) {
throw "Error: Nuget.exe not found! Please download latest from: https://www.nuget.org/downloads";
}
}

function Write-Break() {
$displayMessage = "========== ========== ========== ========== ==========";
Write-Host "";
Write-Host $displayMessage;
$null = $sb.AppendLine();
$null = $sb.AppendLine($displayMessage);
}

function Write-Name([string]$message) {
Write-Host $message;
$null = $sb.AppendLine($message);
}

function Write-IsValid ([string]$message) {
if ($verboseLog) {
$displayMessage = "`tPass:`t$message";
Write-Host $displayMessage -ForegroundColor Green;
$null = $sb.AppendLine($displayMessage);
}
}

function Write-SemiValid ([string]$message, [string]$recommendedDescription) {
$displayMessage = "`tReview:`t$message [Recommended: $recommendedDescription]";
Write-Host $displayMessage -ForegroundColor Yellow;
$null = $sb.AppendLine($displayMessage);
}

function Write-NotValid ([string]$message, [string]$requiredDescription) {
$displayMessage = "`tFail:`t$message [Required: $requiredDescription]";
Write-Host $displayMessage -ForegroundColor Red;
$null = $sb.AppendLine($displayMessage);
$script:isValid = $false;
}

function Test-Condition ([bool]$condition, [string]$message, [string]$requiredDescription) {
if ($condition) {
Write-IsValid $message
} else {
Write-NotValid $message $requiredDescription
}
}

function Test-MultiCondition ([bool]$requiredCondition, [bool]$recommendedCondition, [string]$message, [string]$requiredDescription, [string]$recommendedDescription) {
if ($requiredCondition) {
if($recommendedCondition) {
Write-IsValid $message
} else {
Write-SemiValid $message $recommendedDescription
}
} else {
Write-NotValid $message $requiredDescription
}
}

function Get-IsPackageSigned([string]$nupkgPath) {
$verifyOutput = "";
$null = .\Nuget.exe verify -signature -CertificateFingerprint 3F9001EA83C560D712C24CF213C3D312CB3BFF51EE89435D3430BD06B5D0EECE $nupkgPath -verbosity detailed 2>&1 | Tee-Object -Variable verifyOutput

#TEST OUTPUT
Write-Host $verifyOutput

$output = $verifyOutput[$verifyOutput.Length-1]

$success = ($output -like "Successfully verified*");

if (!$success){
$verifyOutput | Where-Object { $_ -like "NU*" -and $_ -notlike "NUGET*"} | ForEach-Object {
$output = "$output $_" -replace "`n","" -replace "`r","";
}
}

$message = "Is Signed: $output";
$requirement = "Must be signed."

Test-Condition ($success) $message $requirement;
}


function Get-IsDllSigned ([string]$dllPath) {
$test = Get-AuthenticodeSignature $dllPath; # this is equivalent to signtool.exe verify /pa
$SignedStatus = $test.Status;
$SignatureValid = [System.Management.Automation.SignatureStatus]::Valid;

$message = "Is Signed: $SignedStatus";
$requirement = "Must be signed."

Test-Condition ($SignedStatus -eq $SignatureValid) $message $requirement;
}

function Get-DoesXmlDocExist ([string]$dllPath) {
# CONFIRM .XML DOCUMENTATION FILE EXISTS WITH EACH DLL
[string]$docFile = $dllPath -replace ".dll", ".xml";

$message = "XML Documentation:";
$requirement = "Must exist."
Test-Condition (Test-Path $docFile) $message $requirement;
}

function Get-IsValidPackageId([xml]$nuspecXml) {
$id = $nuspecXml.package.metadata.id;

$message = "Package Id: $id";
$requirement = "Must begin with 'Microsoft.'"

Test-Condition ($id.StartsWith("Microsoft.")) $message $requirement;
}

function Get-IsValidAuthors([xml]$nuspecXml) {
$authors = $nuspecXml.package.metadata.authors;

$message = "Authors: $authors";
$requirement = "Microsoft must be the only author.";

Test-Condition ($authors -eq "Microsoft") $message $requirement;
}

function Get-IsValidOwners([xml]$nuspecXml) {
$owners = $nuspecXml.package.metadata.owners;
$ownersList = $owners -split ',';

$message = "Owners: $owners";
$requirement = "Must include Microsoft."
$recommendation = "Should include nuget owner."

Test-MultiCondition ($ownersList -contains "Microsoft") ($ownersList -contains $expectedOwner -and $ownersList.Length -eq 2) $message $requirement $recommendation;
}

function Get-IsValidProjectUrl([xml]$nuspecXml) {
$projectUrl = $nuspecXml.package.metadata.projectUrl;

$message = "Project Url: $projectUrl";
$requirement = "Must match expected."

Test-Condition ($projectUrl -eq $expectedProjectUrl) $message $requirement;
}

function Get-IsValidLicenseUrl([xml]$nuspecXml) {
$licenseUrl = $nuspecXml.package.metadata.licenseUrl;

$message = "License Url: $licenseUrl";
$requirement = "Must match expected."
$recommendation = "Should not use FWLINK."

Test-MultiCondition ($licenseUrl -eq $expectedLicenseUrl) ($licenseUrl -notlike "*fwlink*") $message $requirement $recommendation;
}

function Get-IsValidLicenseAcceptance([xml]$nuspecXml) {
$requireLicenseAcceptance = $nuspecXml.package.metadata.requireLicenseAcceptance;

$message = "Require License Acceptance: $requireLicenseAcceptance";
$requirement = "Not mandatory requirement."
$recommendation = "Should require.";

Test-MultiCondition ($true) ($requireLicenseAcceptance -eq $true) $message $requirement $recommendation;
}

function Get-IsValidCopyright([xml]$nuspecXml) {
$copyright = $nuspecXml.package.metadata.copyright;

$message = "Copyright: $copyright";
$requirement = "Must match '$requiredCopyright'";

Test-Condition ($copyright -eq $requiredCopyright) $message $requirement;
}

function Get-IsValidDescription([xml]$nuspecXml) {
$description = $nuspecXml.package.metadata.description;
$hasDescription = !([System.String]::IsNullOrEmpty($description));

$message = "Description: $description";
$requirement = "Must have a description."

Test-Condition $hasDescription $message $requirement;
}

function Get-IsValidTags([xml]$nuspecXml) {
$tags = $nuspecXml.package.metadata.tags;
$hasTags = !([System.String]::IsNullOrEmpty($tags));

$message = "Tags: $tags";
$requirement = "Must have tags."
Test-Condition $hasTags $message $requirement;

$tagsArray = @();
if($hasTags) {
$tagsArray = $tags -split " ";
}

$expectedTags | ForEach-Object {
$hasTag = $tagsArray.Contains($_);
$requirement = "Must include tag: $_";
Test-Condition $hasTag $message $requirement;
}
}

function Get-IsValidLogoUrl([xml]$nuspecXml, $path) {
$logoUrl = $nuspecXml.package.metadata.iconUrl;
$isEmpty = [System.String]::IsNullOrEmpty($logoUrl);
$dimension = "";

try {
$filePath = Join-Path $path "logo.png";
$wc = New-Object System.Net.WebClient;
$wc.DownloadFile($logoUrl, $filePath);
add-type -AssemblyName System.Drawing
$png = New-Object System.Drawing.Bitmap $filePath
$dimension = "$($png.Height)x$($png.Width)";

# Release lock on png file
Remove-Variable png;
Remove-Variable wc;
} catch [System.SystemException] {
$_.Exception.Message;
}

[string[]]$expectedDimensions = ("32x32","48x48","64x64","128x128");

$message = "Logo Url: $logoUrl Dimensions: $dimension";
$requirement = "Must have a logo."
$recommendation = "Should be one of these sizes: $expectedDimensions";

$isExpected = ($expectedDimensions -contains $dimension);

Test-MultiCondition (!$isEmpty) ($isExpected) $message $requirement $recommendation;
}

function Invoke-UnZip([string]$zipfile, [string]$outpath) {
Write-Verbose "Unzip - source: $zipfile"
Write-Verbose "Unzip - target: $outpath"
Add-Type -assembly "system.io.compression.filesystem"
[System.IO.Compression.ZipFile]::ExtractToDirectory($zipfile, $outpath)
}

function Start-EvaluateNupkg ($nupkgPath) {
Write-Break;
Write-Name $nupkgPath;

Get-IsPackageSigned $nupkgPath;


$unzipPath = $nupkgPath+"_unzip";
Remove-Item $unzipPath -Recurse -ErrorAction Ignore
$null = Invoke-UnZip $nupkgPath $unzipPath;

# LOOK FOR ALL NUSPEC WITHIN NUPKG
Get-ChildItem -Path $unzipPath -Recurse -Filter *.nuspec | ForEach-Object {
Write-Name $_.FullName;
[xml]$nuspecXml = Get-Content $_.FullName
Get-IsValidPackageId $nuspecXml;
Get-IsValidAuthors $nuspecXml;
Get-IsValidOwners $nuspecXml;
Get-IsValidProjectUrl $nuspecXml;
Get-IsValidLicenseUrl $nuspecXml;
Get-IsValidLicenseAcceptance $nuspecXml;
Get-IsValidCopyright $nuspecXml;
Get-IsValidLogoUrl $nuspecXml $unzipPath;
Get-IsValidDescription $nuspecXml;
Get-IsValidTags $nuspecXml;
}

# LOOK FOR ALL DLL WITHIN NUPKG
Get-ChildItem -Path $unzipPath -Recurse -Filter *.dll | ForEach-Object {
Write-Name $_.FullName;
Get-IsDllSigned $_.FullName;
Get-DoesXmlDocExist $_.FullName;
}
}

# LOOK FOR ALL NUPKG IN A DIRECTORY.
Get-ChildItem -Path $path -Recurse -Filter *.nupkg -Exclude *.symbols.nupkg |
ForEach-Object { Start-EvaluateNupkg $_.FullName }

$sb.ToString() | Add-Content (Join-Path $path "log.txt");

if (!$script:isValid){
throw "NUPKG or DLL is not valid. Please review log...";
}
Loading

0 comments on commit ca969ec

Please sign in to comment.