dependabot-nuget 0.250.0 → 0.252.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (86) hide show
  1. checksums.yaml +4 -4
  2. data/helpers/lib/NuGetUpdater/Directory.Common.props +1 -0
  3. data/helpers/lib/NuGetUpdater/Directory.Packages.props +26 -0
  4. data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli/Commands/DiscoverCommand.cs +35 -0
  5. data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli/NuGetUpdater.Cli.csproj +1 -1
  6. data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli/Program.cs +4 -7
  7. data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli.Test/EntryPointTests.Discover.cs +251 -0
  8. data/helpers/lib/NuGetUpdater/NuGetUpdater.Cli.Test/NuGetUpdater.Cli.Test.csproj +3 -3
  9. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Dependency.cs +56 -1
  10. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/DependencyType.cs +1 -1
  11. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/DirectoryPackagesPropsDiscovery.cs +69 -0
  12. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/DirectoryPackagesPropsDiscoveryResult.cs +11 -0
  13. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/DiscoveryWorker.cs +217 -0
  14. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/DotNetToolsJsonDiscovery.cs +30 -0
  15. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/DotNetToolsJsonDiscoveryResult.cs +10 -0
  16. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/GlobalJsonDiscovery.cs +30 -0
  17. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/GlobalJsonDiscoveryResult.cs +10 -0
  18. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/IDiscoveryResult.cs +14 -0
  19. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/PackagesConfigDiscovery.cs +29 -0
  20. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/PackagesConfigDiscoveryResult.cs +10 -0
  21. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/ProjectDiscoveryResult.cs +13 -0
  22. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/SdkProjectDiscovery.cs +127 -0
  23. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/WorkspaceDiscoveryResult.cs +13 -0
  24. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/EvaluationResult.cs +8 -0
  25. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/EvaluationResultType.cs +9 -0
  26. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Files/BuildFile.cs +6 -8
  27. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Files/DotNetToolsJsonBuildFile.cs +4 -7
  28. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Files/GlobalJsonBuildFile.cs +24 -17
  29. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Files/JsonBuildFile.cs +2 -2
  30. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Files/PackagesConfigBuildFile.cs +8 -13
  31. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Files/ProjectBuildFile.cs +100 -19
  32. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Files/XmlBuildFile.cs +2 -2
  33. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/NuGetUpdater.Core.csproj +6 -6
  34. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Property.cs +6 -0
  35. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/DotNetToolsJsonUpdater.cs +23 -36
  36. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/GlobalJsonUpdater.cs +5 -10
  37. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/SdkPackageUpdater.cs +16 -21
  38. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/UpdaterWorker.cs +4 -19
  39. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/HashSetExtensions.cs +14 -0
  40. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/ImmutableArrayExtensions.cs +18 -0
  41. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/JsonHelper.cs +0 -1
  42. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/MSBuildHelper.cs +121 -67
  43. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/NuGetHelper.cs +27 -4
  44. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTestBase.cs +117 -0
  45. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTests.DotNetToolsJson.cs +91 -0
  46. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTests.GlobalJson.cs +71 -0
  47. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTests.PackagesConfig.cs +59 -0
  48. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTests.Project.cs +380 -0
  49. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTests.cs +306 -0
  50. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/ExpectedDiscoveryResults.cs +36 -0
  51. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Files/DotNetToolsJsonBuildFileTests.cs +1 -2
  52. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Files/GlobalJsonBuildFileTests.cs +2 -3
  53. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Files/PackagesConfigBuildFileTests.cs +4 -6
  54. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Files/ProjectBuildFileTests.cs +6 -5
  55. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/NuGetUpdater.Core.Test.csproj +4 -3
  56. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/TemporaryDirectory.cs +38 -6
  57. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTestBase.cs +12 -40
  58. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.Sdk.cs +30 -0
  59. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Utilities/AssertEx.cs +272 -0
  60. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Utilities/DiffUtil.cs +266 -0
  61. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Utilities/MSBuildHelperTests.cs +195 -152
  62. data/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Utilities/SdkPackageUpdaterHelperTests.cs +7 -11
  63. data/lib/dependabot/nuget/discovery/dependency_details.rb +95 -0
  64. data/lib/dependabot/nuget/discovery/dependency_file_discovery.rb +126 -0
  65. data/lib/dependabot/nuget/discovery/directory_packages_props_discovery.rb +43 -0
  66. data/lib/dependabot/nuget/discovery/discovery_json_reader.rb +83 -0
  67. data/lib/dependabot/nuget/discovery/evaluation_details.rb +63 -0
  68. data/lib/dependabot/nuget/discovery/project_discovery.rb +71 -0
  69. data/lib/dependabot/nuget/discovery/property_details.rb +43 -0
  70. data/lib/dependabot/nuget/discovery/workspace_discovery.rb +66 -0
  71. data/lib/dependabot/nuget/file_parser.rb +19 -128
  72. data/lib/dependabot/nuget/file_updater.rb +28 -60
  73. data/lib/dependabot/nuget/native_helpers.rb +55 -0
  74. data/lib/dependabot/nuget/update_checker/compatibility_checker.rb +3 -8
  75. data/lib/dependabot/nuget/update_checker/dependency_finder.rb +1 -0
  76. data/lib/dependabot/nuget/update_checker/property_updater.rb +1 -0
  77. data/lib/dependabot/nuget/update_checker/tfm_finder.rb +17 -152
  78. data/lib/dependabot/nuget/update_checker/version_finder.rb +1 -6
  79. data/lib/dependabot/nuget/update_checker.rb +4 -1
  80. metadata +43 -11
  81. data/lib/dependabot/nuget/file_parser/dotnet_tools_json_parser.rb +0 -71
  82. data/lib/dependabot/nuget/file_parser/global_json_parser.rb +0 -68
  83. data/lib/dependabot/nuget/file_parser/packages_config_parser.rb +0 -92
  84. data/lib/dependabot/nuget/file_parser/project_file_parser.rb +0 -620
  85. data/lib/dependabot/nuget/file_parser/property_value_finder.rb +0 -225
  86. data/lib/dependabot/nuget/file_updater/property_value_updater.rb +0 -81
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.250.0
4
+ version: 0.252.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-04-02 00:00:00.000000000 Z
11
+ date: 2024-04-11 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.250.0
19
+ version: 0.252.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.250.0
26
+ version: 0.252.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rubyzip
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -267,6 +267,7 @@ files:
267
267
  - helpers/lib/NuGetUpdater/.gitignore
