dependabot-nuget 0.288.0 → 0.289.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/helpers/lib/NuGetUpdater/Directory.Packages.props +19 -17
- data/helpers/lib/NuGetUpdater/NuGetProjects/NuGet.Packaging/NuGet.Packaging.csproj +0 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli.Test/EntryPointTests.Analyze.cs +3 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli.Test/EntryPointTests.Discover.cs +23 -3
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Analyze/AnalyzeWorker.cs +30 -15
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Analyze/CompatabilityChecker.cs +1 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Analyze/RequirementArrayConverter.cs +39 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Analyze/VersionFinder.cs +1 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Clone/ShellGitCommandHandler.cs +1 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/DiscoveryWorker.cs +60 -66
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/DotNetToolsJsonDiscovery.cs +2 -2
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/GlobalJsonDiscovery.cs +2 -2
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/PackagesConfigDiscovery.cs +11 -3
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/PackagesConfigDiscoveryResult.cs +1 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/ProjectDiscoveryResult.cs +2 -4
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/SdkProjectDiscovery.cs +54 -11
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/WorkspaceDiscoveryResult.cs +0 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/ExperimentsManager.cs +1 -2
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Files/JsonBuildFile.cs +1 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/FrameworkChecker/CompatabilityChecker.cs +2 -2
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Run/RunWorker.cs +43 -54
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/BindingRedirectManager.cs +13 -43
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/DotNetToolsJsonUpdater.cs +4 -4
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/GlobalJsonUpdater.cs +5 -5
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/LockFileUpdater.cs +2 -10
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/PackageReferenceUpdater.cs +38 -33
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/PackagesConfigUpdater.cs +12 -11
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/UpdaterWorker.cs +16 -12
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/ConsoleLogger.cs +1 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/DependencyConflictResolver.cs +19 -19
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/ILogger.cs +11 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/MSBuildHelper.cs +18 -17
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/NuGetHelper.cs +1 -17
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/PathHelper.cs +17 -9
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/ProjectHelper.cs +96 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Analyze/AnalyzeWorkerTests.cs +87 -5
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTestBase.cs +2 -5
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTests.PackagesConfig.cs +16 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTests.Proj.cs +6 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTests.Project.cs +147 -36
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTests.cs +184 -48
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/ExpectedDiscoveryResults.cs +5 -5
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/SdkProjectDiscoveryTests.cs +32 -10
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/RunWorkerTests.cs +400 -76
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/SerializationTests.cs +2 -2
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Run/UpdatedDependencyListTests.cs +60 -2
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/TestLogger.cs +1 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/BindingRedirectsTests.cs +1 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTestBase.cs +4 -2
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.PackageReference.cs +40 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.PackagesConfig.cs +1 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Utilities/AssertEx.cs +1 -1
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Utilities/LinuxOnlyAttribute.cs +12 -0
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Utilities/MSBuildHelperTests.cs +8 -5
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Utilities/PathHelperTests.cs +47 -2
- data/lib/dependabot/nuget/analysis/analysis_json_reader.rb +3 -1
- data/lib/dependabot/nuget/file_fetcher.rb +12 -393
- data/lib/dependabot/nuget/file_parser.rb +23 -60
- data/lib/dependabot/nuget/file_updater.rb +21 -16
- data/lib/dependabot/nuget/native_discovery/native_dependency_file_discovery.rb +2 -9
- data/lib/dependabot/nuget/native_discovery/native_discovery_json_reader.rb +183 -77
- data/lib/dependabot/nuget/native_discovery/native_project_discovery.rb +25 -3
- data/lib/dependabot/nuget/native_discovery/native_workspace_discovery.rb +1 -8
- data/lib/dependabot/nuget/native_update_checker/native_update_checker.rb +17 -4
- metadata +8 -9
- data/helpers/lib/NuGetUpdater/NuGetProjects/Directory.Packages.props +0 -29
- data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Analyze/RequirementConverter.cs +0 -17
- data/lib/dependabot/nuget/file_fetcher/import_paths_finder.rb +0 -73
- data/lib/dependabot/nuget/file_fetcher/sln_project_paths_finder.rb +0 -60
@@ -2,6 +2,8 @@
|
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
4
|
require "dependabot/dependency"
|
5
|
+
require "dependabot/file_parsers/base/dependency_set"
|
6
|
+
require "dependabot/nuget/cache_manager"
|
5
7
|
require "dependabot/nuget/native_discovery/native_workspace_discovery"
|
6
8
|
require "json"
|
7
9
|
require "sorbet-runtime"
|
@@ -12,114 +14,169 @@ module Dependabot
|
|
12
14
|
extend T::Sig
|
13
15
|
|
14
16
|
sig { returns(T::Hash[String, NativeDiscoveryJsonReader]) }
|
15
|
-
def self.
|
16
|
-
|
17
|
+
def self.cache_directory_to_discovery_json_reader
|
18
|
+
CacheManager.cache("cache_directory_to_discovery_json_reader")
|
17
19
|
end
|
18
20
|
|
19
|
-
sig { returns(T::Hash[String,
|
20
|
-
def self.
|
21
|
-
|
21
|
+
sig { returns(T::Hash[String, NativeDiscoveryJsonReader]) }
|
22
|
+
def self.cache_dependency_file_paths_to_discovery_json_reader
|
23
|
+
CacheManager.cache("cache_dependency_file_paths_to_discovery_json_reader")
|
22
24
|
end
|
23
25
|
|
24
|
-
sig
|
25
|
-
|
26
|
-
|
27
|
-
).returns(NativeDiscoveryJsonReader)
|
26
|
+
sig { returns(T::Hash[String, String]) }
|
27
|
+
def self.cache_dependency_file_paths_to_discovery_json_path
|
28
|
+
CacheManager.cache("cache_dependency_file_paths_to_discovery_json_path")
|
28
29
|
end
|
29
|
-
def self.get_discovery_from_dependency_files(dependency_files)
|
30
|
-
key = create_cache_key(dependency_files)
|
31
|
-
discovery_json = discovery_result_cache[key]
|
32
|
-
raise "No discovery result for specified dependency files: #{key}" unless discovery_json
|
33
30
|
|
34
|
-
|
31
|
+
sig { void }
|
32
|
+
def self.testonly_clear_caches
|
33
|
+
cache_directory_to_discovery_json_reader.clear
|
34
|
+
cache_dependency_file_paths_to_discovery_json_reader.clear
|
35
|
+
cache_dependency_file_paths_to_discovery_json_path.clear
|
35
36
|
end
|
36
37
|
|
37
|
-
sig
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
).void
|
38
|
+
sig { void }
|
39
|
+
def self.testonly_clear_discovery_files
|
40
|
+
# this will get recreated when necessary
|
41
|
+
FileUtils.rm_rf(discovery_directory)
|
42
42
|
end
|
43
|
-
|
44
|
-
|
45
|
-
|
43
|
+
|
44
|
+
sig { params(error_if_missing: T::Boolean).void }
|
45
|
+
def self.debug_report_discovery_files(error_if_missing:)
|
46
|
+
if File.exist?(discovery_map_file_path)
|
47
|
+
Dependabot.logger.info("Discovery map file (#{discovery_map_file_path}) contents: " \
|
48
|
+
"#{File.read(discovery_map_file_path)}")
|
49
|
+
Dependabot.logger.info("Discovery files: #{Dir.glob(File.join(discovery_directory, '*'))}")
|
50
|
+
elsif error_if_missing
|
51
|
+
Dependabot.logger.error("discovery map file missing")
|
52
|
+
end
|
46
53
|
end
|
47
54
|
|
55
|
+
# Runs NuGet dependency discovery in the given directory and returns a new instance of NativeDiscoveryJsonReader.
|
56
|
+
# The location of the resultant JSON file is saved.
|
48
57
|
sig do
|
49
58
|
params(
|
50
|
-
|
51
|
-
|
59
|
+
repo_contents_path: String,
|
60
|
+
directory: String,
|
61
|
+
credentials: T::Array[Dependabot::Credential]
|
62
|
+
).returns(NativeDiscoveryJsonReader)
|
52
63
|
end
|
53
|
-
def self.
|
54
|
-
|
55
|
-
|
56
|
-
|
64
|
+
def self.run_discovery_in_directory(repo_contents_path:, directory:, credentials:)
|
65
|
+
# run discovery
|
66
|
+
job_file_path = ENV.fetch("DEPENDABOT_JOB_PATH")
|
67
|
+
discovery_json_path = discovery_file_path_from_workspace_path(directory)
|
68
|
+
unless File.exist?(discovery_json_path)
|
69
|
+
NativeHelpers.run_nuget_discover_tool(job_path: job_file_path,
|
70
|
+
repo_root: repo_contents_path,
|
71
|
+
workspace_path: directory,
|
72
|
+
output_path: discovery_json_path,
|
73
|
+
credentials: credentials)
|
57
74
|
|
58
|
-
|
75
|
+
Dependabot.logger.info("Discovery JSON content: #{File.read(discovery_json_path)}")
|
76
|
+
end
|
77
|
+
load_discovery_for_directory(repo_contents_path: repo_contents_path, directory: directory)
|
59
78
|
end
|
60
79
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
80
|
+
# Loads NuGet dependency discovery for the given directory and returns a new instance of
|
81
|
+
# NativeDiscoveryJsonReader and caches the resultant object.
|
82
|
+
sig { params(repo_contents_path: String, directory: String).returns(NativeDiscoveryJsonReader) }
|
83
|
+
def self.load_discovery_for_directory(repo_contents_path:, directory:)
|
84
|
+
cache_directory_to_discovery_json_reader[directory] ||= begin
|
85
|
+
discovery_json_reader = discovery_json_reader(repo_contents_path: repo_contents_path,
|
86
|
+
workspace_path: directory)
|
87
|
+
cache_directory_to_discovery_json_reader[directory] = discovery_json_reader
|
88
|
+
dependency_file_cache_key = cache_key_from_dependency_file_paths(discovery_json_reader.dependency_file_paths)
|
89
|
+
cache_dependency_file_paths_to_discovery_json_reader[dependency_file_cache_key] = discovery_json_reader
|
90
|
+
discovery_file_path = discovery_file_path_from_workspace_path(directory)
|
91
|
+
cache_dependency_file_paths_to_discovery_json_path[dependency_file_cache_key] = discovery_file_path
|
92
|
+
|
93
|
+
discovery_json_reader
|
70
94
|
end
|
95
|
+
end
|
71
96
|
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
incremeted_discovery_file_path = File.join(temp_directory, "discovery.#{current_counter}.json")
|
78
|
-
discovery_path_cache[discovery_key] = incremeted_discovery_file_path
|
79
|
-
incremeted_discovery_file_path
|
97
|
+
# Retrieves the cached NativeDiscoveryJsonReader object for the given dependency file paths.
|
98
|
+
sig { params(dependency_file_paths: T::Array[String]).returns(NativeDiscoveryJsonReader) }
|
99
|
+
def self.load_discovery_for_dependency_file_paths(dependency_file_paths)
|
100
|
+
dependency_file_cache_key = cache_key_from_dependency_file_paths(dependency_file_paths)
|
101
|
+
T.must(cache_dependency_file_paths_to_discovery_json_reader[dependency_file_cache_key])
|
80
102
|
end
|
81
103
|
|
82
|
-
#
|
83
|
-
sig
|
84
|
-
|
85
|
-
|
86
|
-
)
|
104
|
+
# Retrieves the cached location of the discovery JSON file for the given dependency file paths.
|
105
|
+
sig { params(dependency_file_paths: T::Array[String]).returns(String) }
|
106
|
+
def self.get_discovery_json_path_for_dependency_file_paths(dependency_file_paths)
|
107
|
+
dependency_file_cache_key = cache_key_from_dependency_file_paths(dependency_file_paths)
|
108
|
+
T.must(cache_dependency_file_paths_to_discovery_json_path[dependency_file_cache_key])
|
87
109
|
end
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
File.
|
92
|
-
|
110
|
+
|
111
|
+
sig { params(repo_contents_path: String, dependency_file: Dependabot::DependencyFile).returns(String) }
|
112
|
+
def self.dependency_file_path(repo_contents_path:, dependency_file:)
|
113
|
+
dep_file_path = Pathname.new(File.join(dependency_file.directory, dependency_file.name)).cleanpath.to_path
|
114
|
+
dep_file_path.delete_prefix("#{repo_contents_path}/")
|
93
115
|
end
|
94
116
|
|
95
|
-
sig
|
96
|
-
|
97
|
-
|
98
|
-
).returns(String)
|
117
|
+
sig { returns(String) }
|
118
|
+
def self.discovery_map_file_path
|
119
|
+
File.join(discovery_directory, "discovery_map.json")
|
99
120
|
end
|
100
|
-
|
101
|
-
|
121
|
+
|
122
|
+
sig { params(workspace_path: String).returns(String) }
|
123
|
+
def self.discovery_file_path_from_workspace_path(workspace_path)
|
124
|
+
# Given an update directory (also known as a workspace path), this function returns the path where the discovery
|
125
|
+
# JSON file is located. This function is called both by methods that need to write the discovery JSON file and
|
126
|
+
# by methods that need to read the discovery JSON file. This function is also called by multiple processes so
|
127
|
+
# we need a way to retain the data. This is accomplished by the following steps:
|
128
|
+
# 1. Check a well-known file for a mapping of workspace_path => discovery file path. If found, return it.
|
129
|
+
# 2. If the path is not found, generate a new path, save it to the well-known file, and return the value.
|
130
|
+
discovery_map_contents = File.exist?(discovery_map_file_path) ? File.read(discovery_map_file_path) : "{}"
|
131
|
+
discovery_map = T.let(JSON.parse(discovery_map_contents), T::Hash[String, String])
|
132
|
+
|
133
|
+
discovery_json_path = discovery_map[workspace_path]
|
134
|
+
if discovery_json_path
|
135
|
+
Dependabot.logger.info("Discovery JSON path for workspace path [#{workspace_path}] found in file " \
|
136
|
+
"[#{discovery_map_file_path}] at location [#{discovery_json_path}]")
|
137
|
+
return discovery_json_path
|
138
|
+
end
|
139
|
+
|
140
|
+
# no discovery JSON path found; generate a new one, but first find a suitable location
|
141
|
+
discovery_json_counter = 1
|
142
|
+
new_discovery_json_path = ""
|
143
|
+
loop do
|
144
|
+
new_discovery_json_path = File.join(discovery_directory, "discovery.#{discovery_json_counter}.json")
|
145
|
+
break unless File.exist?(new_discovery_json_path)
|
146
|
+
|
147
|
+
discovery_json_counter += 1
|
148
|
+
end
|
149
|
+
|
150
|
+
discovery_map[workspace_path] = new_discovery_json_path
|
151
|
+
|
152
|
+
File.write(discovery_map_file_path, discovery_map.to_json)
|
153
|
+
Dependabot.logger.info("Discovery JSON path for workspace path [#{workspace_path}] created for file " \
|
154
|
+
"[#{discovery_map_file_path}] at location [#{new_discovery_json_path}]")
|
155
|
+
new_discovery_json_path
|
102
156
|
end
|
103
157
|
|
104
|
-
sig { returns(String) }
|
105
|
-
def self.
|
106
|
-
|
158
|
+
sig { params(dependency_file_paths: T::Array[String]).returns(String) }
|
159
|
+
def self.cache_key_from_dependency_file_paths(dependency_file_paths)
|
160
|
+
dependency_file_paths.sort.join(",")
|
107
161
|
end
|
108
162
|
|
109
|
-
sig
|
110
|
-
|
111
|
-
|
112
|
-
|
163
|
+
sig { returns(String) }
|
164
|
+
def self.discovery_directory
|
165
|
+
t = File.join(Dir.home, ".dependabot")
|
166
|
+
FileUtils.mkdir_p(t)
|
167
|
+
t
|
113
168
|
end
|
114
|
-
def self.discovery_json_from_path(discovery_json_path)
|
115
|
-
return unless File.exist?(discovery_json_path)
|
116
169
|
|
117
|
-
|
118
|
-
|
119
|
-
|
170
|
+
sig { params(repo_contents_path: String, workspace_path: String).returns(NativeDiscoveryJsonReader) }
|
171
|
+
def self.discovery_json_reader(repo_contents_path:, workspace_path:)
|
172
|
+
discovery_file_path = discovery_file_path_from_workspace_path(workspace_path)
|
173
|
+
discovery_json = DependencyFile.new(
|
174
|
+
name: Pathname.new(discovery_file_path).cleanpath.to_path,
|
175
|
+
directory: discovery_directory,
|
120
176
|
type: "file",
|
121
|
-
content: File.read(
|
177
|
+
content: File.read(discovery_file_path)
|
122
178
|
)
|
179
|
+
NativeDiscoveryJsonReader.new(repo_contents_path: repo_contents_path, discovery_json: discovery_json)
|
123
180
|
end
|
124
181
|
|
125
182
|
sig { returns(T.nilable(NativeWorkspaceDiscovery)) }
|
@@ -128,15 +185,23 @@ module Dependabot
|
|
128
185
|
sig { returns(Dependabot::FileParsers::Base::DependencySet) }
|
129
186
|
attr_reader :dependency_set
|
130
187
|
|
131
|
-
sig {
|
132
|
-
|
188
|
+
sig { returns(T::Array[String]) }
|
189
|
+
attr_reader :dependency_file_paths
|
190
|
+
|
191
|
+
sig { params(repo_contents_path: String, discovery_json: DependencyFile).void }
|
192
|
+
def initialize(repo_contents_path:, discovery_json:)
|
193
|
+
@repo_contents_path = repo_contents_path
|
133
194
|
@discovery_json = discovery_json
|
134
195
|
@workspace_discovery = T.let(read_workspace_discovery, T.nilable(Dependabot::Nuget::NativeWorkspaceDiscovery))
|
135
196
|
@dependency_set = T.let(read_dependency_set, Dependabot::FileParsers::Base::DependencySet)
|
197
|
+
@dependency_file_paths = T.let(read_dependency_file_paths, T::Array[String])
|
136
198
|
end
|
137
199
|
|
138
200
|
private
|
139
201
|
|
202
|
+
sig { returns(String) }
|
203
|
+
attr_reader :repo_contents_path
|
204
|
+
|
140
205
|
sig { returns(DependencyFile) }
|
141
206
|
attr_reader :discovery_json
|
142
207
|
|
@@ -166,6 +231,47 @@ module Dependabot
|
|
166
231
|
|
167
232
|
dependency_set
|
168
233
|
end
|
234
|
+
|
235
|
+
sig { returns(T::Array[String]) }
|
236
|
+
def read_dependency_file_paths
|
237
|
+
dependency_file_paths = T.let([], T::Array[T.nilable(String)])
|
238
|
+
dependency_file_paths << dependency_file_path_from_repo_path("global.json") if workspace_discovery&.global_json
|
239
|
+
if workspace_discovery&.dotnet_tools_json
|
240
|
+
dependency_file_paths << dependency_file_path_from_repo_path(".config/dotnet-tools.json")
|
241
|
+
end
|
242
|
+
|
243
|
+
projects = workspace_discovery&.projects || []
|
244
|
+
projects.each do |project|
|
245
|
+
dependency_file_paths << dependency_file_path_from_repo_path(project.file_path)
|
246
|
+
dependency_file_paths += project.imported_files.map do |f|
|
247
|
+
dependency_file_path_from_project_path(project.file_path, f)
|
248
|
+
end
|
249
|
+
dependency_file_paths += project.additional_files.map do |f|
|
250
|
+
dependency_file_path_from_project_path(project.file_path, f)
|
251
|
+
end
|
252
|
+
end
|
253
|
+
|
254
|
+
deduped_dependency_file_paths = T.let(Set.new(dependency_file_paths.compact), T::Set[String])
|
255
|
+
result = deduped_dependency_file_paths.sort
|
256
|
+
result
|
257
|
+
end
|
258
|
+
|
259
|
+
sig { params(path_parts: String).returns(T.nilable(String)) }
|
260
|
+
def dependency_file_path_from_repo_path(*path_parts)
|
261
|
+
path_parts = path_parts.map { |p| p.delete_prefix("/").delete_suffix("/") }
|
262
|
+
normalized_repo_path = Pathname.new(path_parts.join("/")).cleanpath.to_path.delete_prefix("/")
|
263
|
+
full_path = Pathname.new(File.join(repo_contents_path, normalized_repo_path)).cleanpath.to_path
|
264
|
+
return unless File.exist?(full_path)
|
265
|
+
|
266
|
+
normalized_repo_path = "/#{normalized_repo_path}" unless normalized_repo_path.start_with?("/")
|
267
|
+
normalized_repo_path
|
268
|
+
end
|
269
|
+
|
270
|
+
sig { params(project_path: String, relative_file_path: String).returns(T.nilable(String)) }
|
271
|
+
def dependency_file_path_from_project_path(project_path, relative_file_path)
|
272
|
+
project_directory = File.dirname(project_path)
|
273
|
+
dependency_file_path_from_repo_path(project_directory, relative_file_path)
|
274
|
+
end
|
169
275
|
end
|
170
276
|
end
|
171
277
|
end
|
@@ -10,6 +10,7 @@ module Dependabot
|
|
10
10
|
class NativeProjectDiscovery < NativeDependencyFileDiscovery
|
11
11
|
extend T::Sig
|
12
12
|
|
13
|
+
# rubocop:disable Metrics/AbcSize
|
13
14
|
sig do
|
14
15
|
override.params(json: T.nilable(T::Hash[String, T.untyped]),
|
15
16
|
directory: String).returns(T.nilable(NativeProjectDiscovery))
|
@@ -36,26 +37,41 @@ module Dependabot
|
|
36
37
|
|
37
38
|
details
|
38
39
|
end
|
40
|
+
imported_files = T.let(json.fetch("ImportedFiles"), T::Array[String])
|
41
|
+
additional_files = T.let(json.fetch("AdditionalFiles"), T::Array[String])
|
39
42
|
|
40
43
|
NativeProjectDiscovery.new(file_path: file_path,
|
41
44
|
properties: properties,
|
42
45
|
target_frameworks: target_frameworks,
|
43
46
|
referenced_project_paths: referenced_project_paths,
|
44
|
-
dependencies: dependencies
|
47
|
+
dependencies: dependencies,
|
48
|
+
imported_files: imported_files,
|
49
|
+
additional_files: additional_files)
|
45
50
|
end
|
51
|
+
# rubocop:enable Metrics/AbcSize
|
46
52
|
|
47
53
|
sig do
|
48
54
|
params(file_path: String,
|
49
55
|
properties: T::Array[NativePropertyDetails],
|
50
56
|
target_frameworks: T::Array[String],
|
51
57
|
referenced_project_paths: T::Array[String],
|
52
|
-
dependencies: T::Array[NativeDependencyDetails]
|
58
|
+
dependencies: T::Array[NativeDependencyDetails],
|
59
|
+
imported_files: T::Array[String],
|
60
|
+
additional_files: T::Array[String]).void
|
53
61
|
end
|
54
|
-
def initialize(file_path:,
|
62
|
+
def initialize(file_path:,
|
63
|
+
properties:,
|
64
|
+
target_frameworks:,
|
65
|
+
referenced_project_paths:,
|
66
|
+
dependencies:,
|
67
|
+
imported_files:,
|
68
|
+
additional_files:)
|
55
69
|
super(file_path: file_path, dependencies: dependencies)
|
56
70
|
@properties = properties
|
57
71
|
@target_frameworks = target_frameworks
|
58
72
|
@referenced_project_paths = referenced_project_paths
|
73
|
+
@imported_files = imported_files
|
74
|
+
@additional_files = additional_files
|
59
75
|
end
|
60
76
|
|
61
77
|
sig { returns(T::Array[NativePropertyDetails]) }
|
@@ -67,6 +83,12 @@ module Dependabot
|
|
67
83
|
sig { returns(T::Array[String]) }
|
68
84
|
attr_reader :referenced_project_paths
|
69
85
|
|
86
|
+
sig { returns(T::Array[String]) }
|
87
|
+
attr_reader :imported_files
|
88
|
+
|
89
|
+
sig { returns(T::Array[String]) }
|
90
|
+
attr_reader :additional_files
|
91
|
+
|
70
92
|
sig { override.returns(Dependabot::FileParsers::Base::DependencySet) }
|
71
93
|
def dependency_set
|
72
94
|
if target_frameworks.empty? && file_path.end_with?("proj")
|
@@ -20,7 +20,6 @@ module Dependabot
|
|
20
20
|
projects = T.let(json.fetch("Projects"), T::Array[T::Hash[String, T.untyped]]).filter_map do |project|
|
21
21
|
NativeProjectDiscovery.from_json(project, path)
|
22
22
|
end
|
23
|
-
imported_files = T.let(json.fetch("ImportedFiles"), T::Array[String])
|
24
23
|
global_json = NativeDependencyFileDiscovery
|
25
24
|
.from_json(T.let(json.fetch("GlobalJson"), T.nilable(T::Hash[String, T.untyped])), path)
|
26
25
|
dotnet_tools_json = NativeDependencyFileDiscovery
|
@@ -29,7 +28,6 @@ module Dependabot
|
|
29
28
|
|
30
29
|
NativeWorkspaceDiscovery.new(path: path,
|
31
30
|
projects: projects,
|
32
|
-
imported_files: imported_files,
|
33
31
|
global_json: global_json,
|
34
32
|
dotnet_tools_json: dotnet_tools_json)
|
35
33
|
end
|
@@ -37,14 +35,12 @@ module Dependabot
|
|
37
35
|
sig do
|
38
36
|
params(path: String,
|
39
37
|
projects: T::Array[NativeProjectDiscovery],
|
40
|
-
imported_files: T::Array[String],
|
41
38
|
global_json: T.nilable(NativeDependencyFileDiscovery),
|
42
39
|
dotnet_tools_json: T.nilable(NativeDependencyFileDiscovery)).void
|
43
40
|
end
|
44
|
-
def initialize(path:, projects:,
|
41
|
+
def initialize(path:, projects:, global_json:, dotnet_tools_json:)
|
45
42
|
@path = path
|
46
43
|
@projects = projects
|
47
|
-
@imported_files = imported_files
|
48
44
|
@global_json = global_json
|
49
45
|
@dotnet_tools_json = dotnet_tools_json
|
50
46
|
end
|
@@ -55,9 +51,6 @@ module Dependabot
|
|
55
51
|
sig { returns(T::Array[NativeProjectDiscovery]) }
|
56
52
|
attr_reader :projects
|
57
53
|
|
58
|
-
sig { returns(T::Array[String]) }
|
59
|
-
attr_reader :imported_files
|
60
|
-
|
61
54
|
sig { returns(T.nilable(NativeDependencyFileDiscovery)) }
|
62
55
|
attr_reader :global_json
|
63
56
|
|
@@ -89,12 +89,26 @@ module Dependabot
|
|
89
89
|
|
90
90
|
sig { returns(String) }
|
91
91
|
def dependency_file_path
|
92
|
-
File.join(
|
92
|
+
d = File.join(Dir.tmpdir, "dependency")
|
93
|
+
FileUtils.mkdir_p(d)
|
94
|
+
File.join(d, "#{dependency.name}.json")
|
95
|
+
end
|
96
|
+
|
97
|
+
sig { returns(T::Array[String]) }
|
98
|
+
def dependency_file_paths
|
99
|
+
dependency_files.map do |file|
|
100
|
+
NativeDiscoveryJsonReader.dependency_file_path(
|
101
|
+
repo_contents_path: T.must(repo_contents_path),
|
102
|
+
dependency_file: file
|
103
|
+
)
|
104
|
+
end
|
93
105
|
end
|
94
106
|
|
95
107
|
sig { returns(AnalysisJsonReader) }
|
96
108
|
def request_analysis
|
97
|
-
discovery_file_path = NativeDiscoveryJsonReader.
|
109
|
+
discovery_file_path = NativeDiscoveryJsonReader.get_discovery_json_path_for_dependency_file_paths(
|
110
|
+
dependency_file_paths
|
111
|
+
)
|
98
112
|
analysis_folder_path = AnalysisJsonReader.temp_directory
|
99
113
|
|
100
114
|
write_dependency_info
|
@@ -140,8 +154,7 @@ module Dependabot
|
|
140
154
|
|
141
155
|
sig { returns(Dependabot::FileParsers::Base::DependencySet) }
|
142
156
|
def discovered_dependencies
|
143
|
-
|
144
|
-
discovery_json_reader.dependency_set
|
157
|
+
NativeDiscoveryJsonReader.load_discovery_for_dependency_file_paths(dependency_file_paths).dependency_set
|
145
158
|
end
|
146
159
|
|
147
160
|
sig { override.returns(T::Boolean) }
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dependabot-nuget
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.289.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dependabot
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-12-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dependabot-common
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - '='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.
|
19
|
+
version: 0.289.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - '='
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.
|
26
|
+
version: 0.289.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rubyzip
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -271,7 +271,6 @@ files:
|
|
271
271
|
- helpers/lib/NuGetUpdater/Directory.Packages.props
|
272
272
|
- helpers/lib/NuGetUpdater/NuGetProjects/Directory.Build.props
|
273
273
|
- helpers/lib/NuGetUpdater/NuGetProjects/Directory.Build.targets
|
274
|
-
- helpers/lib/NuGetUpdater/NuGetProjects/Directory.Packages.props
|
275
274
|
- helpers/lib/NuGetUpdater/NuGetProjects/NuGet.Build.Tasks/NuGet.Build.Tasks.csproj
|
276
275
|
- helpers/lib/NuGetUpdater/NuGetProjects/NuGet.CommandLine/AssemblyMetadataExtractor.cs
|
277
276
|
- helpers/lib/NuGetUpdater/NuGetProjects/NuGet.CommandLine/NuGet.CommandLine.csproj
|
@@ -358,6 +357,7 @@ files:
|
|
358
357
|
- helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Utilities/AssertEx.cs
|
359
358
|
- helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Utilities/DiffUtil.cs
|
360
359
|
- helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Utilities/JsonHelperTests.cs
|
360
|
+
- helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Utilities/LinuxOnlyAttribute.cs
|
361
361
|
- helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Utilities/MSBuildHelperTests.cs
|
362
362
|
- helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Utilities/PathHelperTests.cs
|
363
363
|
- helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Utilities/SdkPackageUpdaterHelperTests.cs
|
@@ -369,7 +369,7 @@ files:
|
|
369
369
|
- helpers/lib/NuGetUpdater/NuGetUpdater.Core/Analyze/Extensions.cs
|
370
370
|
- helpers/lib/NuGetUpdater/NuGetUpdater.Core/Analyze/NuGetContext.cs
|
371
371
|
- helpers/lib/NuGetUpdater/NuGetUpdater.Core/Analyze/Requirement.cs
|
372
|
-
- helpers/lib/NuGetUpdater/NuGetUpdater.Core/Analyze/
|
372
|
+
- helpers/lib/NuGetUpdater/NuGetUpdater.Core/Analyze/RequirementArrayConverter.cs
|
373
373
|
- helpers/lib/NuGetUpdater/NuGetUpdater.Core/Analyze/SecurityVulnerability.cs
|
374
374
|
- helpers/lib/NuGetUpdater/NuGetUpdater.Core/Analyze/SecurityVulnerabilityExtensions.cs
|
375
375
|
- helpers/lib/NuGetUpdater/NuGetUpdater.Core/Analyze/VersionFinder.cs
|
@@ -462,6 +462,7 @@ files:
|
|
462
462
|
- helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/PathComparer.cs
|
463
463
|
- helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/PathHelper.cs
|
464
464
|
- helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/ProcessExtensions.cs
|
465
|
+
- helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/ProjectHelper.cs
|
465
466
|
- helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/XmlExtensions.cs
|
466
467
|
- helpers/lib/NuGetUpdater/NuGetUpdater.sln
|
467
468
|
- helpers/lib/NuGetUpdater/global.json
|
@@ -479,8 +480,6 @@ files:
|
|
479
480
|
- lib/dependabot/nuget/discovery/property_details.rb
|
480
481
|
- lib/dependabot/nuget/discovery/workspace_discovery.rb
|
481
482
|
- lib/dependabot/nuget/file_fetcher.rb
|
482
|
-
- lib/dependabot/nuget/file_fetcher/import_paths_finder.rb
|
483
|
-
- lib/dependabot/nuget/file_fetcher/sln_project_paths_finder.rb
|
484
483
|
- lib/dependabot/nuget/file_parser.rb
|
485
484
|
- lib/dependabot/nuget/file_updater.rb
|
486
485
|
- lib/dependabot/nuget/http_response_helpers.rb
|
@@ -515,7 +514,7 @@ licenses:
|
|
515
514
|
- MIT
|
516
515
|
metadata:
|
517
516
|
bug_tracker_uri: https://github.com/dependabot/dependabot-core/issues
|
518
|
-
changelog_uri: https://github.com/dependabot/dependabot-core/releases/tag/v0.
|
517
|
+
changelog_uri: https://github.com/dependabot/dependabot-core/releases/tag/v0.289.0
|
519
518
|
post_install_message:
|
520
519
|
rdoc_options: []
|
521
520
|
require_paths:
|
@@ -1,29 +0,0 @@
|
|
1
|
-
<Project>
|
2
|
-
|
3
|
-
<PropertyGroup>
|
4
|
-
<MicrosoftBuildVersion>17.5.0</MicrosoftBuildVersion>
|
5
|
-
<MicrosoftExtensionsFileProvidersAbstractionsPackageVersion>6.0.0</MicrosoftExtensionsFileProvidersAbstractionsPackageVersion>
|
6
|
-
<MicrosoftExtensionsFileSystemGlobbingPackageVersion>6.0.0</MicrosoftExtensionsFileSystemGlobbingPackageVersion>
|
7
|
-
<MicrosoftWebXdtPackageVersion>3.0.0</MicrosoftWebXdtPackageVersion>
|
8
|
-
<SystemPackagesVersion>4.3.0</SystemPackagesVersion>
|
9
|
-
<CryptographyPackagesVersion>5.0.0</CryptographyPackagesVersion>
|
10
|
-
</PropertyGroup>
|
11
|
-
|
12
|
-
<ItemGroup>
|
13
|
-
<PackageVersion Include="Microsoft.Build.Tasks.Core" Version="$(MicrosoftBuildVersion)" />
|
14
|
-
<PackageVersion Include="Microsoft.Build.Utilities.Core" Version="$(MicrosoftBuildVersion)" />
|
15
|
-
<PackageVersion Include="Microsoft.CSharp" Version="$(SystemPackagesVersion)" />
|
16
|
-
<PackageVersion Include="Microsoft.Extensions.FileProviders.Abstractions" Version="$(MicrosoftExtensionsFileProvidersAbstractionsPackageVersion)" />
|
17
|
-
<PackageVersion Include="Microsoft.Extensions.FileSystemGlobbing" Version="$(MicrosoftExtensionsFileSystemGlobbingPackageVersion)" />
|
18
|
-
<PackageVersion Include="Microsoft.VisualStudio.Setup.Configuration.Interop" Version="3.4.2244" />
|
19
|
-
<PackageVersion Include="Microsoft.Web.Xdt" Version="$(MicrosoftWebXdtPackageVersion)" />
|
20
|
-
<PackageVersion Include="Newtonsoft.Json" Version="13.0.1" />
|
21
|
-
<PackageVersion Include="NuGet.Core" Version="2.14.0-rtm-832" />
|
22
|
-
<PackageVersion Include="System.ComponentModel.Composition" Version="7.0.0" />
|
23
|
-
<PackageVersion Include="System.Security.Cryptography.Cng" Version="$(CryptographyPackagesVersion)" />
|
24
|
-
<PackageVersion Include="System.Security.Cryptography.Pkcs" Version="$(CryptographyPackagesVersion)" />
|
25
|
-
<PackageVersion Include="System.Security.Cryptography.ProtectedData" Version="4.4.0" />
|
26
|
-
<PackageVersion Include="System.Threading.Tasks.Dataflow" Version="6.0.0" />
|
27
|
-
</ItemGroup>
|
28
|
-
|
29
|
-
</Project>
|
@@ -1,17 +0,0 @@
|
|
1
|
-
using System.Text.Json;
|
2
|
-
using System.Text.Json.Serialization;
|
3
|
-
|
4
|
-
namespace NuGetUpdater.Core.Analyze;
|
5
|
-
|
6
|
-
public class RequirementConverter : JsonConverter<Requirement>
|
7
|
-
{
|
8
|
-
public override Requirement? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
|
9
|
-
{
|
10
|
-
return Requirement.Parse(reader.GetString()!);
|
11
|
-
}
|
12
|
-
|
13
|
-
public override void Write(Utf8JsonWriter writer, Requirement value, JsonSerializerOptions options)
|
14
|
-
{
|
15
|
-
writer.WriteStringValue(value.ToString());
|
16
|
-
}
|
17
|
-
}
|