Skip to content

Commit 9697b44

Browse files
Merge branch 'main' into fileMapping
2 parents 407ab41 + 91c6660 commit 9697b44

File tree

5 files changed

+170
-37
lines changed

5 files changed

+170
-37
lines changed

Diff for: Directory.Packages.props

+10-5
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,28 @@
22

33
<PropertyGroup>
44
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
5+
<CentralPackageTransitivePinningEnabled>true</CentralPackageTransitivePinningEnabled>
56
<!-- This is due to noise caused from the Minimatch package, tracked at https://github.com/SLaks/Minimatch/issues/12 -->
67
<NoWarn>$(NoWarn);NU1603</NoWarn>
78
<WebToolsPackageVersion>17.7.273</WebToolsPackageVersion>
89
</PropertyGroup>
910

1011
<ItemGroup>
11-
<PackageVersion Include="Microsoft.Bcl.AsyncInterfaces" Version="7.0.0" />
12+
<PackageVersion Include="Microsoft.Bcl.AsyncInterfaces" Version="8.0.0" />
1213
<PackageVersion Include="Microsoft.Build.Framework" Version="17.8.3" />
1314
<PackageVersion Include="Microsoft.Build.Tasks.Core" Version="17.8.3" />
1415
<PackageVersion Include="Microsoft.Build.Utilities.Core" Version="17.8.3" />
1516
<PackageVersion Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="3.3.1" />
17+
<PackageVersion Include="Microsoft.IO.Redist" Version="6.0.1" />
1618
<PackageVersion Include="Microsoft.VisualStudio.Editor" Version="17.7.188" />
1719
<PackageVersion Include="Microsoft.VisualStudio.Internal.MicroBuild" Version="2.0.66" />
1820
<PackageVersion Include="Microsoft.VisualStudio.Language.Intellisense" Version="17.7.188" />
1921
<PackageVersion Include="Microsoft.VisualStudio.Settings.15.0" Version="17.5.33428.388" />
2022
<PackageVersion Include="Microsoft.VisualStudio.Shell.15.0" Version="17.7.37355" />
21-
<PackageVersion Include="Microsoft.VisualStudio.Threading" Version="17.7.30" />
2223
<PackageVersion Include="Microsoft.VisualStudio.Telemetry" Version="17.7.57" />
24+
<PackageVersion Include="Microsoft.VisualStudio.Threading" Version="17.7.30" />
2325
<PackageVersion Include="Microsoft.VisualStudio.Validation" Version="17.6.11" />
24-
<PackageVersion Include="Microsoft.VSSDK.BuildTools" Version="17.7.2196" />
26+
<PackageVersion Include="Microsoft.VSSDK.BuildTools" Version="17.10.2185" />
2527
<PackageVersion Include="Microsoft.WebTools.Languages.Css" Version="$(WebToolsPackageVersion)" />
2628
<PackageVersion Include="Microsoft.WebTools.Languages.Shared" Version="$(WebToolsPackageVersion)" />
2729
<PackageVersion Include="Microsoft.WebTools.Languages.Shared.Editor" Version="$(WebToolsPackageVersion)" />
@@ -34,14 +36,17 @@
3436
<PackageVersion Include="Nuget.VisualStudio" Version="17.7.1" />
3537

3638
<PackageVersion Include="System.Collections.Immutable" Version="7.0.0" />
39+
<PackageVersion Include="System.Formats.Asn1" Version="8.0.1" />
3740
<PackageVersion Include="System.Memory" Version="4.5.5" />
3841
<PackageVersion Include="System.Net.Http" Version="4.3.1" />
3942
<PackageVersion Include="System.Runtime" Version="4.3.0" />
4043
<PackageVersion Include="System.Runtime.CompilerServices.Unsafe" Version="6.0.0" />
4144
<PackageVersion Include="System.Runtime.Loader" Version="4.3.0" />
42-
<PackageVersion Include="System.Security.Cryptography.ProtectedData" Version="4.5.0" />
45+
<PackageVersion Include="System.Security.Cryptography.ProtectedData" Version="7.0.0" />
46+
<PackageVersion Include="System.Security.Permissions" Version="7.0.0" />
47+
<PackageVersion Include="System.Text.Json" Version="8.0.4" />
4348
<PackageVersion Include="System.Threading.Tasks.Extensions" Version="4.5.4"/>
44-
<PackageVersion Include="System.ValueTuple" Version="4.3.0" />
49+
<PackageVersion Include="System.ValueTuple" Version="4.5.0" />
4550