268
268
  - helpers/lib/NuGetUpdater/Directory.Build.props
269
269
  - helpers/lib/NuGetUpdater/Directory.Common.props
270
+ - helpers/lib/NuGetUpdater/Directory.Packages.props
270
271
  - helpers/lib/NuGetUpdater/NuGetProjects/Directory.Build.props
271
272
  - helpers/lib/NuGetUpdater/NuGetProjects/Directory.Build.targets
272
273
  - helpers/lib/NuGetUpdater/NuGetProjects/Directory.Packages.props
@@ -288,13 +289,22 @@ files:
288
289
  - helpers/lib/NuGetUpdater/NuGetProjects/NuGet.Resolver/NuGet.Resolver.csproj
289
290
  - helpers/lib/NuGetUpdater/NuGetProjects/NuGet.Versioning/NuGet.Versioning.csproj
290
291
  - helpers/lib/NuGetUpdater/NuGetProjects/README.md
292
+ - helpers/lib/NuGetUpdater/NuGetUpdater.Cli.Test/EntryPointTests.Discover.cs
291
293
  - helpers/lib/NuGetUpdater/NuGetUpdater.Cli.Test/EntryPointTests.FrameworkCheck.cs
292
294
  - helpers/lib/NuGetUpdater/NuGetUpdater.Cli.Test/EntryPointTests.Update.cs
293
295
  - helpers/lib/NuGetUpdater/NuGetUpdater.Cli.Test/NuGetUpdater.Cli.Test.csproj
