dependabot-nuget 0.322.2 → 0.325.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli/Program.cs +0 -4
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Analyze/AnalyzeWorker.cs +1 -31
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Analyze/DependencyFinder.cs +0 -3
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Analyze/DependencyInfo.cs +1 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Analyze/VersionFinder.cs +64 -10
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Clone/CloneWorker.cs +1 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/DependencySolver/MSBuildDependencySolver.cs +10 -4
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/DiscoveryWorker.cs +4 -4
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/PackagesConfigDiscovery.cs +2 -2
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/SdkProjectDiscovery.cs +31 -41
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/ExperimentsManager.cs +3 -6
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/ApiModel/Cooldown.cs +83 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/ApiModel/Job.cs +2 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/ModifiedFilesTracker.cs +9 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/PullRequestBodyGenerator/DetailedPullRequestBodyGenerator.cs +6 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/RunWorker.cs +8 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/UpdateHandlers/CreateSecurityUpdatePullRequestHandler.cs +1 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/UpdateHandlers/GroupUpdateAllVersionsHandler.cs +79 -67
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/UpdateHandlers/RefreshGroupUpdatePullRequestHandler.cs +1 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/UpdateHandlers/RefreshSecurityUpdatePullRequestHandler.cs +1 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/UpdateHandlers/RefreshVersionUpdatePullRequestHandler.cs +1 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/FileWriters/FileWriterWorker.cs +10 -7
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/FileWriters/XmlFileWriter.cs +245 -125
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/LockFileUpdater.cs +4 -11
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/PackageReferenceUpdater.cs +4 -5
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/UpdaterWorker.cs +1 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/DependencyConflictResolver.cs +2 -2
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/MSBuildHelper.cs +14 -31
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/NuGetHelper.cs +3 -5
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/ProcessExtensions.cs +12 -13
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/XmlExtensions.cs +3 -3
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Analyze/AnalyzeWorkerTests.cs +78 -2
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Analyze/VersionFinderTests.cs +126 -3
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Clone/CloneWorkerTests.cs +14 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/DependencySolver/MSBuildDependencySolverTests.cs +1 -2
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTestBase.cs +2 -2
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTests.Project.cs +1 -2
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTests.cs +0 -6
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/SdkProjectDiscoveryTests.cs +2 -3
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/MockNuGetPackage.cs +1 -2
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/ApiModel/CooldownTests.cs +99 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/MiscellaneousTests.cs +168 -4
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/PullRequestBodyGenerator/DetailedPullRequestBodyGeneratorTests.cs +71 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/SerializationTests.cs +71 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/UpdateHandlers/GroupUpdateAllVersionsHandlerTests.cs +70 -39
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/FileWriters/FileWriterWorkerTests.cs +43 -30
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/FileWriters/XmlFileWriterTests.cs +76 -3
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/PackageReferenceUpdaterTests.cs +0 -2
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Utilities/MSBuildHelperTests.cs +11 -27
- data/lib/dependabot/nuget.rb +3 -11
- metadata +8 -54
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli/Commands/AnalyzeCommand.cs +0 -49
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli/Commands/DiscoverCommand.cs +0 -60
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli/Commands/FrameworkCheckCommand.cs +0 -35
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli/Commands/UpdateCommand.cs +0 -58
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli.Test/EntryPointTests.Analyze.cs +0 -380
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli.Test/EntryPointTests.Discover.cs +0 -557
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli.Test/EntryPointTests.FrameworkCheck.cs +0 -37
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli.Test/EntryPointTests.Update.cs +0 -226
- data/lib/dependabot/nuget/analysis/analysis_json_reader.rb +0 -65
- data/lib/dependabot/nuget/analysis/dependency_analysis.rb +0 -66
- data/lib/dependabot/nuget/cache_manager.rb +0 -29
- data/lib/dependabot/nuget/discovery/dependency_details.rb +0 -102
- data/lib/dependabot/nuget/discovery/dependency_file_discovery.rb +0 -122
- data/lib/dependabot/nuget/discovery/discovery_json_reader.rb +0 -266
- data/lib/dependabot/nuget/discovery/evaluation_details.rb +0 -63
- data/lib/dependabot/nuget/discovery/project_discovery.rb +0 -104
- data/lib/dependabot/nuget/discovery/property_details.rb +0 -43
- data/lib/dependabot/nuget/discovery/workspace_discovery.rb +0 -61
- data/lib/dependabot/nuget/file_fetcher.rb +0 -46
- data/lib/dependabot/nuget/file_parser.rb +0 -153
- data/lib/dependabot/nuget/file_updater.rb +0 -256
- data/lib/dependabot/nuget/language.rb +0 -98
- data/lib/dependabot/nuget/metadata_finder.rb +0 -197
- data/lib/dependabot/nuget/native_helpers.rb +0 -364
- data/lib/dependabot/nuget/nuget_config_credential_helpers.rb +0 -88
- data/lib/dependabot/nuget/package_manager.rb +0 -51
- data/lib/dependabot/nuget/update_checker/requirements_updater.rb +0 -105
- data/lib/dependabot/nuget/update_checker.rb +0 -210
@@ -1,226 +0,0 @@
|
|
1
|
-
using System.IO;
|
2
|
-
using System.Text;
|
3
|
-
|
4
|
-
using NuGetUpdater.Core;
|
5
|
-
using NuGetUpdater.Core.Test;
|
6
|
-
using NuGetUpdater.Core.Test.Update;
|
7
|
-
|
8
|
-
using Xunit;
|
9
|
-
|
10
|
-
namespace NuGetUpdater.Cli.Test;
|
11
|
-
|
12
|
-
public partial class EntryPointTests
|
13
|
-
{
|
14
|
-
public class Update : UpdateWorkerTestBase
|
15
|
-
{
|
16
|
-
[Fact]
|
17
|
-
public async Task WithProject()
|
18
|
-
{
|
19
|
-
await Run(path =>
|
20
|
-
[
|
21
|
-
"update",
|
22
|
-
"--job-id",
|
23
|
-
"TEST-JOB-ID",
|
24
|
-
"--job-path",
|
25
|
-
Path.Combine(path, "job.json"),
|
26
|
-
"--repo-root",
|
27
|
-
path,
|
28
|
-
"--solution-or-project",
|
29
|
-
Path.Combine(path, "path/to/my.csproj"),
|
30
|
-
"--dependency",
|
31
|
-
"Some.Package",
|
32
|
-
"--new-version",
|
33
|
-
"13.0.1",
|
34
|
-
"--previous-version",
|
35
|
-
"7.0.1"
|
36
|
-
],
|
37
|
-
packages:
|
38
|
-
[
|
39
|
-
MockNuGetPackage.CreateSimplePackage("Some.Package", "7.0.1", "net45"),
|
40
|
-
MockNuGetPackage.CreateSimplePackage("Some.Package", "13.0.1", "net45"),
|
41
|
-
],
|
42
|
-
initialFiles:
|
43
|
-
[
|
44
|
-
("path/to/my.csproj", """
|
45
|
-
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
46
|
-
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
47
|
-
<PropertyGroup>
|
48
|
-
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
49
|
-
</PropertyGroup>
|
50
|
-
<ItemGroup>
|
51
|
-
<None Include="packages.config" />
|
52
|
-
</ItemGroup>
|
53
|
-
<ItemGroup>
|
54
|
-
<Reference Include="Some.Package">
|
55
|
-
<HintPath>packages\Some.Package.7.0.1\lib\net45\Some.Package.dll</HintPath>
|
56
|
-
<Private>True</Private>
|
57
|
-
</Reference>
|
58
|
-
</ItemGroup>
|
59
|
-
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
60
|
-
</Project>
|
61
|
-
"""),
|
62
|
-
("path/to/packages.config", """
|
63
|
-
<packages>
|
64
|
-
<package id="Some.Package" version="7.0.1" targetFramework="net45" />
|
65
|
-
</packages>
|
66
|
-
""")
|
67
|
-
],
|
68
|
-
expectedFiles:
|
69
|
-
[
|
70
|
-
("path/to/my.csproj", """
|
71
|
-
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
72
|
-
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
73
|
-
<PropertyGroup>
|
74
|
-
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
75
|
-
</PropertyGroup>
|
76
|
-
<ItemGroup>
|
77
|
-
<None Include="packages.config" />
|
78
|
-
</ItemGroup>
|
79
|
-
<ItemGroup>
|
80
|
-
<Reference Include="Some.Package">
|
81
|
-
<HintPath>packages\Some.Package.13.0.1\lib\net45\Some.Package.dll</HintPath>
|
82
|
-
<Private>True</Private>
|
83
|
-
</Reference>
|
84
|
-
</ItemGroup>
|
85
|
-
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
86
|
-
</Project>
|
87
|
-
"""),
|
88
|
-
("path/to/packages.config", """
|
89
|
-
<?xml version="1.0" encoding="utf-8"?>
|
90
|
-
<packages>
|
91
|
-
<package id="Some.Package" version="13.0.1" targetFramework="net45" />
|
92
|
-
</packages>
|
93
|
-
""")
|
94
|
-
]
|
95
|
-
);
|
96
|
-
}
|
97
|
-
|
98
|
-
[Theory]
|
99
|
-
[InlineData(null)]
|
100
|
-
[InlineData("src")]
|
101
|
-
public async Task UpdaterDoesNotUseRepoGlobalJsonForMSBuildTasks(string? workingDirectoryPath)
|
102
|
-
{
|
103
|
-
// This is a _very_ specific scenario where the `NuGetUpdater.Cli` tool might pick up a `global.json` from
|
104
|
-
// the root of the repo under test and use it's `sdk` property when trying to locate MSBuild. To properly
|
105
|
-
// test this, it must be tested in a new process where MSBuild has not been loaded yet and the runner tool
|
106
|
-
// must be started with its working directory at the test repo's root.
|
107
|
-
using var tempDir = new TemporaryDirectory();
|
108
|
-
|
109
|
-
MockNuGetPackage[] testPackages =
|
110
|
-
[
|
111
|
-
MockNuGetPackage.CreateSimplePackage("Some.Package", "7.0.1", "net8.0"),
|
112
|
-
MockNuGetPackage.CreateSimplePackage("Some.Package", "13.0.1", "net8.0"),
|
113
|
-
];
|
114
|
-
await MockNuGetPackagesInDirectory(testPackages, tempDir.DirectoryPath);
|
115
|
-
await MockJobFileInDirectory(tempDir.DirectoryPath);
|
116
|
-
|
117
|
-
var globalJsonPath = Path.Join(tempDir.DirectoryPath, "global.json");
|
118
|
-
var srcGlobalJsonPath = Path.Join(tempDir.DirectoryPath, "src", "global.json");
|
119
|
-
string globalJsonContent = """
|
120
|
-
{
|
121
|
-
"sdk": {
|
122
|
-
"version": "99.99.99"
|
123
|
-
}
|
124
|
-
}
|
125
|
-
""";
|
126
|
-
await File.WriteAllTextAsync(globalJsonPath, globalJsonContent, TestContext.Current.CancellationToken);
|
127
|
-
Directory.CreateDirectory(Path.Join(tempDir.DirectoryPath, "src"));
|
128
|
-
await File.WriteAllTextAsync(srcGlobalJsonPath, globalJsonContent, TestContext.Current.CancellationToken);
|
129
|
-
var projectPath = Path.Join(tempDir.DirectoryPath, "src", "project.csproj");
|
130
|
-
await File.WriteAllTextAsync(projectPath, """
|
131
|
-
<Project Sdk="Microsoft.NET.Sdk">
|
132
|
-
<PropertyGroup>
|
133
|
-
<TargetFramework>net8.0</TargetFramework>
|
134
|
-
</PropertyGroup>
|
135
|
-
<ItemGroup>
|
136
|
-
<PackageReference Include="Some.Package" Version="7.0.1" />
|
137
|
-
</ItemGroup>
|
138
|
-
</Project>
|
139
|
-
""", TestContext.Current.CancellationToken);
|
140
|
-
await File.WriteAllTextAsync(Path.Join(Path.GetDirectoryName(projectPath)!, "Directory.Build.props"), "<Project />", TestContext.Current.CancellationToken);
|
141
|
-
await File.WriteAllTextAsync(Path.Join(Path.GetDirectoryName(projectPath)!, "Directory.Build.targets"), "<Project />", TestContext.Current.CancellationToken);
|
142
|
-
await File.WriteAllTextAsync(Path.Join(Path.GetDirectoryName(projectPath)!, "Directory.Packages.props"), """
|
143
|
-
<Project>
|
144
|
-
<PropertyGroup>
|
145
|
-
<ManagePackageVersionsCentrally>false</ManagePackageVersionsCentrally>
|
146
|
-
</PropertyGroup>
|
147
|
-
</Project>
|
148
|
-
""", TestContext.Current.CancellationToken);
|
149
|
-
var executableName = Path.Join(Path.GetDirectoryName(GetType().Assembly.Location), "NuGetUpdater.Cli.dll");
|
150
|
-
IEnumerable<string> executableArgs = [
|
151
|
-
executableName,
|
152
|
-
"update",
|
153
|
-
"--job-id",
|
154
|
-
"TEST-JOB-ID",
|
155
|
-
"--job-path",
|
156
|
-
Path.Combine(tempDir.DirectoryPath, "job.json"),
|
157
|
-
"--repo-root",
|
158
|
-
tempDir.DirectoryPath,
|
159
|
-
"--solution-or-project",
|
160
|
-
projectPath,
|
161
|
-
"--dependency",
|
162
|
-
"Some.Package",
|
163
|
-
"--new-version",
|
164
|
-
"13.0.1",
|
165
|
-
"--previous-version",
|
166
|
-
"7.0.1"
|
167
|
-
];
|
168
|
-
|
169
|
-
// verify base run
|
170
|
-
var workingDirectory = tempDir.DirectoryPath;
|
171
|
-
if (workingDirectoryPath is not null)
|
172
|
-
{
|
173
|
-
workingDirectory = Path.Join(workingDirectory, workingDirectoryPath);
|
174
|
-
}
|
175
|
-
|
176
|
-
var (exitCode, output, error) = await ProcessEx.RunDotnetWithoutMSBuildEnvironmentVariablesAsync(executableArgs, workingDirectory, new ExperimentsManager() { InstallDotnetSdks = false });
|
177
|
-
Assert.True(exitCode == 0, $"Error running update on unsupported SDK.\nSTDOUT:\n{output}\nSTDERR:\n{error}");
|
178
|
-
|
179
|
-
// verify project update
|
180
|
-
var updatedProjectContents = await File.ReadAllTextAsync(projectPath, TestContext.Current.CancellationToken);
|
181
|
-
Assert.Contains("13.0.1", updatedProjectContents);
|
182
|
-
|
183
|
-
// verify `global.json` untouched
|
184
|
-
var updatedGlobalJsonContents = await File.ReadAllTextAsync(globalJsonPath, TestContext.Current.CancellationToken);
|
185
|
-
Assert.Contains("99.99.99", updatedGlobalJsonContents);
|
186
|
-
|
187
|
-
// verify `src/global.json` untouched
|
188
|
-
var updatedSrcGlobalJsonContents = await File.ReadAllTextAsync(srcGlobalJsonPath, TestContext.Current.CancellationToken);
|
189
|
-
Assert.Contains("99.99.99", updatedGlobalJsonContents);
|
190
|
-
}
|
191
|
-
|
192
|
-
private static async Task Run(Func<string, string[]> getArgs, (string Path, string Content)[] initialFiles, (string, string)[] expectedFiles, MockNuGetPackage[]? packages = null)
|
193
|
-
{
|
194
|
-
var actualFiles = await RunUpdate(initialFiles, async path =>
|
195
|
-
{
|
196
|
-
var sb = new StringBuilder();
|
197
|
-
var writer = new StringWriter(sb);
|
198
|
-
|
199
|
-
var originalOut = Console.Out;
|
200
|
-
var originalErr = Console.Error;
|
201
|
-
Console.SetOut(writer);
|
202
|
-
Console.SetError(writer);
|
203
|
-
|
204
|
-
try
|
205
|
-
{
|
206
|
-
await MockJobFileInDirectory(path);
|
207
|
-
await MockNuGetPackagesInDirectory(packages, path);
|
208
|
-
|
209
|
-
var args = getArgs(path);
|
210
|
-
var result = await Program.Main(args);
|
211
|
-
if (result != 0)
|
212
|
-
{
|
213
|
-
throw new Exception($"Program exited with code {result}.\nOutput:\n\n{sb}");
|
214
|
-
}
|
215
|
-
}
|
216
|
-
finally
|
217
|
-
{
|
218
|
-
Console.SetOut(originalOut);
|
219
|
-
Console.SetError(originalErr);
|
220
|
-
}
|
221
|
-
});
|
222
|
-
|
223
|
-
AssertContainsFiles(expectedFiles, actualFiles);
|
224
|
-
}
|
225
|
-
}
|
226
|
-
}
|
@@ -1,65 +0,0 @@
|
|
1
|
-
# typed: strong
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
require "dependabot/dependency"
|
5
|
-
require "dependabot/nuget/analysis/dependency_analysis"
|
6
|
-
require "dependabot/nuget/discovery/discovery_json_reader"
|
7
|
-
require "json"
|
8
|
-
require "sorbet-runtime"
|
9
|
-
|
10
|
-
module Dependabot
|
11
|
-
module Nuget
|
12
|
-
class AnalysisJsonReader
|
13
|
-
extend T::Sig
|
14
|
-
|
15
|
-
sig { returns(String) }
|
16
|
-
def self.temp_directory
|
17
|
-
d = File.join(Dir.tmpdir, "analysis")
|
18
|
-
FileUtils.mkdir_p(d)
|
19
|
-
d
|
20
|
-
end
|
21
|
-
|
22
|
-
sig { params(dependency_name: String).returns(String) }
|
23
|
-
def self.analysis_file_path(dependency_name:)
|
24
|
-
File.join(temp_directory, "#{dependency_name}.json")
|
25
|
-
end
|
26
|
-
|
27
|
-
sig { params(dependency_name: String).returns(T.nilable(DependencyFile)) }
|
28
|
-
def self.analysis_json(dependency_name:)
|
29
|
-
file_path = analysis_file_path(dependency_name: dependency_name)
|
30
|
-
return unless File.exist?(file_path)
|
31
|
-
|
32
|
-
DependencyFile.new(
|
33
|
-
name: Pathname.new(file_path).cleanpath.to_path,
|
34
|
-
directory: temp_directory,
|
35
|
-
type: "file",
|
36
|
-
content: File.read(file_path)
|
37
|
-
)
|
38
|
-
end
|
39
|
-
|
40
|
-
sig { params(analysis_json: DependencyFile).void }
|
41
|
-
def initialize(analysis_json:)
|
42
|
-
@analysis_json = analysis_json
|
43
|
-
end
|
44
|
-
|
45
|
-
sig { returns(DependencyAnalysis) }
|
46
|
-
def dependency_analysis
|
47
|
-
@dependency_analysis ||= T.let(begin
|
48
|
-
raise Dependabot::DependencyFileNotParseable, analysis_json.path unless analysis_json.content
|
49
|
-
|
50
|
-
Dependabot.logger.info("#{File.basename(analysis_json.path)} analysis content: #{analysis_json.content}")
|
51
|
-
|
52
|
-
parsed_json = T.let(JSON.parse(T.must(analysis_json.content)), T::Hash[String, T.untyped])
|
53
|
-
DependencyAnalysis.from_json(parsed_json)
|
54
|
-
end, T.nilable(DependencyAnalysis))
|
55
|
-
rescue JSON::ParserError
|
56
|
-
raise Dependabot::DependencyFileNotParseable, analysis_json.path
|
57
|
-
end
|
58
|
-
|
59
|
-
private
|
60
|
-
|
61
|
-
sig { returns(DependencyFile) }
|
62
|
-
attr_reader :analysis_json
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
@@ -1,66 +0,0 @@
|
|
1
|
-
# typed: strong
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
require "dependabot/nuget/version"
|
5
|
-
require "dependabot/nuget/native_helpers"
|
6
|
-
require "sorbet-runtime"
|
7
|
-
|
8
|
-
module Dependabot
|
9
|
-
module Nuget
|
10
|
-
class DependencyAnalysis
|
11
|
-
extend T::Sig
|
12
|
-
|
13
|
-
sig { params(json: T::Hash[String, T.untyped]).returns(DependencyAnalysis) }
|
14
|
-
def self.from_json(json)
|
15
|
-
Dependabot::Nuget::NativeHelpers.ensure_no_errors(json)
|
16
|
-
|
17
|
-
updated_version = T.let(json.fetch("UpdatedVersion"), String)
|
18
|
-
can_update = T.let(json.fetch("CanUpdate"), T::Boolean)
|
19
|
-
version_comes_from_multi_dependency_property = T.let(json.fetch("VersionComesFromMultiDependencyProperty"),
|
20
|
-
T::Boolean)
|
21
|
-
updated_dependencies = T.let(json.fetch("UpdatedDependencies"),
|
22
|
-
T::Array[T::Hash[String, T.untyped]]).map do |dep|
|
23
|
-
DependencyDetails.from_json(dep)
|
24
|
-
end
|
25
|
-
|
26
|
-
DependencyAnalysis.new(
|
27
|
-
updated_version: updated_version,
|
28
|
-
can_update: can_update,
|
29
|
-
version_comes_from_multi_dependency_property: version_comes_from_multi_dependency_property,
|
30
|
-
updated_dependencies: updated_dependencies
|
31
|
-
)
|
32
|
-
end
|
33
|
-
|
34
|
-
sig do
|
35
|
-
params(updated_version: String,
|
36
|
-
can_update: T::Boolean,
|
37
|
-
version_comes_from_multi_dependency_property: T::Boolean,
|
38
|
-
updated_dependencies: T::Array[DependencyDetails]).void
|
39
|
-
end
|
40
|
-
def initialize(updated_version:, can_update:, version_comes_from_multi_dependency_property:,
|
41
|
-
updated_dependencies:)
|
42
|
-
@updated_version = updated_version
|
43
|
-
@can_update = can_update
|
44
|
-
@version_comes_from_multi_dependency_property = version_comes_from_multi_dependency_property
|
45
|
-
@updated_dependencies = updated_dependencies
|
46
|
-
end
|
47
|
-
|
48
|
-
sig { returns(String) }
|
49
|
-
attr_reader :updated_version
|
50
|
-
|
51
|
-
sig { returns(T::Boolean) }
|
52
|
-
attr_reader :can_update
|
53
|
-
|
54
|
-
sig { returns(T::Boolean) }
|
55
|
-
attr_reader :version_comes_from_multi_dependency_property
|
56
|
-
|
57
|
-
sig { returns(T::Array[DependencyDetails]) }
|
58
|
-
attr_reader :updated_dependencies
|
59
|
-
|
60
|
-
sig { returns(Dependabot::Nuget::Version) }
|
61
|
-
def numeric_updated_version
|
62
|
-
@numeric_updated_version ||= T.let(Version.new(updated_version), T.nilable(Dependabot::Nuget::Version))
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
@@ -1,29 +0,0 @@
|
|
1
|
-
# typed: strict
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
require "sorbet-runtime"
|
5
|
-
|
6
|
-
require "dependabot/file_fetchers"
|
7
|
-
require "dependabot/file_fetchers/base"
|
8
|
-
|
9
|
-
module Dependabot
|
10
|
-
module Nuget
|
11
|
-
class CacheManager
|
12
|
-
extend T::Sig
|
13
|
-
|
14
|
-
sig { returns(T::Boolean) }
|
15
|
-
def self.caching_disabled?
|
16
|
-
ENV["DEPENDABOT_NUGET_CACHE_DISABLED"] == "true"
|
17
|
-
end
|
18
|
-
|
19
|
-
sig { params(name: String).returns(T::Hash[String, T.untyped]) }
|
20
|
-
def self.cache(name)
|
21
|
-
return {} if caching_disabled?
|
22
|
-
|
23
|
-
@cache ||= T.let({}, T.nilable(T::Hash[String, T.untyped]))
|
24
|
-
@cache[name] ||= {}
|
25
|
-
@cache[name]
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
@@ -1,102 +0,0 @@
|
|
1
|
-
# typed: strong
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
require "dependabot/nuget/discovery/evaluation_details"
|
5
|
-
require "sorbet-runtime"
|
6
|
-
|
7
|
-
module Dependabot
|
8
|
-
module Nuget
|
9
|
-
class DependencyDetails
|
10
|
-
extend T::Sig
|
11
|
-
|
12
|
-
sig { params(json: T::Hash[String, T.untyped]).returns(DependencyDetails) }
|
13
|
-
def self.from_json(json)
|
14
|
-
name = T.let(json.fetch("Name"), String)
|
15
|
-
version = T.let(json.fetch("Version"), T.nilable(String))
|
16
|
-
type = T.let(json.fetch("Type"), String)
|
17
|
-
evaluation = EvaluationDetails
|
18
|
-
.from_json(T.let(json.fetch("EvaluationResult"), T.nilable(T::Hash[String, T.untyped])))
|
19
|
-
target_frameworks = T.let(json.fetch("TargetFrameworks"), T.nilable(T::Array[String]))
|
20
|
-
is_dev_dependency = T.let(json.fetch("IsDevDependency"), T::Boolean)
|
21
|
-
is_direct = T.let(json.fetch("IsDirect"), T::Boolean)
|
22
|
-
is_transitive = T.let(json.fetch("IsTransitive"), T::Boolean)
|
23
|
-
is_override = T.let(json.fetch("IsOverride"), T::Boolean)
|
24
|
-
is_update = T.let(json.fetch("IsUpdate"), T::Boolean)
|
25
|
-
info_url = T.let(json.fetch("InfoUrl"), T.nilable(String))
|
26
|
-
|
27
|
-
DependencyDetails.new(name: name,
|
28
|
-
version: version,
|
29
|
-
type: type,
|
30
|
-
evaluation: evaluation,
|
31
|
-
target_frameworks: target_frameworks,
|
32
|
-
is_dev_dependency: is_dev_dependency,
|
33
|
-
is_direct: is_direct,
|
34
|
-
is_transitive: is_transitive,
|
35
|
-
is_override: is_override,
|
36
|
-
is_update: is_update,
|
37
|
-
info_url: info_url)
|
38
|
-
end
|
39
|
-
|
40
|
-
sig do
|
41
|
-
params(name: String,
|
42
|
-
version: T.nilable(String),
|
43
|
-
type: String,
|
44
|
-
evaluation: T.nilable(EvaluationDetails),
|
45
|
-
target_frameworks: T.nilable(T::Array[String]),
|
46
|
-
is_dev_dependency: T::Boolean,
|
47
|
-
is_direct: T::Boolean,
|
48
|
-
is_transitive: T::Boolean,
|
49
|
-
is_override: T::Boolean,
|
50
|
-
is_update: T::Boolean,
|
51
|
-
info_url: T.nilable(String)).void
|
52
|
-
end
|
53
|
-
def initialize(name:, version:, type:, evaluation:, target_frameworks:, is_dev_dependency:, is_direct:,
|
54
|
-
is_transitive:, is_override:, is_update:, info_url:)
|
55
|
-
@name = name
|
56
|
-
@version = version
|
57
|
-
@type = type
|
58
|
-
@evaluation = evaluation
|
59
|
-
@target_frameworks = target_frameworks
|
60
|
-
@is_dev_dependency = is_dev_dependency
|
61
|
-
@is_direct = is_direct
|
62
|
-
@is_transitive = is_transitive
|
63
|
-
@is_override = is_override
|
64
|
-
@is_update = is_update
|
65
|
-
@info_url = info_url
|
66
|
-
end
|
67
|
-
|
68
|
-
sig { returns(String) }
|
69
|
-
attr_reader :name
|
70
|
-
|
71
|
-
sig { returns(T.nilable(String)) }
|
72
|
-
attr_reader :version
|
73
|
-
|
74
|
-
sig { returns(String) }
|
75
|
-
attr_reader :type
|
76
|
-
|
77
|
-
sig { returns(T.nilable(EvaluationDetails)) }
|
78
|
-
attr_reader :evaluation
|
79
|
-
|
80
|
-
sig { returns(T.nilable(T::Array[String])) }
|
81
|
-
attr_reader :target_frameworks
|
82
|
-
|
83
|
-
sig { returns(T::Boolean) }
|
84
|
-
attr_reader :is_dev_dependency
|
85
|
-
|
86
|
-
sig { returns(T::Boolean) }
|
87
|
-
attr_reader :is_direct
|
88
|
-
|
89
|
-
sig { returns(T::Boolean) }
|
90
|
-
attr_reader :is_transitive
|
91
|
-
|
92
|
-
sig { returns(T::Boolean) }
|
93
|
-
attr_reader :is_override
|
94
|
-
|
95
|
-
sig { returns(T::Boolean) }
|
96
|
-
attr_reader :is_update
|
97
|
-
|
98
|
-
sig { returns(T.nilable(String)) }
|
99
|
-
attr_reader :info_url
|
100
|
-
end
|
101
|
-
end
|
102
|
-
end
|
@@ -1,122 +0,0 @@
|
|
1
|
-
# typed: strong
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
require "dependabot/nuget/discovery/dependency_details"
|
5
|
-
require "sorbet-runtime"
|
6
|
-
|
7
|
-
module Dependabot
|
8
|
-
module Nuget
|
9
|
-
class DependencyFileDiscovery
|
10
|
-
extend T::Sig
|
11
|
-
|
12
|
-
sig do
|
13
|
-
params(json: T.nilable(T::Hash[String, T.untyped]),
|
14
|
-
directory: String).returns(T.nilable(DependencyFileDiscovery))
|
15
|
-
end
|
16
|
-
def self.from_json(json, directory)
|
17
|
-
return nil if json.nil?
|
18
|
-
|
19
|
-
file_path = File.join(directory, T.let(json.fetch("FilePath"), String))
|
20
|
-
dependencies = T.let(json.fetch("Dependencies"), T::Array[T::Hash[String, T.untyped]]).map do |dep|
|
21
|
-
DependencyDetails.from_json(dep)
|
22
|
-
end
|
23
|
-
|
24
|
-
DependencyFileDiscovery.new(file_path: file_path,
|
25
|
-
dependencies: dependencies)
|
26
|
-
end
|
27
|
-
|
28
|
-
sig do
|
29
|
-
params(file_path: String,
|
30
|
-
dependencies: T::Array[DependencyDetails]).void
|
31
|
-
end
|
32
|
-
def initialize(file_path:, dependencies:)
|
33
|
-
@file_path = file_path
|
34
|
-
@dependencies = dependencies
|
35
|
-
end
|
36
|
-
|
37
|
-
sig { returns(String) }
|
38
|
-
attr_reader :file_path
|
39
|
-
|
40
|
-
sig { returns(T::Array[DependencyDetails]) }
|
41
|
-
attr_reader :dependencies
|
42
|
-
|
43
|
-
sig { overridable.returns(Dependabot::FileParsers::Base::DependencySet) }
|
44
|
-
def dependency_set # rubocop:disable Metrics/PerceivedComplexity
|
45
|
-
dependency_set = Dependabot::FileParsers::Base::DependencySet.new
|
46
|
-
|
47
|
-
file_name = Pathname.new(file_path).cleanpath.to_path
|
48
|
-
dependencies.each do |dependency|
|
49
|
-
next if dependency.name.casecmp("Microsoft.NET.Sdk")&.zero?
|
50
|
-
|
51
|
-
# If the version string was evaluated it must have been successfully resolved
|
52
|
-
if dependency.evaluation && dependency.evaluation&.result_type != "Success"
|
53
|
-
logger.warn "Dependency '#{dependency.name}' excluded due to unparsable version: #{dependency.version}"
|
54
|
-
next
|
55
|
-
end
|
56
|
-
|
57
|
-
# Exclude any dependencies using version ranges or wildcards
|
58
|
-
next if dependency.version&.include?(",") ||
|
59
|
-
dependency.version&.include?("*")
|
60
|
-
|
61
|
-
# Exclude any dependencies specified using interpolation
|
62
|
-
next if dependency.name.include?("%(") ||
|
63
|
-
dependency.version&.include?("%(")
|
64
|
-
|
65
|
-
# Exclude any dependencies which reference an item type
|
66
|
-
next if dependency.name.include?("@(")
|
67
|
-
|
68
|
-
dependency_set << build_dependency(file_name, dependency)
|
69
|
-
end
|
70
|
-
|
71
|
-
dependency_set
|
72
|
-
end
|
73
|
-
|
74
|
-
private
|
75
|
-
|
76
|
-
sig { returns(::Logger) }
|
77
|
-
def logger
|
78
|
-
Dependabot.logger
|
79
|
-
end
|
80
|
-
|
81
|
-
sig { params(file_name: String, dependency_details: DependencyDetails).returns(Dependabot::Dependency) }
|
82
|
-
def build_dependency(file_name, dependency_details)
|
83
|
-
requirement = build_requirement(file_name, dependency_details)
|
84
|
-
requirements = requirement.nil? ? [] : [requirement]
|
85
|
-
|
86
|
-
version = dependency_details.version&.gsub(/[\(\)\[\]]/, "")&.strip
|
87
|
-
version = nil if version&.empty?
|
88
|
-
|
89
|
-
Dependency.new(
|
90
|
-
name: dependency_details.name,
|
91
|
-
version: version,
|
92
|
-
package_manager: "nuget",
|
93
|
-
requirements: requirements
|
94
|
-
)
|
95
|
-
end
|
96
|
-
|
97
|
-
sig do
|
98
|
-
params(file_name: String, dependency_details: DependencyDetails)
|
99
|
-
.returns(T.nilable(T::Hash[Symbol, T.untyped]))
|
100
|
-
end
|
101
|
-
def build_requirement(file_name, dependency_details)
|
102
|
-
return if dependency_details.is_transitive
|
103
|
-
|
104
|
-
version = dependency_details.version
|
105
|
-
version = nil if version&.empty?
|
106
|
-
|
107
|
-
requirement = {
|
108
|
-
requirement: version,
|
109
|
-
file: file_name,
|
110
|
-
groups: [dependency_details.is_dev_dependency ? "devDependencies" : "dependencies"],
|
111
|
-
source: nil
|
112
|
-
}
|
113
|
-
|
114
|
-
property_name = dependency_details.evaluation&.root_property_name
|
115
|
-
return requirement unless property_name
|
116
|
-
|
117
|
-
requirement[:metadata] = { property_name: property_name }
|
118
|
-
requirement
|
119
|
-
end
|
120
|
-
end
|
121
|
-
end
|
122
|
-
end
|