dependabot-nuget 0.323.0 → 0.325.1
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,266 +0,0 @@
|
|
1
|
-
# typed: strong
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
require "dependabot/dependency"
|
5
|
-
require "dependabot/file_parsers/base/dependency_set"
|
6
|
-
require "dependabot/nuget/cache_manager"
|
7
|
-
require "dependabot/nuget/discovery/workspace_discovery"
|
8
|
-
require "json"
|
9
|
-
require "sorbet-runtime"
|
10
|
-
|
11
|
-
module Dependabot
|
12
|
-
module Nuget
|
13
|
-
class DiscoveryJsonReader
|
14
|
-
extend T::Sig
|
15
|
-
|
16
|
-
sig { returns(T::Hash[String, DiscoveryJsonReader]) }
|
17
|
-
def self.cache_directory_to_discovery_json_reader
|
18
|
-
CacheManager.cache("cache_directory_to_discovery_json_reader")
|
19
|
-
end
|
20
|
-
|
21
|
-
sig { returns(T::Hash[String, DiscoveryJsonReader]) }
|
22
|
-
def self.cache_dependency_file_paths_to_discovery_json_reader
|
23
|
-
CacheManager.cache("cache_dependency_file_paths_to_discovery_json_reader")
|
24
|
-
end
|
25
|
-
|
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")
|
29
|
-
end
|
30
|
-
|
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
|
36
|
-
end
|
37
|
-
|
38
|
-
sig { void }
|
39
|
-
def self.testonly_clear_discovery_files
|
40
|
-
# this will get recreated when necessary
|
41
|
-
FileUtils.rm_rf(discovery_directory)
|
42
|
-
end
|
43
|
-
|
44
|
-
# Runs NuGet dependency discovery in the given directory and returns a new instance of DiscoveryJsonReader.
|
45
|
-
# The location of the resultant JSON file is saved.
|
46
|
-
sig do
|
47
|
-
params(
|
48
|
-
repo_contents_path: String,
|
49
|
-
directory: String,
|
50
|
-
credentials: T::Array[Dependabot::Credential]
|
51
|
-
).returns(DiscoveryJsonReader)
|
52
|
-
end
|
53
|
-
def self.run_discovery_in_directory(repo_contents_path:, directory:, credentials:)
|
54
|
-
# run discovery
|
55
|
-
job_file_path = ENV.fetch("DEPENDABOT_JOB_PATH")
|
56
|
-
discovery_json_path = discovery_file_path_from_workspace_path(directory)
|
57
|
-
unless File.exist?(discovery_json_path)
|
58
|
-
NativeHelpers.run_nuget_discover_tool(job_path: job_file_path,
|
59
|
-
repo_root: repo_contents_path,
|
60
|
-
workspace_path: directory,
|
61
|
-
output_path: discovery_json_path,
|
62
|
-
credentials: credentials)
|
63
|
-
|
64
|
-
Dependabot.logger.info("Discovery JSON content: #{File.read(discovery_json_path)}")
|
65
|
-
end
|
66
|
-
load_discovery_for_directory(repo_contents_path: repo_contents_path, directory: directory)
|
67
|
-
end
|
68
|
-
|
69
|
-
# Loads NuGet dependency discovery for the given directory and returns a new instance of DiscoveryJsonReader and
|
70
|
-
# caches the resultant object.
|
71
|
-
sig { params(repo_contents_path: String, directory: String).returns(DiscoveryJsonReader) }
|
72
|
-
def self.load_discovery_for_directory(repo_contents_path:, directory:)
|
73
|
-
cache_directory_to_discovery_json_reader[directory] ||= begin
|
74
|
-
discovery_json_reader = discovery_json_reader(repo_contents_path: repo_contents_path,
|
75
|
-
workspace_path: directory)
|
76
|
-
cache_directory_to_discovery_json_reader[directory] = discovery_json_reader
|
77
|
-
dependency_file_cache_key = cache_key_from_dependency_file_paths(discovery_json_reader.dependency_file_paths)
|
78
|
-
cache_dependency_file_paths_to_discovery_json_reader[dependency_file_cache_key] = discovery_json_reader
|
79
|
-
discovery_file_path = discovery_file_path_from_workspace_path(directory)
|
80
|
-
cache_dependency_file_paths_to_discovery_json_path[dependency_file_cache_key] = discovery_file_path
|
81
|
-
|
82
|
-
discovery_json_reader
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
|
-
# Retrieves the cached DiscoveryJsonReader object for the given dependency file paths.
|
87
|
-
sig { params(dependency_file_paths: T::Array[String]).returns(DiscoveryJsonReader) }
|
88
|
-
def self.load_discovery_for_dependency_file_paths(dependency_file_paths)
|
89
|
-
dependency_file_cache_key = cache_key_from_dependency_file_paths(dependency_file_paths)
|
90
|
-
T.must(cache_dependency_file_paths_to_discovery_json_reader[dependency_file_cache_key])
|
91
|
-
end
|
92
|
-
|
93
|
-
# Retrieves the cached location of the discovery JSON file for the given dependency file paths.
|
94
|
-
sig { params(dependency_file_paths: T::Array[String]).returns(String) }
|
95
|
-
def self.get_discovery_json_path_for_dependency_file_paths(dependency_file_paths)
|
96
|
-
dependency_file_cache_key = cache_key_from_dependency_file_paths(dependency_file_paths)
|
97
|
-
T.must(cache_dependency_file_paths_to_discovery_json_path[dependency_file_cache_key])
|
98
|
-
end
|
99
|
-
|
100
|
-
sig { params(repo_contents_path: String, dependency_file: Dependabot::DependencyFile).returns(String) }
|
101
|
-
def self.dependency_file_path(repo_contents_path:, dependency_file:)
|
102
|
-
dep_file_path = Pathname.new(File.join(dependency_file.directory, dependency_file.name)).cleanpath.to_path
|
103
|
-
dep_file_path.delete_prefix("#{repo_contents_path}/")
|
104
|
-
end
|
105
|
-
|
106
|
-
sig { returns(String) }
|
107
|
-
def self.discovery_map_file_path
|
108
|
-
File.join(discovery_directory, "discovery_map.json")
|
109
|
-
end
|
110
|
-
|
111
|
-
sig { params(workspace_path: String).returns(String) }
|
112
|
-
def self.discovery_file_path_from_workspace_path(workspace_path)
|
113
|
-
# Given an update directory (also known as a workspace path), this function returns the path where the discovery
|
114
|
-
# JSON file is located. This function is called both by methods that need to write the discovery JSON file and
|
115
|
-
# by methods that need to read the discovery JSON file. This function is also called by multiple processes so
|
116
|
-
# we need a way to retain the data. This is accomplished by the following steps:
|
117
|
-
# 1. Check a well-known file for a mapping of workspace_path => discovery file path. If found, return it.
|
118
|
-
# 2. If the path is not found, generate a new path, save it to the well-known file, and return the value.
|
119
|
-
discovery_map_contents = File.exist?(discovery_map_file_path) ? File.read(discovery_map_file_path) : "{}"
|
120
|
-
discovery_map = T.let(JSON.parse(discovery_map_contents), T::Hash[String, String])
|
121
|
-
|
122
|
-
discovery_json_path = discovery_map[workspace_path]
|
123
|
-
if discovery_json_path
|
124
|
-
Dependabot.logger.info("Discovery JSON path for workspace path [#{workspace_path}] found in file " \
|
125
|
-
"[#{discovery_map_file_path}] at location [#{discovery_json_path}]")
|
126
|
-
return discovery_json_path
|
127
|
-
end
|
128
|
-
|
129
|
-
# no discovery JSON path found; generate a new one, but first find a suitable location
|
130
|
-
discovery_json_counter = 1
|
131
|
-
new_discovery_json_path = ""
|
132
|
-
loop do
|
133
|
-
new_discovery_json_path = File.join(discovery_directory, "discovery.#{discovery_json_counter}.json")
|
134
|
-
break unless File.exist?(new_discovery_json_path)
|
135
|
-
|
136
|
-
discovery_json_counter += 1
|
137
|
-
end
|
138
|
-
|
139
|
-
discovery_map[workspace_path] = new_discovery_json_path
|
140
|
-
|
141
|
-
File.write(discovery_map_file_path, discovery_map.to_json)
|
142
|
-
Dependabot.logger.info("Discovery JSON path for workspace path [#{workspace_path}] created for file " \
|
143
|
-
"[#{discovery_map_file_path}] at location [#{new_discovery_json_path}]")
|
144
|
-
new_discovery_json_path
|
145
|
-
end
|
146
|
-
|
147
|
-
sig { params(dependency_file_paths: T::Array[String]).returns(String) }
|
148
|
-
def self.cache_key_from_dependency_file_paths(dependency_file_paths)
|
149
|
-
dependency_file_paths.sort.join(",")
|
150
|
-
end
|
151
|
-
|
152
|
-
sig { returns(String) }
|
153
|
-
def self.discovery_directory
|
154
|
-
t = File.join(Dir.home, ".dependabot")
|
155
|
-
FileUtils.mkdir_p(t)
|
156
|
-
t
|
157
|
-
end
|
158
|
-
|
159
|
-
sig { params(repo_contents_path: String, workspace_path: String).returns(DiscoveryJsonReader) }
|
160
|
-
def self.discovery_json_reader(repo_contents_path:, workspace_path:)
|
161
|
-
discovery_file_path = discovery_file_path_from_workspace_path(workspace_path)
|
162
|
-
discovery_json = DependencyFile.new(
|
163
|
-
name: Pathname.new(discovery_file_path).cleanpath.to_path,
|
164
|
-
directory: discovery_directory,
|
165
|
-
type: "file",
|
166
|
-
content: File.read(discovery_file_path)
|
167
|
-
)
|
168
|
-
DiscoveryJsonReader.new(repo_contents_path: repo_contents_path, discovery_json: discovery_json)
|
169
|
-
end
|
170
|
-
|
171
|
-
sig { returns(T.nilable(WorkspaceDiscovery)) }
|
172
|
-
attr_reader :workspace_discovery
|
173
|
-
|
174
|
-
sig { returns(Dependabot::FileParsers::Base::DependencySet) }
|
175
|
-
attr_reader :dependency_set
|
176
|
-
|
177
|
-
sig { returns(T::Array[String]) }
|
178
|
-
attr_reader :dependency_file_paths
|
179
|
-
|
180
|
-
sig { params(repo_contents_path: String, discovery_json: DependencyFile).void }
|
181
|
-
def initialize(repo_contents_path:, discovery_json:)
|
182
|
-
@repo_contents_path = repo_contents_path
|
183
|
-
@discovery_json = discovery_json
|
184
|
-
@workspace_discovery = T.let(read_workspace_discovery, T.nilable(Dependabot::Nuget::WorkspaceDiscovery))
|
185
|
-
@dependency_set = T.let(read_dependency_set, Dependabot::FileParsers::Base::DependencySet)
|
186
|
-
@dependency_file_paths = T.let(read_dependency_file_paths, T::Array[String])
|
187
|
-
end
|
188
|
-
|
189
|
-
private
|
190
|
-
|
191
|
-
sig { returns(String) }
|
192
|
-
attr_reader :repo_contents_path
|
193
|
-
|
194
|
-
sig { returns(DependencyFile) }
|
195
|
-
attr_reader :discovery_json
|
196
|
-
|
197
|
-
sig { returns(T.nilable(WorkspaceDiscovery)) }
|
198
|
-
def read_workspace_discovery
|
199
|
-
return nil unless discovery_json.content
|
200
|
-
|
201
|
-
parsed_json = T.let(JSON.parse(T.must(discovery_json.content)), T::Hash[String, T.untyped])
|
202
|
-
WorkspaceDiscovery.from_json(parsed_json)
|
203
|
-
rescue JSON::ParserError
|
204
|
-
raise Dependabot::DependencyFileNotParseable, discovery_json.path
|
205
|
-
end
|
206
|
-
|
207
|
-
sig { returns(Dependabot::FileParsers::Base::DependencySet) }
|
208
|
-
def read_dependency_set
|
209
|
-
dependency_set = Dependabot::FileParsers::Base::DependencySet.new
|
210
|
-
return dependency_set unless workspace_discovery
|
211
|
-
|
212
|
-
workspace_result = T.must(workspace_discovery)
|
213
|
-
workspace_result.projects.each do |project|
|
214
|
-
dependency_set += project.dependency_set
|
215
|
-
end
|
216
|
-
if workspace_result.dotnet_tools_json
|
217
|
-
dependency_set += T.must(workspace_result.dotnet_tools_json).dependency_set
|
218
|
-
end
|
219
|
-
dependency_set += T.must(workspace_result.global_json).dependency_set if workspace_result.global_json
|
220
|
-
|
221
|
-
dependency_set
|
222
|
-
end
|
223
|
-
|
224
|
-
sig { returns(T::Array[String]) }
|
225
|
-
def read_dependency_file_paths
|
226
|
-
dependency_file_paths = T.let([], T::Array[T.nilable(String)])
|
227
|
-
dependency_file_paths << dependency_file_path_from_repo_path("global.json") if workspace_discovery&.global_json
|
228
|
-
if workspace_discovery&.dotnet_tools_json
|
229
|
-
dependency_file_paths << dependency_file_path_from_repo_path(".config/dotnet-tools.json")
|
230
|
-
end
|
231
|
-
|
232
|
-
projects = workspace_discovery&.projects || []
|
233
|
-
projects.each do |project|
|
234
|
-
dependency_file_paths << dependency_file_path_from_repo_path(project.file_path)
|
235
|
-
dependency_file_paths += project.imported_files.map do |f|
|
236
|
-
dependency_file_path_from_project_path(project.file_path, f)
|
237
|
-
end
|
238
|
-
dependency_file_paths += project.additional_files.map do |f|
|
239
|
-
dependency_file_path_from_project_path(project.file_path, f)
|
240
|
-
end
|
241
|
-
end
|
242
|
-
|
243
|
-
deduped_dependency_file_paths = T.let(Set.new(dependency_file_paths.compact), T::Set[String])
|
244
|
-
result = deduped_dependency_file_paths.sort
|
245
|
-
result
|
246
|
-
end
|
247
|
-
|
248
|
-
sig { params(path_parts: String).returns(T.nilable(String)) }
|
249
|
-
def dependency_file_path_from_repo_path(*path_parts)
|
250
|
-
path_parts = path_parts.map { |p| p.delete_prefix("/").delete_suffix("/") }
|
251
|
-
normalized_repo_path = Pathname.new(path_parts.join("/")).cleanpath.to_path.delete_prefix("/")
|
252
|
-
full_path = Pathname.new(File.join(repo_contents_path, normalized_repo_path)).cleanpath.to_path
|
253
|
-
return unless File.exist?(full_path)
|
254
|
-
|
255
|
-
normalized_repo_path = "/#{normalized_repo_path}" unless normalized_repo_path.start_with?("/")
|
256
|
-
normalized_repo_path
|
257
|
-
end
|
258
|
-
|
259
|
-
sig { params(project_path: String, relative_file_path: String).returns(T.nilable(String)) }
|
260
|
-
def dependency_file_path_from_project_path(project_path, relative_file_path)
|
261
|
-
project_directory = File.dirname(project_path)
|
262
|
-
dependency_file_path_from_repo_path(project_directory, relative_file_path)
|
263
|
-
end
|
264
|
-
end
|
265
|
-
end
|
266
|
-
end
|
@@ -1,63 +0,0 @@
|
|
1
|
-
# typed: strong
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
require "sorbet-runtime"
|
5
|
-
|
6
|
-
module Dependabot
|
7
|
-
module Nuget
|
8
|
-
class EvaluationDetails
|
9
|
-
extend T::Sig
|
10
|
-
|
11
|
-
sig { params(json: T.nilable(T::Hash[String, T.untyped])).returns(T.nilable(EvaluationDetails)) }
|
12
|
-
def self.from_json(json)
|
13
|
-
return nil if json.nil?
|
14
|
-
|
15
|
-
result_type = T.let(json.fetch("ResultType"), String)
|
16
|
-
original_value = T.let(json.fetch("OriginalValue"), String)
|
17
|
-
evaluated_value = T.let(json.fetch("EvaluatedValue"), String)
|
18
|
-
root_property_name = T.let(json.fetch("RootPropertyName", nil), T.nilable(String))
|
19
|
-
error_message = T.let(json.fetch("ErrorMessage", nil), T.nilable(String))
|
20
|
-
|
21
|
-
EvaluationDetails.new(result_type: result_type,
|
22
|
-
original_value: original_value,
|
23
|
-
evaluated_value: evaluated_value,
|
24
|
-
root_property_name: root_property_name,
|
25
|
-
error_message: error_message)
|
26
|
-
end
|
27
|
-
|
28
|
-
sig do
|
29
|
-
params(result_type: String,
|
30
|
-
original_value: String,
|
31
|
-
evaluated_value: String,
|
32
|
-
root_property_name: T.nilable(String),
|
33
|
-
error_message: T.nilable(String)).void
|
34
|
-
end
|
35
|
-
def initialize(result_type:,
|
36
|
-
original_value:,
|
37
|
-
evaluated_value:,
|
38
|
-
root_property_name:,
|
39
|
-
error_message:)
|
40
|
-
@result_type = result_type
|
41
|
-
@original_value = original_value
|
42
|
-
@evaluated_value = evaluated_value
|
43
|
-
@root_property_name = root_property_name
|
44
|
-
@error_message = error_message
|
45
|
-
end
|
46
|
-
|
47
|
-
sig { returns(String) }
|
48
|
-
attr_reader :result_type
|
49
|
-
|
50
|
-
sig { returns(String) }
|
51
|
-
attr_reader :original_value
|
52
|
-
|
53
|
-
sig { returns(String) }
|
54
|
-
attr_reader :evaluated_value
|
55
|
-
|
56
|
-
sig { returns(T.nilable(String)) }
|
57
|
-
attr_reader :root_property_name
|
58
|
-
|
59
|
-
sig { returns(T.nilable(String)) }
|
60
|
-
attr_reader :error_message
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
@@ -1,104 +0,0 @@
|
|
1
|
-
# typed: strong
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
require "dependabot/nuget/discovery/dependency_details"
|
5
|
-
require "dependabot/nuget/discovery/property_details"
|
6
|
-
require "sorbet-runtime"
|
7
|
-
|
8
|
-
module Dependabot
|
9
|
-
module Nuget
|
10
|
-
class ProjectDiscovery < DependencyFileDiscovery
|
11
|
-
extend T::Sig
|
12
|
-
|
13
|
-
# rubocop:disable Metrics/AbcSize
|
14
|
-
sig do
|
15
|
-
override.params(json: T.nilable(T::Hash[String, T.untyped]),
|
16
|
-
directory: String).returns(T.nilable(ProjectDiscovery))
|
17
|
-
end
|
18
|
-
def self.from_json(json, directory)
|
19
|
-
return nil if json.nil?
|
20
|
-
|
21
|
-
file_path = File.join(directory, T.let(json.fetch("FilePath"), String))
|
22
|
-
properties = T.let(json.fetch("Properties"), T::Array[T::Hash[String, T.untyped]]).map do |prop|
|
23
|
-
PropertyDetails.from_json(prop)
|
24
|
-
end
|
25
|
-
target_frameworks = T.let(json.fetch("TargetFrameworks"), T::Array[String])
|
26
|
-
referenced_project_paths = T.let(json.fetch("ReferencedProjectPaths"), T::Array[String])
|
27
|
-
dependencies = T.let(json.fetch("Dependencies"), T::Array[T::Hash[String, T.untyped]]).filter_map do |dep|
|
28
|
-
details = DependencyDetails.from_json(dep)
|
29
|
-
next unless details.version # can't do anything without a version
|
30
|
-
|
31
|
-
version = T.must(details.version)
|
32
|
-
next unless version.length.positive? # can't do anything with an empty version
|
33
|
-
|
34
|
-
next if version.include? "," # can't do anything with a range
|
35
|
-
|
36
|
-
next if version.include? "*" # can't do anything with a wildcard
|
37
|
-
|
38
|
-
details
|
39
|
-
end
|
40
|
-
imported_files = T.let(json.fetch("ImportedFiles"), T::Array[String])
|
41
|
-
additional_files = T.let(json.fetch("AdditionalFiles"), T::Array[String])
|
42
|
-
|
43
|
-
ProjectDiscovery.new(file_path: file_path,
|
44
|
-
properties: properties,
|
45
|
-
target_frameworks: target_frameworks,
|
46
|
-
referenced_project_paths: referenced_project_paths,
|
47
|
-
dependencies: dependencies,
|
48
|
-
imported_files: imported_files,
|
49
|
-
additional_files: additional_files)
|
50
|
-
end
|
51
|
-
# rubocop:enable Metrics/AbcSize
|
52
|
-
|
53
|
-
sig do
|
54
|
-
params(file_path: String,
|
55
|
-
properties: T::Array[PropertyDetails],
|
56
|
-
target_frameworks: T::Array[String],
|
57
|
-
referenced_project_paths: T::Array[String],
|
58
|
-
dependencies: T::Array[DependencyDetails],
|
59
|
-
imported_files: T::Array[String],
|
60
|
-
additional_files: T::Array[String]).void
|
61
|
-
end
|
62
|
-
def initialize(file_path:,
|
63
|
-
properties:,
|
64
|
-
target_frameworks:,
|
65
|
-
referenced_project_paths:,
|
66
|
-
dependencies:,
|
67
|
-
imported_files:,
|
68
|
-
additional_files:)
|
69
|
-
super(file_path: file_path, dependencies: dependencies)
|
70
|
-
@properties = properties
|
71
|
-
@target_frameworks = target_frameworks
|
72
|
-
@referenced_project_paths = referenced_project_paths
|
73
|
-
@imported_files = imported_files
|
74
|
-
@additional_files = additional_files
|
75
|
-
end
|
76
|
-
|
77
|
-
sig { returns(T::Array[PropertyDetails]) }
|
78
|
-
attr_reader :properties
|
79
|
-
|
80
|
-
sig { returns(T::Array[String]) }
|
81
|
-
attr_reader :target_frameworks
|
82
|
-
|
83
|
-
sig { returns(T::Array[String]) }
|
84
|
-
attr_reader :referenced_project_paths
|
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
|
-
|
92
|
-
sig { override.returns(Dependabot::FileParsers::Base::DependencySet) }
|
93
|
-
def dependency_set
|
94
|
-
if target_frameworks.empty? && file_path.end_with?("proj")
|
95
|
-
Dependabot.logger.warn("Excluding project file '#{file_path}' due to unresolvable target framework")
|
96
|
-
dependency_set = Dependabot::FileParsers::Base::DependencySet.new
|
97
|
-
return dependency_set
|
98
|
-
end
|
99
|
-
|
100
|
-
super
|
101
|
-
end
|
102
|
-
end
|
103
|
-
end
|
104
|
-
end
|
@@ -1,43 +0,0 @@
|
|
1
|
-
# typed: strong
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
require "sorbet-runtime"
|
5
|
-
|
6
|
-
module Dependabot
|
7
|
-
module Nuget
|
8
|
-
class PropertyDetails
|
9
|
-
extend T::Sig
|
10
|
-
|
11
|
-
sig { params(json: T::Hash[String, T.untyped]).returns(PropertyDetails) }
|
12
|
-
def self.from_json(json)
|
13
|
-
name = T.let(json.fetch("Name"), String)
|
14
|
-
value = T.let(json.fetch("Value"), String)
|
15
|
-
source_file_path = T.let(json.fetch("SourceFilePath"), String)
|
16
|
-
|
17
|
-
PropertyDetails.new(name: name,
|
18
|
-
value: value,
|
19
|
-
source_file_path: source_file_path)
|
20
|
-
end
|
21
|
-
|
22
|
-
sig do
|
23
|
-
params(name: String,
|
24
|
-
value: String,
|
25
|
-
source_file_path: String).void
|
26
|
-
end
|
27
|
-
def initialize(name:, value:, source_file_path:)
|
28
|
-
@name = name
|
29
|
-
@value = value
|
30
|
-
@source_file_path = source_file_path
|
31
|
-
end
|
32
|
-
|
33
|
-
sig { returns(String) }
|
34
|
-
attr_reader :name
|
35
|
-
|
36
|
-
sig { returns(String) }
|
37
|
-
attr_reader :value
|
38
|
-
|
39
|
-
sig { returns(String) }
|
40
|
-
attr_reader :source_file_path
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
@@ -1,61 +0,0 @@
|
|
1
|
-
# typed: strong
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
require "dependabot/nuget/discovery/dependency_file_discovery"
|
5
|
-
require "dependabot/nuget/discovery/project_discovery"
|
6
|
-
require "dependabot/nuget/native_helpers"
|
7
|
-
require "sorbet-runtime"
|
8
|
-
|
9
|
-
module Dependabot
|
10
|
-
module Nuget
|
11
|
-
class WorkspaceDiscovery
|
12
|
-
extend T::Sig
|
13
|
-
|
14
|
-
sig { params(json: T::Hash[String, T.untyped]).returns(WorkspaceDiscovery) }
|
15
|
-
def self.from_json(json)
|
16
|
-
Dependabot::Nuget::NativeHelpers.ensure_no_errors(json)
|
17
|
-
|
18
|
-
path = T.let(json.fetch("Path"), String)
|
19
|
-
path = "/" + path unless path.start_with?("/")
|
20
|
-
projects = T.let(json.fetch("Projects"), T::Array[T::Hash[String, T.untyped]]).filter_map do |project|
|
21
|
-
ProjectDiscovery.from_json(project, path)
|
22
|
-
end
|
23
|
-
global_json = DependencyFileDiscovery
|
24
|
-
.from_json(T.let(json.fetch("GlobalJson"), T.nilable(T::Hash[String, T.untyped])), path)
|
25
|
-
dotnet_tools_json = DependencyFileDiscovery
|
26
|
-
.from_json(T.let(json.fetch("DotNetToolsJson"),
|
27
|
-
T.nilable(T::Hash[String, T.untyped])), path)
|
28
|
-
|
29
|
-
WorkspaceDiscovery.new(path: path,
|
30
|
-
projects: projects,
|
31
|
-
global_json: global_json,
|
32
|
-
dotnet_tools_json: dotnet_tools_json)
|
33
|
-
end
|
34
|
-
|
35
|
-
sig do
|
36
|
-
params(path: String,
|
37
|
-
projects: T::Array[ProjectDiscovery],
|
38
|
-
global_json: T.nilable(DependencyFileDiscovery),
|
39
|
-
dotnet_tools_json: T.nilable(DependencyFileDiscovery)).void
|
40
|
-
end
|
41
|
-
def initialize(path:, projects:, global_json:, dotnet_tools_json:)
|
42
|
-
@path = path
|
43
|
-
@projects = projects
|
44
|
-
@global_json = global_json
|
45
|
-
@dotnet_tools_json = dotnet_tools_json
|
46
|
-
end
|
47
|
-
|
48
|
-
sig { returns(String) }
|
49
|
-
attr_reader :path
|
50
|
-
|
51
|
-
sig { returns(T::Array[ProjectDiscovery]) }
|
52
|
-
attr_reader :projects
|
53
|
-
|
54
|
-
sig { returns(T.nilable(DependencyFileDiscovery)) }
|
55
|
-
attr_reader :global_json
|
56
|
-
|
57
|
-
sig { returns(T.nilable(DependencyFileDiscovery)) }
|
58
|
-
attr_reader :dotnet_tools_json
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
@@ -1,46 +0,0 @@
|
|
1
|
-
# typed: strong
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
require "sorbet-runtime"
|
5
|
-
|
6
|
-
require "dependabot/file_fetchers"
|
7
|
-
require "dependabot/file_fetchers/base"
|
8
|
-
require "dependabot/nuget/discovery/discovery_json_reader"
|
9
|
-
require "dependabot/nuget/native_helpers"
|
10
|
-
|
11
|
-
module Dependabot
|
12
|
-
module Nuget
|
13
|
-
class FileFetcher < Dependabot::FileFetchers::Base
|
14
|
-
extend T::Sig
|
15
|
-
extend T::Helpers
|
16
|
-
|
17
|
-
sig { override.params(filenames: T::Array[String]).returns(T::Boolean) }
|
18
|
-
def self.required_files_in?(filenames)
|
19
|
-
filenames.any? { |name| name.match?(/\.(cs|vb|fs)proj$/) }
|
20
|
-
end
|
21
|
-
|
22
|
-
sig { override.returns(String) }
|
23
|
-
def self.required_files_message
|
24
|
-
"Repo must contain .(cs|vb|fs)proj file."
|
25
|
-
end
|
26
|
-
|
27
|
-
sig { override.returns(T::Array[DependencyFile]) }
|
28
|
-
def fetch_files
|
29
|
-
NativeHelpers.normalize_file_names
|
30
|
-
NativeHelpers.install_dotnet_sdks
|
31
|
-
discovery_json_reader = DiscoveryJsonReader.run_discovery_in_directory(
|
32
|
-
repo_contents_path: T.must(repo_contents_path),
|
33
|
-
directory: directory,
|
34
|
-
credentials: credentials
|
35
|
-
)
|
36
|
-
|
37
|
-
discovery_json_reader.dependency_file_paths.map do |p|
|
38
|
-
relative_path = Pathname.new(p).relative_path_from(directory).to_path
|
39
|
-
fetch_file_from_host(relative_path)
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
Dependabot::FileFetchers.register("nuget", Dependabot::Nuget::FileFetcher)
|