296
+ - helpers/lib/NuGetUpdater/NuGetUpdater.Cli/Commands/DiscoverCommand.cs
294
297
  - helpers/lib/NuGetUpdater/NuGetUpdater.Cli/Commands/FrameworkCheckCommand.cs
295
298
  - helpers/lib/NuGetUpdater/NuGetUpdater.Cli/Commands/UpdateCommand.cs
296
299
  - helpers/lib/NuGetUpdater/NuGetUpdater.Cli/NuGetUpdater.Cli.csproj
297
300
  - helpers/lib/NuGetUpdater/NuGetUpdater.Cli/Program.cs
301
+ - helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTestBase.cs
302
+ - helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTests.DotNetToolsJson.cs
303
+ - helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTests.GlobalJson.cs
304
+ - helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTests.PackagesConfig.cs
305
+ - helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTests.Project.cs
306
+ - helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/DiscoveryWorkerTests.cs
307
+ - helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/ExpectedDiscoveryResults.cs
298
308
  - helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Files/DotNetToolsJsonBuildFileTests.cs
299
309
  - helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Files/GlobalJsonBuildFileTests.cs
300
310
  - helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Files/PackagesConfigBuildFileTests.cs
@@ -313,11 +323,28 @@ files:
313
323
  - helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.Mixed.cs
314
324
  - helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.PackagesConfig.cs
315
325
  - helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Update/UpdateWorkerTests.Sdk.cs
326
+ - helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Utilities/AssertEx.cs
327
+ - helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Utilities/DiffUtil.cs
316
328
  - helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Utilities/JsonHelperTests.cs
317
329
  - helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Utilities/MSBuildHelperTests.cs
318
330
  - helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Utilities/SdkPackageUpdaterHelperTests.cs
319
331
  - helpers/lib/NuGetUpdater/NuGetUpdater.Core/Dependency.cs
320
332
  - helpers/lib/NuGetUpdater/NuGetUpdater.Core/DependencyType.cs
333
+ - helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/DirectoryPackagesPropsDiscovery.cs
334
+ - helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/DirectoryPackagesPropsDiscoveryResult.cs
335
+ - helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/DiscoveryWorker.cs
336
+ - helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/DotNetToolsJsonDiscovery.cs
337
+ - helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/DotNetToolsJsonDiscoveryResult.cs
338
+ - helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/GlobalJsonDiscovery.cs
339
+ - helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/GlobalJsonDiscoveryResult.cs
340
+ - helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/IDiscoveryResult.cs
341
+ - helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/PackagesConfigDiscovery.cs
342
+ - helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/PackagesConfigDiscoveryResult.cs
343
+ - helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/ProjectDiscoveryResult.cs
344
+ - helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/SdkProjectDiscovery.cs
345
+ - helpers/lib/NuGetUpdater/NuGetUpdater.Core/Discover/WorkspaceDiscoveryResult.cs
346
+ - helpers/lib/NuGetUpdater/NuGetUpdater.Core/EvaluationResult.cs
347
+ - helpers/lib/NuGetUpdater/NuGetUpdater.Core/EvaluationResultType.cs
321
348
  - helpers/lib/NuGetUpdater/NuGetUpdater.Core/Files/BuildFile.cs
322
349
  - helpers/lib/NuGetUpdater/NuGetUpdater.Core/Files/DotNetToolsJsonBuildFile.cs
323
350
  - helpers/lib/NuGetUpdater/NuGetUpdater.Core/Files/GlobalJsonBuildFile.cs
@@ -329,6 +356,7 @@ files:
329
356
  - helpers/lib/NuGetUpdater/NuGetUpdater.Core/FrameworkChecker/FrameworkCompatibilityService.cs
330
357
  - helpers/lib/NuGetUpdater/NuGetUpdater.Core/FrameworkChecker/SupportedFrameworks.cs
331
358
  - helpers/lib/NuGetUpdater/NuGetUpdater.Core/NuGetUpdater.Core.csproj
