dependabot-common 0.120.3 → 0.122.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of dependabot-common might be problematic. Click here for more details.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0cb8d42beb59f598224b8eeabe01953e3feb92f61e63231ae2e6842f1d848269
|
4
|
+
data.tar.gz: 5a89adfdc3206b73f54a7fc3d72dcb04c18524d6becdb910f9de5f89bbcb8ae3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e97880807e925c059b3b48c9835f70981536b49b82a2e912c8d288fc19d46cb3e705c23a43cd31b3db626249f3383e95bbb334512cc4a7c834b625047c5d6640
|
7
|
+
data.tar.gz: 2f257b6b8e0344bd3992695fb6594702ec6df167f41043f450e22a6719907042286c0fb5f55cf8071d067f705aa4f24a57a9387c0937ea7f9e9f9754ab043f2f
|
@@ -14,7 +14,7 @@ require "dependabot/shared_helpers"
|
|
14
14
|
module Dependabot
|
15
15
|
module FileFetchers
|
16
16
|
class Base
|
17
|
-
attr_reader :source, :credentials
|
17
|
+
attr_reader :source, :credentials, :repo_contents_path
|
18
18
|
|
19
19
|
CLIENT_NOT_FOUND_ERRORS = [
|
20
20
|
Octokit::NotFound,
|
@@ -32,10 +32,19 @@ module Dependabot
|
|
32
32
|
raise NotImplementedError
|
33
33
|
end
|
34
34
|
|
35
|
-
|
35
|
+
# Creates a new FileFetcher for retrieving `DependencyFile`s.
|
36
|
+
#
|
37
|
+
# Files are typically grabbed individually via the source's API.
|
38
|
+
# repo_contents_path is an optional empty directory that will be used
|
39
|
+
# to clone the entire source repository on first read.
|
40
|
+
#
|
41
|
+
# If provided, file _data_ will be loaded from the clone.
|
42
|
+
# Submodules and directory listings are _not_ currently supported
|
43
|
+
# by repo_contents_path and still use an API trip.
|
44
|
+
def initialize(source:, credentials:, repo_contents_path: nil)
|
36
45
|
@source = source
|
37
46
|
@credentials = credentials
|
38
|
-
|
47
|
+
@repo_contents_path = repo_contents_path
|
39
48
|
@linked_paths = {}
|
40
49
|
end
|
41
50
|
|
@@ -68,14 +77,24 @@ module Dependabot
|
|
68
77
|
end
|
69
78
|
|
70
79
|
# Returns the path to the cloned repo
|
71
|
-
def clone_repo_contents
|
80
|
+
def clone_repo_contents
|
72
81
|
@clone_repo_contents ||=
|
73
|
-
_clone_repo_contents(target_directory:
|
82
|
+
_clone_repo_contents(target_directory: repo_contents_path)
|
83
|
+
rescue Dependabot::SharedHelpers::HelperSubprocessFailed
|
84
|
+
raise Dependabot::RepoNotFound, source
|
74
85
|
end
|
75
86
|
|
76
87
|
private
|
77
88
|
|
78
89
|
def fetch_file_if_present(filename, fetch_submodules: false)
|
90
|
+
unless repo_contents_path.nil?
|
91
|
+
begin
|
92
|
+
return load_cloned_file_if_present(filename)
|
93
|
+
rescue Dependabot::DependencyFileNotFound
|
94
|
+
return
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
79
98
|
dir = File.dirname(filename)
|
80
99
|
basename = File.basename(filename)
|
81
100
|
|
@@ -91,7 +110,35 @@ module Dependabot
|
|
91
110
|
raise Dependabot::DependencyFileNotFound, path
|
92
111
|
end
|
93
112
|
|
113
|
+
def load_cloned_file_if_present(filename)
|
114
|
+
path = Pathname.new(File.join(directory, filename)).cleanpath.to_path
|
115
|
+
repo_path = File.join(clone_repo_contents, path)
|
116
|
+
unless File.exist?(repo_path)
|
117
|
+
raise Dependabot::DependencyFileNotFound, path
|
118
|
+
end
|
119
|
+
|
120
|
+
content = File.read(repo_path)
|
121
|
+
type = if File.symlink?(repo_path)
|
122
|
+
symlink_target = File.readlink(repo_path)
|
123
|
+
"symlink"
|
124
|
+
else
|
125
|
+
"file"
|
126
|
+
end
|
127
|
+
|
128
|
+
DependencyFile.new(
|
129
|
+
name: Pathname.new(filename).cleanpath.to_path,
|
130
|
+
directory: directory,
|
131
|
+
type: type,
|
132
|
+
content: content,
|
133
|
+
symlink_target: symlink_target
|
134
|
+
)
|
135
|
+
end
|
136
|
+
|
94
137
|
def fetch_file_from_host(filename, type: "file", fetch_submodules: false)
|
138
|
+
unless repo_contents_path.nil?
|
139
|
+
return load_cloned_file_if_present(filename)
|
140
|
+
end
|
141
|
+
|
95
142
|
path = Pathname.new(File.join(directory, filename)).cleanpath.to_path
|
96
143
|
content = _fetch_file_content(path, fetch_submodules: fetch_submodules)
|
97
144
|
type = @linked_paths.key?(path.gsub(%r{^/}, "")) ? "symlink" : type
|
@@ -4,18 +4,19 @@ module Dependabot
|
|
4
4
|
module FileUpdaters
|
5
5
|
class Base
|
6
6
|
attr_reader :dependencies, :dependency_files, :repo_contents_path,
|
7
|
-
:credentials
|
7
|
+
:credentials, :options
|
8
8
|
|
9
9
|
def self.updated_files_regex
|
10
10
|
raise NotImplementedError
|
11
11
|
end
|
12
12
|
|
13
13
|
def initialize(dependencies:, dependency_files:, repo_contents_path: nil,
|
14
|
-
credentials:)
|
14
|
+
credentials:, options: {})
|
15
15
|
@dependencies = dependencies
|
16
16
|
@dependency_files = dependency_files
|
17
17
|
@repo_contents_path = repo_contents_path
|
18
18
|
@credentials = credentials
|
19
|
+
@options = options
|
19
20
|
|
20
21
|
check_required_files
|
21
22
|
end
|
@@ -0,0 +1,86 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "dependabot/dependency_file"
|
4
|
+
|
5
|
+
module Dependabot
|
6
|
+
module FileUpdaters
|
7
|
+
class VendorUpdater
|
8
|
+
# notable filenames without a reliable extension:
|
9
|
+
TEXT_FILE_NAMES = [
|
10
|
+
"README",
|
11
|
+
"LICENSE",
|
12
|
+
"Gemfile",
|
13
|
+
"Gemfile.lock",
|
14
|
+
".bundlecache",
|
15
|
+
".gitignore"
|
16
|
+
].freeze
|
17
|
+
|
18
|
+
TEXT_FILE_EXTS = [
|
19
|
+
# code
|
20
|
+
".rb",
|
21
|
+
".erb",
|
22
|
+
".gemspec",
|
23
|
+
".js",
|
24
|
+
".html",
|
25
|
+
# config
|
26
|
+
".json",
|
27
|
+
".xml",
|
28
|
+
".toml",
|
29
|
+
".yaml",
|
30
|
+
".yml",
|
31
|
+
# docs
|
32
|
+
".md",
|
33
|
+
".txt",
|
34
|
+
".go"
|
35
|
+
].freeze
|
36
|
+
|
37
|
+
def initialize(repo_contents_path:, vendor_dir:)
|
38
|
+
@repo_contents_path = repo_contents_path
|
39
|
+
@vendor_dir = vendor_dir
|
40
|
+
end
|
41
|
+
|
42
|
+
# Returns changed files in the vendor/cache folder
|
43
|
+
#
|
44
|
+
# @param base_directory [String] Update config base directory
|
45
|
+
# @return [Array<Dependabot::DependencyFile>]
|
46
|
+
def updated_vendor_cache_files(base_directory:)
|
47
|
+
return [] unless repo_contents_path && vendor_dir
|
48
|
+
|
49
|
+
Dir.chdir(repo_contents_path) do
|
50
|
+
relative_dir = vendor_dir.sub("#{repo_contents_path}/", "")
|
51
|
+
status = SharedHelpers.run_shell_command(
|
52
|
+
"git status --untracked-files=all --porcelain=v1 #{relative_dir}"
|
53
|
+
)
|
54
|
+
changed_paths = status.split("\n").map { |l| l.split(" ") }
|
55
|
+
changed_paths.map do |type, path|
|
56
|
+
deleted = type == "D"
|
57
|
+
encoding = ""
|
58
|
+
encoded_content = File.read(path) unless deleted
|
59
|
+
if binary_file?(path)
|
60
|
+
encoding = Dependabot::DependencyFile::ContentEncoding::BASE64
|
61
|
+
encoded_content = Base64.encode64(encoded_content) unless deleted
|
62
|
+
end
|
63
|
+
Dependabot::DependencyFile.new(
|
64
|
+
name: path,
|
65
|
+
content: encoded_content,
|
66
|
+
directory: base_directory,
|
67
|
+
deleted: deleted,
|
68
|
+
content_encoding: encoding
|
69
|
+
)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
private
|
75
|
+
|
76
|
+
attr_reader :repo_contents_path, :vendor_dir
|
77
|
+
|
78
|
+
def binary_file?(path)
|
79
|
+
return false if TEXT_FILE_NAMES.include?(File.basename(path))
|
80
|
+
return false if TEXT_FILE_EXTS.include?(File.extname(path))
|
81
|
+
|
82
|
+
true
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
data/lib/dependabot/utils.rb
CHANGED
@@ -29,5 +29,15 @@ module Dependabot
|
|
29
29
|
def self.register_requirement_class(package_manager, requirement_class)
|
30
30
|
@requirement_classes[package_manager] = requirement_class
|
31
31
|
end
|
32
|
+
|
33
|
+
@cloning_package_managers = Set[]
|
34
|
+
|
35
|
+
def self.always_clone_for_package_manager?(package_manager)
|
36
|
+
@cloning_package_managers.include?(package_manager)
|
37
|
+
end
|
38
|
+
|
39
|
+
def self.register_always_clone(package_manager)
|
40
|
+
@cloning_package_managers << package_manager
|
41
|
+
end
|
32
42
|
end
|
33
43
|
end
|
data/lib/dependabot/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dependabot-common
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.122.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dependabot
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-10-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk-codecommit
|
@@ -292,14 +292,42 @@ dependencies:
|
|
292
292
|
requirements:
|
293
293
|
- - "~>"
|
294
294
|
- !ruby/object:Gem::Version
|
295
|
-
version: 0.
|
295
|
+
version: 0.92.0
|
296
296
|
type: :development
|
297
297
|
prerelease: false
|
298
298
|
version_requirements: !ruby/object:Gem::Requirement
|
299
299
|
requirements:
|
300
300
|
- - "~>"
|
301
301
|
- !ruby/object:Gem::Version
|
302
|
-
version: 0.
|
302
|
+
version: 0.92.0
|
303
|
+
- !ruby/object:Gem::Dependency
|
304
|
+
name: simplecov
|
305
|
+
requirement: !ruby/object:Gem::Requirement
|
306
|
+
requirements:
|
307
|
+
- - "~>"
|
308
|
+
- !ruby/object:Gem::Version
|
309
|
+
version: 0.19.0
|
310
|
+
type: :development
|
311
|
+
prerelease: false
|
312
|
+
version_requirements: !ruby/object:Gem::Requirement
|
313
|
+
requirements:
|
314
|
+
- - "~>"
|
315
|
+
- !ruby/object:Gem::Version
|
316
|
+
version: 0.19.0
|
317
|
+
- !ruby/object:Gem::Dependency
|
318
|
+
name: simplecov-console
|
319
|
+
requirement: !ruby/object:Gem::Requirement
|
320
|
+
requirements:
|
321
|
+
- - "~>"
|
322
|
+
- !ruby/object:Gem::Version
|
323
|
+
version: 0.7.2
|
324
|
+
type: :development
|
325
|
+
prerelease: false
|
326
|
+
version_requirements: !ruby/object:Gem::Requirement
|
327
|
+
requirements:
|
328
|
+
- - "~>"
|
329
|
+
- !ruby/object:Gem::Version
|
330
|
+
version: 0.7.2
|
303
331
|
- !ruby/object:Gem::Dependency
|
304
332
|
name: vcr
|
305
333
|
requirement: !ruby/object:Gem::Requirement
|
@@ -356,6 +384,7 @@ files:
|
|
356
384
|
- lib/dependabot/file_updaters.rb
|
357
385
|
- lib/dependabot/file_updaters/README.md
|
358
386
|
- lib/dependabot/file_updaters/base.rb
|
387
|
+
- lib/dependabot/file_updaters/vendor_updater.rb
|
359
388
|
- lib/dependabot/git_commit_checker.rb
|
360
389
|
- lib/dependabot/git_metadata_fetcher.rb
|
361
390
|
- lib/dependabot/metadata_finders.rb
|