dependabot-composer 0.103.0 → 0.103.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3083a8f3347ae0158c14b6d01a35c3bff89456b2ecd143cd56d8525ec9ad44bf
4
- data.tar.gz: 0e316e6d184ed6b0ac8be4d53ab0d36db9aa40dc0ce4f7d192bdf3a94b2a14e0
3
+ metadata.gz: 8a00f0b1d602746a20b3eb2cac2a4c244e4825eca5609d1437da9c887c7f9c9d
4
+ data.tar.gz: b53978ab4a8106a365cf9bdb4258f8e8f2d3b6f5b88374b2a31f3fd09c783830
5
5
  SHA512:
6
- metadata.gz: 35efb0f0daffb7f0da63584dd6724fdce4a4ecf988226e93f352c01ee3d70cbd3114191d62561966c228e7414a8c8713ca6f137b23624b51cc5be895eec695d3
7
- data.tar.gz: ce7d49889b2fd4133877f68c56f115db8af64c1c886f0e17201b0829a781edbdacf3ac8358d95628def7b8a28cf034a50676195cee421e55aed4a8cca5c4f199
6
+ metadata.gz: 44aacb1a8124e4afc26fb5a6288f05f47dd68b2823c9991000d6567ed85807c9267dd0270d6a9509c3da95abd43ab7181e6d105cc53a3d10f65dd3f186dcb298
7
+ data.tar.gz: 57a7ae70391187a9d057f00d48c05bb62b1612c37d2b628f799bcae0017c515773390dd7fbe7098524f0be163488b98508425b51234d8c2f6207777187191bb7
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "json"
3
4
  require "dependabot/file_fetchers"
4
5
  require "dependabot/file_fetchers/base"
5
6
 
@@ -59,7 +60,7 @@ module Dependabot
59
60
  begin
60
61
  composer_json_files << fetch_file_with_root_fallback(file)
61
62
  rescue Dependabot::DependencyFileNotFound
62
- unfetchable_deps << path
63
+ unfetchable_deps << dir
63
64
  end
64
65
  end
65
66
  end
@@ -99,22 +100,29 @@ module Dependabot
99
100
  select { |file| file.type == "dir" }.
100
101
  map { |f| path.gsub(/\*$/, f.name) }
101
102
  rescue Octokit::NotFound, Gitlab::Error::NotFound
102
- # If there's no lockfile, or if none of the dependencies are path
103
- # dependencies, then we can ignore failures to find path deps
104
- return [] unless composer_lock&.content&.include?('"path"')
103
+ lockfile_path_dependency_paths.
104
+ select { |p| p.to_s.start_with?(path.gsub(/\*$/, "")) }
105
+ end
105
106
 
106
- # Otherwise, we don't know what to do. For now, just raise. If we see
107
- # this in the wild we can make a call on the correct handling
108
- raise if directory == "/"
107
+ def lockfile_path_dependency_paths
108
+ keys = FileParser::DEPENDENCY_GROUP_KEYS.
109
+ map { |h| h.fetch(:lockfile) }
109
110
 
110
- # If the directory isn't found at the full path, try looking for it
111
- # at the root of the repository.
112
- depth = directory.gsub(%r{^/}, "").gsub(%r{/$}, "").split("/").count
113
- dir = "../" * depth + path.gsub(/\*$/, "").gsub(/^\.*/, "")
111
+ keys.flat_map do |key|
112
+ next [] unless parsed_lockfile[key]
114
113
 
115
- repo_contents(dir: dir).
116
- select { |file| file.type == "dir" }.
117
- map { |f| path.gsub(/\*$/, f.name) }
114
+ parsed_lockfile[key].
115
+ select { |details| details.dig("dist", "type") == "path" }.
116
+ map { |details| details.dig("dist", "url") }
117
+ end
118
+ end
119
+
120
+ def parsed_lockfile
121
+ return {} unless composer_lock
122
+
123
+ @parsed_lockfile ||= JSON.parse(composer_lock.content)
124
+ rescue JSON::ParserError
125
+ {}
118
126
  end
119
127
 
120
128
  def fetch_file_with_root_fallback(filename)
@@ -125,7 +133,7 @@ module Dependabot
125
133
  rescue Dependabot::DependencyFileNotFound
126
134
  # If the file isn't found at the full path, try looking for it
127
135
  # without considering the directory (i.e., check if the path should
128
- # have been relevative to the root of the repository).
136
+ # have been relative to the root of the repository).
129
137
  cleaned_filename = filename.gsub(/^\./, "")
130
138
  cleaned_filename = Pathname.new(cleaned_filename).cleanpath.to_path
131
139
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dependabot-composer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.103.0
4
+ version: 0.103.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dependabot
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 0.103.0
19
+ version: 0.103.1
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.103.0
26
+ version: 0.103.1
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: byebug
29
29
  requirement: !ruby/object:Gem::Requirement