4651
<!-- Test references -->
4752
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.7.0" />

Diff for: SECURITY.md

+9-29
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,15 @@
1-
<!-- BEGIN MICROSOFT SECURITY.MD V0.0.1 BLOCK -->
1+
# Security Policy
22

3-
## Security
3+
## Supported Versions
44

5-
Microsoft takes the security of our software products and services seriously, which includes all source code repositories managed through our GitHub organizations, which include [Microsoft](https://github.com/Microsoft), [Azure](https://github.com/Azure), [DotNet](https://github.com/dotnet), [AspNet](https://github.com/aspnet), [Xamarin](https://github.com/xamarin), and [many more](https://opensource.microsoft.com/).
5+
The .NET Core and ASP.NET Core support policy, including supported versions can be found at the [.NET Core Support Policy Page](https://dotnet.microsoft.com/platform/support/policy/dotnet-core).
66

7-
If you believe you have found a security vulnerability in any Microsoft-owned repository that meets Microsoft's [definition](https://docs.microsoft.com/en-us/previous-versions/tn-archive/cc751383(v=technet.10)) of a security vulnerability, please report it to us as described below.
7+
## Reporting a Vulnerability
88

9-
## Reporting Security Issues
9+
Security issues and bugs should be reported privately to the Microsoft Security Response Center (MSRC), either by emailing [email protected] or via the portal at https://msrc.microsoft.com.
10+
You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your
11+
original message. Further information, including the MSRC PGP key, can be found in the [MSRC Report an Issue FAQ](https://www.microsoft.com/en-us/msrc/faqs-report-an-issue).
1012

11-
**Please do not report security vulnerabilities through public GitHub issues.** Instead, please report them to the Microsoft Security Response Center at [[email protected]](mailto:[email protected]). If possible, encrypt your message with our PGP key; please download it from the [Microsoft Security Response Center PGP Key page](https://technet.microsoft.com/en-us/security/dn606155).
13+
Reports via MSRC may qualify for the .NET Core Bug Bounty. Details of the .NET Core Bug Bounty including terms and conditions are at [https://aka.ms/corebounty](https://aka.ms/corebounty).
1214

13-
You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. Additional information can be found at [microsoft.com/msrc](https://www.microsoft.com/msrc).
14-
15-
Please include the requested information listed below (as much as you can provide) to help us better understand the nature and scope of the possible issue:
16-
17-
* Type of issue (e.g. buffer overflow, SQL injection, cross-site scripting, etc.)
18-
* Full paths of source file(s) related to the manifestation of the issue
19-
* The location of the affected source code (tag/branch/commit or direct URL)
20-
* Any special configuration required to reproduce the issue
21-
* Step-by-step instructions to reproduce the issue
22-
* Proof-of-concept or exploit code (if possible)
23-
* Impact of the issue, including how an attacker might exploit the issue
24-
25-
This information will help us triage your report more quickly.
26-
27-
## Preferred Languages
28-
29-
We prefer all communications to be in English.
30-
31-
## Policy
32-
33-
Microsoft follows the principle of [Coordinated Vulnerability Disclosure](https://www.microsoft.com/en-us/msrc/cvd).
34-
35-
<!-- END MICROSOFT SECURITY.MD BLOCK -->
15+
Please do not open issues for anything you think might have a security implication.

Diff for: azure-pipelines/official.yml

+10
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,16 @@ trigger:
44
paths:
55
exclude: ["*.md"]
66

7+
schedules:
8+
- cron: "0 8 22-28 * 0" # Fourth Sunday of each month at 8:00 UTC
9+
displayName: "Monthly build check"
10+
branches:
11+
include:
12+
- main
13+
- rel/*
14+
always: true # Run even if there have been no source code changes since the last successful scheduled run
15+
batch: false # Do not run the pipeline if the previously scheduled run is in-progress
16+
717
variables:
818
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
919
BuildConfiguration: Release

Diff for: src/LibraryManager/Json/LibraryStateToFileConverter.cs

+32-3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33

44
using System.Linq;
5+
using System.Diagnostics.CodeAnalysis;
6+
using System.Text;
57
using Microsoft.Web.LibraryManager.Contracts;
68
using Microsoft.Web.LibraryManager.LibraryNaming;
79

@@ -26,10 +28,14 @@ public ILibraryInstallationState ConvertToLibraryInstallationState(LibraryInstal
2628
}
2729

2830
string provider = string.IsNullOrEmpty(stateOnDisk.ProviderId) ? _defaultProvider : stateOnDisk.ProviderId;
29-
string destination = string.IsNullOrEmpty(stateOnDisk.DestinationPath) ? _defaultDestination : stateOnDisk.DestinationPath;
31+
32+
(string name, string version) = LibraryIdToNameAndVersionConverter.Instance.GetLibraryNameAndVersion(stateOnDisk.LibraryId, provider);
33+
string destination = string.IsNullOrEmpty(stateOnDisk.DestinationPath) ? ExpandDestination(_defaultDestination, name, version) : stateOnDisk.DestinationPath;
3034

3135
var state = new LibraryInstallationState()
3236
{
37+
Name = name,
38+
Version = version,
3339
IsUsingDefaultDestination = string.IsNullOrEmpty(stateOnDisk.DestinationPath),
3440
IsUsingDefaultProvider = string.IsNullOrEmpty(stateOnDisk.ProviderId),
3541
ProviderId = provider,
@@ -38,11 +44,34 @@ public ILibraryInstallationState ConvertToLibraryInstallationState(LibraryInstal
3844
FileMappings = stateOnDisk.FileMappings?.Select(f => new Contracts.FileMapping { Destination = f.Destination, Root = f.Root, Files = f.Files }).ToList(),
3945
};
4046

41-
(state.Name, state.Version) = LibraryIdToNameAndVersionConverter.Instance.GetLibraryNameAndVersion(stateOnDisk.LibraryId, provider);
42-
4347
return state;
4448
}
4549

50+
/// <summary>
51+
/// Expands [Name] and [Version] tokens in the DefaultDestination
52+
/// </summary>
53+
/// <param name="destination">The default destination string</param>
54+
/// <param name="name">Package name</param>
55+
/// <param name="version">Package version</param>
56+
/// <returns></returns>
57+
[SuppressMessage("Globalization", "CA1307:Specify StringComparison for clarity", Justification = "Not available on net481, not needed here (caseless)")]
58+
private string ExpandDestination(string destination, string name, string version)
59+
{
60+
if (!destination.Contains("["))
61+
{
62+
return destination;
63+
}
64+
65+
// if the name contains a slash (either filesystem or scoped packages),
66+
// trim that and only take the last segment.
67+
int cutIndex = name.LastIndexOfAny(['/', '\\']);
68+
69+
StringBuilder stringBuilder = new StringBuilder(destination);
70+
stringBuilder.Replace("[Name]", cutIndex == -1 ? name : name.Substring(cutIndex + 1));
71+
stringBuilder.Replace("[Version]", version);
72+
return stringBuilder.ToString();
73+
}
74+
4675
public LibraryInstallationStateOnDisk ConvertToLibraryInstallationStateOnDisk(ILibraryInstallationState state)
4776
{
4877
if (state == null)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
// Copyright (c) .NET Foundation. All rights reserved.
2+
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3+
4+
using System;
5+
using System.IO;
6+
using Microsoft.VisualStudio.TestTools.UnitTesting;
7+
using Microsoft.Web.LibraryManager.Contracts;
8+
using Microsoft.Web.LibraryManager.Json;
9+
using Microsoft.Web.LibraryManager.LibraryNaming;
10+
using Microsoft.Web.LibraryManager.Mocks;
11+
using Microsoft.Web.LibraryManager.Providers.Cdnjs;
12+
13+
namespace Microsoft.Web.LibraryManager.Test.Json
14+
{
15+
[TestClass]
16+
public class LibraryStateToFileConverterTests
17+
{
18+
[TestInitialize]
19+
public void Setup()
20+
{
21+
string cacheFolder = Environment.ExpandEnvironmentVariables(@"%localappdata%\Microsoft\Library\");
22+
string projectFolder = Path.Combine(Path.GetTempPath(), "LibraryManager");
23+
var hostInteraction = new HostInteraction(projectFolder, cacheFolder);
24+
var dependencies = new Dependencies(hostInteraction, new CdnjsProviderFactory());
25+
IProvider provider = dependencies.GetProvider("cdnjs");
26+
LibraryIdToNameAndVersionConverter.Instance.Reinitialize(dependencies);
27+
}
28+
29+
[TestMethod]
30+
public void ConvertToLibraryInstallationState_NullStateOnDisk()
31+
{
32+
LibraryStateToFileConverter converter = new LibraryStateToFileConverter("provider", "destination");
33+
34+
ILibraryInstallationState result = converter.ConvertToLibraryInstallationState(null);
35+
36+
Assert.IsNull(result);
37+
}
38+
39+
[TestMethod]
40+
public void ConvertToLibraryInstallationState_UseDefaultProviderAndDestination()
41+
{
42+
LibraryStateToFileConverter converter = new LibraryStateToFileConverter("defaultProvider", "defaultDestination");
43+
44+
var stateOnDisk = new LibraryInstallationStateOnDisk
45+
{
46+
LibraryId = "libraryId",
47+
};
48+
49+
ILibraryInstallationState result = converter.ConvertToLibraryInstallationState(stateOnDisk);
50+
51+
Assert.AreEqual("defaultProvider", result.ProviderId);
52+
Assert.AreEqual("defaultDestination", result.DestinationPath);
53+
}
54+
55+
[TestMethod]
56+
public void ConvertToLibraryInstallationState_OverrideProviderAndDestination()
57+
{
58+
LibraryStateToFileConverter converter = new LibraryStateToFileConverter("defaultProvider", "defaultDestination");
59+
60+
var stateOnDisk = new LibraryInstallationStateOnDisk
61+
{
62+
LibraryId = "libraryId",
63+
ProviderId = "provider",
64+
DestinationPath = "destination",
65+
};
66+
67+
ILibraryInstallationState result = converter.ConvertToLibraryInstallationState(stateOnDisk);
68+
69+
Assert.AreEqual("provider", result.ProviderId);
70+
Assert.AreEqual("destination", result.DestinationPath);
71+
}
72+
73+
[TestMethod]
74+
public void ConvertToLibraryInstallationState_ExpandTokensInDefaultDestination()
75+
{
76+
LibraryStateToFileConverter converter = new LibraryStateToFileConverter("defaultProvider", "lib/[Name]/[Version]");
77+
78+
var stateOnDisk = new LibraryInstallationStateOnDisk
79+
{
80+
LibraryId = "[email protected]",
81+
// it needs to be a provider that uses the versioned naming scheme
82+
ProviderId = "cdnjs",
83+
};
84+
85+
ILibraryInstallationState result = converter.ConvertToLibraryInstallationState(stateOnDisk);
86+
87+
Assert.AreEqual("lib/testLibraryId/1.0", result.DestinationPath);
88+
}
89+
90+
[TestMethod]
91+
[DataRow("filesystem", "c:\\path\\to\\library")]
92+
[DataRow("filesystem", "/path/to/library")]
93+
[DataRow("cdnjs", "@scope/[email protected]")]
94+
public void ConvertToLibraryInstallationState_ExpandTokensInDefaultDestination_NamesWithSlashes(string provider, string libraryId)
95+
{
96+
LibraryStateToFileConverter converter = new LibraryStateToFileConverter("defaultProvider", "lib/[Name]");
97+
98+
var stateOnDisk = new LibraryInstallationStateOnDisk
99+
{
100+
LibraryId = libraryId,
101+
ProviderId = provider,
102+
};
103+
104+
ILibraryInstallationState result = converter.ConvertToLibraryInstallationState(stateOnDisk);
105+
106+
Assert.AreEqual("lib/library", result.DestinationPath);
107+
}
108+
}
109+
}

0 commit comments

Comments
 (0)