359
+ - helpers/lib/NuGetUpdater/NuGetUpdater.Core/Property.cs
332
360
  - helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/BindingRedirectManager.cs
333
361
  - helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/BindingRedirectResolver.cs
334
362
  - helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/ConfigurationFile.cs
@@ -340,6 +368,8 @@ files:
340
368
  - helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/UpdaterWorker.cs
341
369
  - helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/WebApplicationTargetsConditionPatcher.cs
342
370
  - helpers/lib/NuGetUpdater/NuGetUpdater.Core/Updater/XmlFilePreAndPostProcessor.cs
371
+ - helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/HashSetExtensions.cs
372
+ - helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/ImmutableArrayExtensions.cs
343
373
  - helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/JsonHelper.cs
344
374
  - helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/Logger.cs
345
375
  - helpers/lib/NuGetUpdater/NuGetUpdater.Core/Utilities/MSBuildHelper.cs
@@ -351,17 +381,19 @@ files:
351
381
  - helpers/lib/NuGetUpdater/xunit.runner.json
352
382
  - lib/dependabot/nuget.rb
353
383
  - lib/dependabot/nuget/cache_manager.rb
384
+ - lib/dependabot/nuget/discovery/dependency_details.rb
385
+ - lib/dependabot/nuget/discovery/dependency_file_discovery.rb
386
+ - lib/dependabot/nuget/discovery/directory_packages_props_discovery.rb
387
+ - lib/dependabot/nuget/discovery/discovery_json_reader.rb
388
+ - lib/dependabot/nuget/discovery/evaluation_details.rb
389
+ - lib/dependabot/nuget/discovery/project_discovery.rb
390
+ - lib/dependabot/nuget/discovery/property_details.rb
391
+ - lib/dependabot/nuget/discovery/workspace_discovery.rb
354
392
  - lib/dependabot/nuget/file_fetcher.rb
355
393
  - lib/dependabot/nuget/file_fetcher/import_paths_finder.rb
356
394
  - lib/dependabot/nuget/file_fetcher/sln_project_paths_finder.rb
357
395
  - lib/dependabot/nuget/file_parser.rb
358
- - lib/dependabot/nuget/file_parser/dotnet_tools_json_parser.rb
359
- - lib/dependabot/nuget/file_parser/global_json_parser.rb
360
- - lib/dependabot/nuget/file_parser/packages_config_parser.rb
361
- - lib/dependabot/nuget/file_parser/project_file_parser.rb
362
- - lib/dependabot/nuget/file_parser/property_value_finder.rb
363
396
  - lib/dependabot/nuget/file_updater.rb
364
- - lib/dependabot/nuget/file_updater/property_value_updater.rb
365
397
  - lib/dependabot/nuget/http_response_helpers.rb
366
398
  - lib/dependabot/nuget/metadata_finder.rb
367
399
  - lib/dependabot/nuget/native_helpers.rb
@@ -385,7 +417,7 @@ licenses:
385
417
  - Nonstandard
386
418
  metadata:
387
419
  bug_tracker_uri: https://github.com/dependabot/dependabot-core/issues
388
- changelog_uri: https://github.com/dependabot/dependabot-core/releases/tag/v0.250.0
420
+ changelog_uri: https://github.com/dependabot/dependabot-core/releases/tag/v0.252.0
389
421
  post_install_message:
390
422
  rdoc_options: []
391
423
  require_paths:
@@ -1,71 +0,0 @@
1
- # typed: strict
2
- # frozen_string_literal: true
3
-
4
- require "json"
5
- require "sorbet-runtime"
6
-
7
- require "dependabot/dependency"
8
- require "dependabot/nuget/file_parser"
9
-
10
- # For details on dotnet-tools.json files see:
11
- # https://learn.microsoft.com/en-us/dotnet/core/tools/local-tools-how-to-use
12
- module Dependabot
13
- module Nuget
14
- class FileParser
15
- class DotNetToolsJsonParser
16
- extend T::Sig
17
-
18
- require "dependabot/file_parsers/base/dependency_set"
19
-
20
- sig { params(dotnet_tools_json: Dependabot::DependencyFile).void }
21
- def initialize(dotnet_tools_json:)
22
- @dotnet_tools_json = dotnet_tools_json
23
- @parsed_dotnet_tools_json = T.let(nil, T.nilable(T::Hash[String, T.untyped]))
24
- end
25
-
26
- sig { returns(Dependabot::FileParsers::Base::DependencySet) }
27
- def dependency_set
28
- dependency_set = Dependabot::FileParsers::Base::DependencySet.new
29
-
30
- tools = parsed_dotnet_tools_json.fetch("tools", {})
31
-
32
- raise Dependabot::DependencyFileNotParseable, dotnet_tools_json.path unless tools.is_a?(Hash)
33
-
34
- tools.each do |dependency_name, node|
35
- raise Dependabot::DependencyFileNotParseable, dotnet_tools_json.path unless node.is_a?(Hash)
36
-
37
- version = node["version"]
38
- dependency_set <<
39
- Dependency.new(
40
- name: dependency_name,
41
- version: version,
42
- package_manager: "nuget",
43
- requirements: [{
44
- requirement: version,
45
- file: dotnet_tools_json.name,
46
- groups: ["dependencies"],
47
- source: nil
48
- }]
49
- )
50
- end
51
-
52
- dependency_set
53
- end
54
-
55
- private
56
-
57
- sig { returns(Dependabot::DependencyFile) }
58
- attr_reader :dotnet_tools_json
59
-
60
- sig { returns(T::Hash[String, T.untyped]) }
61
- def parsed_dotnet_tools_json
62
- # Remove BOM if present as JSON should be UTF-8
63
- content = T.must(dotnet_tools_json.content)
64
- @parsed_dotnet_tools_json ||= JSON.parse(content.delete_prefix("\uFEFF"))
65
- rescue JSON::ParserError
66
- raise Dependabot::DependencyFileNotParseable, dotnet_tools_json.path
67
- end
68
- end
69
- end
70
- end
71
- end
@@ -1,68 +0,0 @@
1
- # typed: strict
2
- # frozen_string_literal: true
3
-
4
- require "json"
5
- require "sorbet-runtime"
6
-
7
- require "dependabot/dependency"
8
- require "dependabot/nuget/file_parser"
9
-
10
- # For details on global.json files see:
11
- # https://docs.microsoft.com/en-us/dotnet/core/tools/global-json
12
- module Dependabot
13
- module Nuget
14
- class FileParser
15
- class GlobalJsonParser
16
- extend T::Sig
17
-
18
- require "dependabot/file_parsers/base/dependency_set"
19
-
20
- sig { params(global_json: Dependabot::DependencyFile).void }
21
- def initialize(global_json:)
22
- @global_json = global_json
23
- @parsed_global_json = T.let(nil, T.nilable(T::Hash[String, T.untyped]))
24
- end
25
-
26
- sig { returns(Dependabot::FileParsers::Base::DependencySet) }
27
- def dependency_set
28
- dependency_set = Dependabot::FileParsers::Base::DependencySet.new
29
-
30
- project_sdks = parsed_global_json.fetch("msbuild-sdks", {})
31
-
32
- raise Dependabot::DependencyFileNotParseable, global_json.path unless project_sdks.is_a?(Hash)
33
-
34
- project_sdks.each do |dependency_name, version|
35
- dependency_set <<
36
- Dependency.new(
37
- name: dependency_name,
38
- version: version,
39
- package_manager: "nuget",
40
- requirements: [{
41
- requirement: version,
42
- file: global_json.name,
43
- groups: ["dependencies"],
44
- source: nil
45
- }]
46
- )
47
- end
48
-
49
- dependency_set
50
- end
51
-
52
- private
53
-
54
- sig { returns(Dependabot::DependencyFile) }
55
- attr_reader :global_json
56
-
57
- sig { returns(T::Hash[String, T.untyped]) }
58
- def parsed_global_json
59
- # Remove BOM if present as JSON should be UTF-8
60
- content = T.must(global_json.content)
61
- @parsed_global_json ||= JSON.parse(content.delete_prefix("\uFEFF"))
62
- rescue JSON::ParserError
63
- raise Dependabot::DependencyFileNotParseable, global_json.path
64
- end
65
- end
66
- end
67
- end
68
- end
@@ -1,92 +0,0 @@
1
- # typed: strict
2
- # frozen_string_literal: true
3
-
4
- require "nokogiri"
5
- require "sorbet-runtime"
6
-
7
- require "dependabot/dependency"
8
- require "dependabot/nuget/file_parser"
9
- require "dependabot/nuget/cache_manager"
10
-
11
- # For details on packages.config files see:
12
- # https://docs.microsoft.com/en-us/nuget/reference/packages-config
13
- module Dependabot
14
- module Nuget
15
- class FileParser
16
- class PackagesConfigParser
17
- extend T::Sig
18
- require "dependabot/file_parsers/base/dependency_set"
19
-
20
- DEPENDENCY_SELECTOR = "packages > package"
21
-
22
- sig { returns(T::Hash[String, Dependabot::FileParsers::Base::DependencySet]) }
23
- def self.dependency_set_cache
24
- CacheManager.cache("packages_config_dependency_set")
25
- end
26
-
27
- sig { params(packages_config: Dependabot::DependencyFile).void }
28
- def initialize(packages_config:)
29
- @packages_config = packages_config
30
- end
31
-
32
- sig { returns(Dependabot::FileParsers::Base::DependencySet) }
33
- def dependency_set
34
- key = "#{packages_config.name.downcase}::#{packages_config.content.hash}"
35
- cache = PackagesConfigParser.dependency_set_cache
36
-
37
- cache[key] ||= parse_dependencies
38
- end
39
-
40
- private
41
-
42
- sig { returns(Dependabot::DependencyFile) }
43
- attr_reader :packages_config
44
-
45
- sig { returns(Dependabot::FileParsers::Base::DependencySet) }
46
- def parse_dependencies
47
- dependency_set = Dependabot::FileParsers::Base::DependencySet.new
48
-
49
- doc = Nokogiri::XML(packages_config.content)
50
- doc.remove_namespaces!
51
- doc.css(DEPENDENCY_SELECTOR).each do |dependency_node|
52
- dependency_set <<
53
- Dependency.new(
54
- name: T.must(dependency_name(dependency_node)),
55
- version: dependency_version(dependency_node),
56
- package_manager: "nuget",
57
- requirements: [{
58
- requirement: dependency_version(dependency_node),
59
- file: packages_config.name,
60
- groups: [dependency_type(dependency_node)],
61
- source: nil
62
- }]
63
- )
64
- end
65
-
66
- dependency_set
67
- end
68
-
69
- sig { params(dependency_node: Nokogiri::XML::Node).returns(T.nilable(String)) }
70
- def dependency_name(dependency_node)
71
- dependency_node.attribute("id")&.value&.strip ||
72
- dependency_node.at_xpath("./id")&.content&.strip
73
- end
74
-
75
- sig { params(dependency_node: Nokogiri::XML::Node).returns(T.nilable(String)) }
76
- def dependency_version(dependency_node)
77
- # Ranges and wildcards aren't allowed in a packages.config - the
78
- # specified requirement is always an exact version.
79
- dependency_node.attribute("version")&.value&.strip ||
80
- dependency_node.at_xpath("./version")&.content&.strip
81
- end
82
-
83
- sig { params(dependency_node: Nokogiri::XML::Node).returns(String) }
84
- def dependency_type(dependency_node)
85
- val = dependency_node.attribute("developmentDependency")&.value&.strip ||
86
- dependency_node.at_xpath("./developmentDependency")&.content&.strip
87
- val.to_s.casecmp("true").zero? ? "devDependencies" : "dependencies"
88
- end
89
- end
90
- end
91
- end
92
- end