bibliothecary 8.7.4 → 8.7.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +21 -4
- data/.rubocop.yml +32 -941
- data/Gemfile +1 -1
- data/Rakefile +10 -0
- data/bibliothecary.gemspec +2 -2
- data/lib/bibliothecary/analyser.rb +6 -6
- data/lib/bibliothecary/cli.rb +8 -8
- data/lib/bibliothecary/configuration.rb +8 -8
- data/lib/bibliothecary/file_info.rb +2 -2
- data/lib/bibliothecary/multi_parsers/bundler_like_manifest.rb +1 -1
- data/lib/bibliothecary/multi_parsers/cyclonedx.rb +16 -17
- data/lib/bibliothecary/multi_parsers/dependencies_csv.rb +16 -16
- data/lib/bibliothecary/multi_parsers/json_runtime.rb +3 -3
- data/lib/bibliothecary/multi_parsers/spdx.rb +14 -14
- data/lib/bibliothecary/parsers/bower.rb +7 -7
- data/lib/bibliothecary/parsers/cargo.rb +15 -15
- data/lib/bibliothecary/parsers/carthage.rb +16 -16
- data/lib/bibliothecary/parsers/clojars.rb +7 -7
- data/lib/bibliothecary/parsers/cocoapods.rb +20 -20
- data/lib/bibliothecary/parsers/conda.rb +9 -9
- data/lib/bibliothecary/parsers/cpan.rb +12 -12
- data/lib/bibliothecary/parsers/cran.rb +12 -12
- data/lib/bibliothecary/parsers/dub.rb +8 -8
- data/lib/bibliothecary/parsers/elm.rb +8 -8
- data/lib/bibliothecary/parsers/go.rb +131 -66
- data/lib/bibliothecary/parsers/hackage.rb +13 -13
- data/lib/bibliothecary/parsers/haxelib.rb +4 -4
- data/lib/bibliothecary/parsers/hex.rb +11 -11
- data/lib/bibliothecary/parsers/julia.rb +4 -4
- data/lib/bibliothecary/parsers/maven.rb +88 -89
- data/lib/bibliothecary/parsers/meteor.rb +4 -4
- data/lib/bibliothecary/parsers/npm.rb +31 -31
- data/lib/bibliothecary/parsers/nuget.rb +44 -44
- data/lib/bibliothecary/parsers/packagist.rb +14 -14
- data/lib/bibliothecary/parsers/pub.rb +13 -13
- data/lib/bibliothecary/parsers/pypi.rb +71 -71
- data/lib/bibliothecary/parsers/rubygems.rb +15 -15
- data/lib/bibliothecary/parsers/shard.rb +13 -13
- data/lib/bibliothecary/parsers/swift_pm.rb +6 -6
- data/lib/bibliothecary/purl_util.rb +1 -1
- data/lib/bibliothecary/runner.rb +4 -4
- data/lib/bibliothecary/version.rb +1 -1
- data/lib/bibliothecary.rb +3 -3
- data/lib/sdl_parser.rb +5 -5
- metadata +2 -2
@@ -15,73 +15,73 @@ module Bibliothecary
|
|
15
15
|
PIP_COMPILE_REGEXP = /.*require.*$/
|
16
16
|
|
17
17
|
# Adapted from https://peps.python.org/pep-0508/#names
|
18
|
-
|
18
|
+
PEP_508_NAME_REGEXP = /^([A-Z0-9][A-Z0-9._-]*[A-Z0-9]|[A-Z0-9])/i
|
19
19
|
|
20
20
|
def self.mapping
|
21
21
|
{
|
22
|
-
match_filenames(
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
kind:
|
27
|
-
parser: :parse_requirements_txt
|
22
|
+
match_filenames("requirements-dev.txt", "requirements/dev.txt",
|
23
|
+
"requirements-docs.txt", "requirements/docs.txt",
|
24
|
+
"requirements-test.txt", "requirements/test.txt",
|
25
|
+
"requirements-tools.txt", "requirements/tools.txt") => {
|
26
|
+
kind: "manifest",
|
27
|
+
parser: :parse_requirements_txt,
|
28
28
|
},
|
29
29
|
lambda { |p| PIP_COMPILE_REGEXP.match(p) } => {
|
30
30
|
content_matcher: :pip_compile?,
|
31
|
-
kind:
|
32
|
-
parser: :parse_requirements_txt
|
31
|
+
kind: "lockfile",
|
32
|
+
parser: :parse_requirements_txt,
|
33
33
|
},
|
34
34
|
lambda { |p| MANIFEST_REGEXP.match(p) } => {
|
35
|
-
kind:
|
35
|
+
kind: "manifest",
|
36
36
|
parser: :parse_requirements_txt,
|
37
|
-
can_have_lockfile: false
|
37
|
+
can_have_lockfile: false,
|
38
38
|
},
|
39
|
-
match_filename(
|
39
|
+
match_filename("requirements.frozen") => { # pattern exists to store frozen deps in requirements.frozen
|
40
40
|
parser: :parse_requirements_txt,
|
41
|
-
kind:
|
41
|
+
kind: "lockfile",
|
42
42
|
},
|
43
|
-
match_filename(
|
44
|
-
kind:
|
45
|
-
parser: :parse_requirements_txt
|
43
|
+
match_filename("pip-resolved-dependencies.txt") => { # Inferred from pip
|
44
|
+
kind: "lockfile",
|
45
|
+
parser: :parse_requirements_txt,
|
46
46
|
},
|
47
47
|
match_filename("setup.py") => {
|
48
|
-
kind:
|
48
|
+
kind: "manifest",
|
49
49
|
parser: :parse_setup_py,
|
50
|
-
can_have_lockfile: false
|
50
|
+
can_have_lockfile: false,
|
51
51
|
},
|
52
52
|
match_filename("Pipfile") => {
|
53
|
-
kind:
|
54
|
-
parser: :parse_pipfile
|
53
|
+
kind: "manifest",
|
54
|
+
parser: :parse_pipfile,
|
55
55
|
},
|
56
56
|
match_filename("Pipfile.lock") => {
|
57
|
-
kind:
|
58
|
-
parser: :parse_pipfile_lock
|
57
|
+
kind: "lockfile",
|
58
|
+
parser: :parse_pipfile_lock,
|
59
59
|
},
|
60
60
|
match_filename("pyproject.toml") => {
|
61
|
-
kind:
|
62
|
-
parser: :parse_pyproject
|
61
|
+
kind: "manifest",
|
62
|
+
parser: :parse_pyproject,
|
63
63
|
},
|
64
64
|
match_filename("poetry.lock") => {
|
65
|
-
kind:
|
66
|
-
parser: :parse_poetry_lock
|
65
|
+
kind: "lockfile",
|
66
|
+
parser: :parse_poetry_lock,
|
67
67
|
},
|
68
68
|
# Pip dependencies can be embedded in conda environment files
|
69
69
|
match_filename("environment.yml") => {
|
70
70
|
parser: :parse_conda,
|
71
|
-
kind: "manifest"
|
71
|
+
kind: "manifest",
|
72
72
|
},
|
73
73
|
match_filename("environment.yaml") => {
|
74
74
|
parser: :parse_conda,
|
75
|
-
kind: "manifest"
|
75
|
+
kind: "manifest",
|
76
76
|
},
|
77
77
|
match_filename("environment.yml.lock") => {
|
78
78
|
parser: :parse_conda,
|
79
|
-
kind: "lockfile"
|
79
|
+
kind: "lockfile",
|
80
80
|
},
|
81
81
|
match_filename("environment.yaml.lock") => {
|
82
82
|
parser: :parse_conda,
|
83
|
-
kind: "lockfile"
|
84
|
-
}
|
83
|
+
kind: "lockfile",
|
84
|
+
},
|
85
85
|
}
|
86
86
|
end
|
87
87
|
|
@@ -89,21 +89,21 @@ module Bibliothecary
|
|
89
89
|
add_multi_parser(Bibliothecary::MultiParsers::DependenciesCSV)
|
90
90
|
add_multi_parser(Bibliothecary::MultiParsers::Spdx)
|
91
91
|
|
92
|
-
def self.parse_pipfile(file_contents, options: {})
|
92
|
+
def self.parse_pipfile(file_contents, options: {}) # rubocop:disable Lint/UnusedMethodArgument
|
93
93
|
manifest = Tomlrb.parse(file_contents)
|
94
|
-
map_dependencies(manifest[
|
94
|
+
map_dependencies(manifest["packages"], "runtime") + map_dependencies(manifest["dev-packages"], "develop")
|
95
95
|
end
|
96
96
|
|
97
|
-
def self.parse_pyproject(file_contents, options: {})
|
97
|
+
def self.parse_pyproject(file_contents, options: {}) # rubocop:disable Lint/UnusedMethodArgument
|
98
98
|
deps = []
|
99
99
|
|
100
100
|
file_contents = Tomlrb.parse(file_contents)
|
101
101
|
|
102
102
|
# Parse poetry [tool.poetry] deps
|
103
|
-
poetry_manifest = file_contents.fetch(
|
104
|
-
deps += map_dependencies(poetry_manifest[
|
103
|
+
poetry_manifest = file_contents.fetch("tool", {}).fetch("poetry", {})
|
104
|
+
deps += map_dependencies(poetry_manifest["dependencies"], "runtime")
|
105
105
|
# Poetry 1.0.0-1.2.0 way of defining dev deps
|
106
|
-
deps += map_dependencies(poetry_manifest[
|
106
|
+
deps += map_dependencies(poetry_manifest["dev-dependencies"], "develop")
|
107
107
|
# Poetry's 1.2.0+ of defining dev deps
|
108
108
|
poetry_manifest
|
109
109
|
.fetch("group", {})
|
@@ -113,9 +113,9 @@ module Bibliothecary
|
|
113
113
|
end
|
114
114
|
|
115
115
|
# Parse PEP621 [project] deps
|
116
|
-
pep621_manifest = file_contents.fetch(
|
117
|
-
pep621_deps = pep621_manifest.fetch(
|
118
|
-
deps += map_dependencies(pep621_deps,
|
116
|
+
pep621_manifest = file_contents.fetch("project", {})
|
117
|
+
pep621_deps = pep621_manifest.fetch("dependencies", []).map { |d| parse_pep_508_dep_spec(d) }
|
118
|
+
deps += map_dependencies(pep621_deps, "runtime")
|
119
119
|
|
120
120
|
# We're combining both poetry+PEP621 deps instead of making them mutually exclusive, until we
|
121
121
|
# find a reason not to ingest them both.
|
@@ -128,7 +128,7 @@ module Bibliothecary
|
|
128
128
|
parse_pyproject(file_contents, options)
|
129
129
|
end
|
130
130
|
|
131
|
-
def self.parse_conda(file_contents, options: {})
|
131
|
+
def self.parse_conda(file_contents, options: {}) # rubocop:disable Lint/UnusedMethodArgument
|
132
132
|
contents = YAML.safe_load(file_contents)
|
133
133
|
return [] unless contents
|
134
134
|
|
@@ -145,64 +145,64 @@ module Bibliothecary
|
|
145
145
|
{
|
146
146
|
name: name,
|
147
147
|
requirement: map_requirements(info),
|
148
|
-
type: type
|
148
|
+
type: type,
|
149
149
|
}
|
150
150
|
end
|
151
151
|
end
|
152
152
|
|
153
153
|
def self.map_requirements(info)
|
154
154
|
if info.is_a?(Hash)
|
155
|
-
if info[
|
156
|
-
info[
|
157
|
-
elsif info[
|
158
|
-
info[
|
155
|
+
if info["version"]
|
156
|
+
info["version"]
|
157
|
+
elsif info["git"]
|
158
|
+
info["git"] + "#" + info["ref"]
|
159
159
|
else
|
160
|
-
|
160
|
+
"*"
|
161
161
|
end
|
162
162
|
else
|
163
|
-
info ||
|
163
|
+
info || "*"
|
164
164
|
end
|
165
165
|
end
|
166
166
|
|
167
|
-
def self.parse_pipfile_lock(file_contents, options: {})
|
167
|
+
def self.parse_pipfile_lock(file_contents, options: {}) # rubocop:disable Lint/UnusedMethodArgument
|
168
168
|
manifest = JSON.parse(file_contents)
|
169
169
|
deps = []
|
170
170
|
manifest.each do |group, dependencies|
|
171
171
|
next if group == "_meta"
|
172
|
-
group =
|
172
|
+
group = "runtime" if group == "default"
|
173
173
|
dependencies.each do |name, info|
|
174
174
|
deps << {
|
175
175
|
name: name,
|
176
176
|
requirement: map_requirements(info),
|
177
|
-
type: group
|
177
|
+
type: group,
|
178
178
|
}
|
179
179
|
end
|
180
180
|
end
|
181
181
|
deps
|
182
182
|
end
|
183
183
|
|
184
|
-
def self.parse_poetry_lock(file_contents, options: {})
|
184
|
+
def self.parse_poetry_lock(file_contents, options: {}) # rubocop:disable Lint/UnusedMethodArgument
|
185
185
|
manifest = Tomlrb.parse(file_contents)
|
186
186
|
deps = []
|
187
187
|
manifest["package"].each do |package|
|
188
188
|
# next if group == "_meta"
|
189
|
-
group = case package[
|
190
|
-
when
|
191
|
-
|
189
|
+
group = case package["category"]
|
190
|
+
when "dev"
|
191
|
+
"develop"
|
192
192
|
else
|
193
|
-
|
193
|
+
"runtime"
|
194
194
|
end
|
195
195
|
|
196
196
|
deps << {
|
197
|
-
name: package[
|
197
|
+
name: package["name"],
|
198
198
|
requirement: map_requirements(package),
|
199
|
-
type: group
|
199
|
+
type: group,
|
200
200
|
}
|
201
201
|
end
|
202
202
|
deps
|
203
203
|
end
|
204
204
|
|
205
|
-
def self.parse_setup_py(file_contents, options: {})
|
205
|
+
def self.parse_setup_py(file_contents, options: {}) # rubocop:disable Lint/UnusedMethodArgument
|
206
206
|
match = file_contents.match(INSTALL_REGEXP)
|
207
207
|
return [] unless match
|
208
208
|
deps = []
|
@@ -212,8 +212,8 @@ module Bibliothecary
|
|
212
212
|
next unless match
|
213
213
|
deps << {
|
214
214
|
name: match[1],
|
215
|
-
requirement: match[-1] ||
|
216
|
-
type:
|
215
|
+
requirement: match[-1] || "*",
|
216
|
+
type: "runtime",
|
217
217
|
}
|
218
218
|
end
|
219
219
|
deps
|
@@ -229,22 +229,22 @@ module Bibliothecary
|
|
229
229
|
# https://pip.pypa.io/en/stable/cli/pip_install/#requirement-specifiers
|
230
230
|
# and https://pip.pypa.io/en/stable/topics/vcs-support/#git.
|
231
231
|
# Invalid lines in requirements.txt are skipped.
|
232
|
-
def self.parse_requirements_txt(file_contents, options: {})
|
232
|
+
def self.parse_requirements_txt(file_contents, options: {}) # rubocop:disable Lint/UnusedMethodArgument
|
233
233
|
deps = []
|
234
234
|
type = case options[:filename]
|
235
235
|
when /dev/ || /docs/ || /tools/
|
236
|
-
|
236
|
+
"development"
|
237
237
|
when /test/
|
238
|
-
|
238
|
+
"test"
|
239
239
|
else
|
240
|
-
|
240
|
+
"runtime"
|
241
241
|
end
|
242
242
|
|
243
243
|
file_contents.split("\n").each do |line|
|
244
|
-
if line[
|
244
|
+
if line["://"]
|
245
245
|
begin
|
246
246
|
result = parse_requirements_txt_url(line)
|
247
|
-
rescue URI::Error, NoEggSpecified
|
247
|
+
rescue URI::Error, NoEggSpecified
|
248
248
|
next
|
249
249
|
end
|
250
250
|
|
@@ -252,13 +252,13 @@ module Bibliothecary
|
|
252
252
|
type: type
|
253
253
|
)
|
254
254
|
else
|
255
|
-
match = line.delete(
|
255
|
+
match = line.delete(" ").match(REQUIREMENTS_REGEXP)
|
256
256
|
next unless match
|
257
257
|
|
258
258
|
deps << {
|
259
259
|
name: match[1],
|
260
|
-
requirement: match[-1] ||
|
261
|
-
type: type
|
260
|
+
requirement: match[-1] || "*",
|
261
|
+
type: type,
|
262
262
|
}
|
263
263
|
end
|
264
264
|
end
|
@@ -289,7 +289,7 @@ module Bibliothecary
|
|
289
289
|
# Simply parses out the name of a PEP 508 Dependency specification: https://peps.python.org/pep-0508/
|
290
290
|
# Leaves the rest as-is with any leading semicolons or spaces stripped
|
291
291
|
def self.parse_pep_508_dep_spec(dep)
|
292
|
-
name, requirement = dep.split(
|
292
|
+
name, requirement = dep.split(PEP_508_NAME_REGEXP, 2).last(2).map(&:strip)
|
293
293
|
requirement = requirement.sub(/^[\s;]*/, "")
|
294
294
|
requirement = "*" if requirement == ""
|
295
295
|
return name, requirement
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require "gemnasium/parser"
|
2
2
|
|
3
3
|
module Bibliothecary
|
4
4
|
module Parsers
|
@@ -13,20 +13,20 @@ module Bibliothecary
|
|
13
13
|
def self.mapping
|
14
14
|
{
|
15
15
|
match_filenames("Gemfile", "gems.rb") => {
|
16
|
-
kind:
|
16
|
+
kind: "manifest",
|
17
17
|
parser: :parse_gemfile,
|
18
|
-
related_to: [
|
18
|
+
related_to: [ "manifest", "lockfile" ],
|
19
19
|
},
|
20
20
|
match_extension(".gemspec") => {
|
21
|
-
kind:
|
21
|
+
kind: "manifest",
|
22
22
|
parser: :parse_gemspec,
|
23
|
-
related_to: [
|
23
|
+
related_to: [ "manifest", "lockfile" ],
|
24
24
|
},
|
25
25
|
match_filenames("Gemfile.lock", "gems.locked") => {
|
26
|
-
kind:
|
26
|
+
kind: "lockfile",
|
27
27
|
parser: :parse_gemfile_lock,
|
28
|
-
related_to: [
|
29
|
-
}
|
28
|
+
related_to: [ "manifest", "lockfile" ],
|
29
|
+
},
|
30
30
|
}
|
31
31
|
end
|
32
32
|
|
@@ -34,7 +34,7 @@ module Bibliothecary
|
|
34
34
|
add_multi_parser(Bibliothecary::MultiParsers::DependenciesCSV)
|
35
35
|
add_multi_parser(Bibliothecary::MultiParsers::Spdx)
|
36
36
|
|
37
|
-
def self.parse_gemfile_lock(file_contents, options: {})
|
37
|
+
def self.parse_gemfile_lock(file_contents, options: {}) # rubocop:disable Lint/UnusedMethodArgument
|
38
38
|
file_contents.lines(chomp: true).map do |line|
|
39
39
|
match = line.match(NAME_VERSION_4)
|
40
40
|
bundler_match = line.match(BUNDLED_WITH)
|
@@ -42,11 +42,11 @@ module Bibliothecary
|
|
42
42
|
|
43
43
|
if match
|
44
44
|
name = match[1]
|
45
|
-
version = match[2].gsub(/\(|\)/,
|
45
|
+
version = match[2].gsub(/\(|\)/,"")
|
46
46
|
{
|
47
47
|
name: name,
|
48
48
|
requirement: version,
|
49
|
-
type:
|
49
|
+
type: "runtime",
|
50
50
|
}
|
51
51
|
else
|
52
52
|
parse_bundler(file_contents)
|
@@ -54,12 +54,12 @@ module Bibliothecary
|
|
54
54
|
end.compact
|
55
55
|
end
|
56
56
|
|
57
|
-
def self.parse_gemfile(file_contents, options: {})
|
57
|
+
def self.parse_gemfile(file_contents, options: {}) # rubocop:disable Lint/UnusedMethodArgument
|
58
58
|
manifest = Gemnasium::Parser.send(:gemfile, file_contents)
|
59
59
|
parse_ruby_manifest(manifest)
|
60
60
|
end
|
61
61
|
|
62
|
-
def self.parse_gemspec(file_contents, options: {})
|
62
|
+
def self.parse_gemspec(file_contents, options: {}) # rubocop:disable Lint/UnusedMethodArgument
|
63
63
|
manifest = Gemnasium::Parser.send(:gemspec, file_contents)
|
64
64
|
parse_ruby_manifest(manifest)
|
65
65
|
end
|
@@ -71,9 +71,9 @@ module Bibliothecary
|
|
71
71
|
return nil unless version
|
72
72
|
|
73
73
|
{
|
74
|
-
name:
|
74
|
+
name: "bundler",
|
75
75
|
requirement: version,
|
76
|
-
type:
|
76
|
+
type: "runtime",
|
77
77
|
}
|
78
78
|
end
|
79
79
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require "yaml"
|
2
2
|
|
3
3
|
module Bibliothecary
|
4
4
|
module Parsers
|
@@ -8,35 +8,35 @@ module Bibliothecary
|
|
8
8
|
def self.mapping
|
9
9
|
{
|
10
10
|
match_filename("shard.yml", case_insensitive: true) => {
|
11
|
-
kind:
|
12
|
-
parser: :parse_yaml_manifest
|
11
|
+
kind: "manifest",
|
12
|
+
parser: :parse_yaml_manifest,
|
13
13
|
},
|
14
14
|
match_filename("shard.lock", case_insensitive: true) => {
|
15
|
-
kind:
|
16
|
-
parser: :parse_yaml_lockfile
|
17
|
-
}
|
15
|
+
kind: "lockfile",
|
16
|
+
parser: :parse_yaml_lockfile,
|
17
|
+
},
|
18
18
|
}
|
19
19
|
end
|
20
20
|
|
21
21
|
add_multi_parser(Bibliothecary::MultiParsers::DependenciesCSV)
|
22
22
|
|
23
|
-
def self.parse_yaml_lockfile(file_contents, options: {})
|
23
|
+
def self.parse_yaml_lockfile(file_contents, options: {}) # rubocop:disable Lint/UnusedMethodArgument
|
24
24
|
manifest = YAML.load file_contents
|
25
|
-
map_dependencies(manifest,
|
25
|
+
map_dependencies(manifest, "shards", "runtime")
|
26
26
|
end
|
27
27
|
|
28
|
-
def self.parse_yaml_manifest(file_contents, options: {})
|
28
|
+
def self.parse_yaml_manifest(file_contents, options: {}) # rubocop:disable Lint/UnusedMethodArgument
|
29
29
|
manifest = YAML.load file_contents
|
30
|
-
map_dependencies(manifest,
|
31
|
-
map_dependencies(manifest,
|
30
|
+
map_dependencies(manifest, "dependencies", "runtime") +
|
31
|
+
map_dependencies(manifest, "development_dependencies", "runtime")
|
32
32
|
end
|
33
33
|
|
34
34
|
def self.map_dependencies(hash, key, type)
|
35
35
|
hash.fetch(key,[]).map do |name, requirement|
|
36
36
|
{
|
37
37
|
name: name,
|
38
|
-
requirement: requirement[
|
39
|
-
type: type
|
38
|
+
requirement: requirement["version"] || "*",
|
39
|
+
type: type,
|
40
40
|
}
|
41
41
|
end
|
42
42
|
end
|
@@ -6,9 +6,9 @@ module Bibliothecary
|
|
6
6
|
def self.mapping
|
7
7
|
{
|
8
8
|
match_filename("Package.swift", case_insensitive: true) => {
|
9
|
-
kind:
|
10
|
-
parser: :parse_package_swift
|
11
|
-
}
|
9
|
+
kind: "manifest",
|
10
|
+
parser: :parse_package_swift,
|
11
|
+
},
|
12
12
|
}
|
13
13
|
end
|
14
14
|
|
@@ -16,17 +16,17 @@ module Bibliothecary
|
|
16
16
|
add_multi_parser(Bibliothecary::MultiParsers::DependenciesCSV)
|
17
17
|
add_multi_parser(Bibliothecary::MultiParsers::Spdx)
|
18
18
|
|
19
|
-
def self.parse_package_swift(file_contents, options: {})
|
19
|
+
def self.parse_package_swift(file_contents, options: {}) # rubocop:disable Lint/UnusedMethodArgument
|
20
20
|
response = Typhoeus.post("#{Bibliothecary.configuration.swift_parser_host}/to-json", body: file_contents)
|
21
21
|
raise Bibliothecary::RemoteParsingError.new("Http Error #{response.response_code} when contacting: #{Bibliothecary.configuration.swift_parser_host}/to-json", response.response_code) unless response.success?
|
22
22
|
json = JSON.parse(response.body)
|
23
23
|
json["dependencies"].map do |dependency|
|
24
|
-
name = dependency[
|
24
|
+
name = dependency["url"].gsub(/^https?:\/\//, "").gsub(/\.git$/,"")
|
25
25
|
version = "#{dependency['version']['lowerBound']} - #{dependency['version']['upperBound']}"
|
26
26
|
{
|
27
27
|
name: name,
|
28
28
|
requirement: version,
|
29
|
-
type:
|
29
|
+
type: "runtime",
|
30
30
|
}
|
31
31
|
end
|
32
32
|
end
|
data/lib/bibliothecary/runner.rb
CHANGED
@@ -6,7 +6,7 @@ module Bibliothecary
|
|
6
6
|
def initialize(configuration)
|
7
7
|
@configuration = configuration
|
8
8
|
@options = {
|
9
|
-
cache: {}
|
9
|
+
cache: {},
|
10
10
|
}
|
11
11
|
end
|
12
12
|
|
@@ -24,8 +24,8 @@ module Bibliothecary
|
|
24
24
|
analyses = analyses.flatten.compact
|
25
25
|
|
26
26
|
info_list.select { |info| info.package_manager.nil? }.each do |info|
|
27
|
-
analyses.push(Bibliothecary::Analyser::create_error_analysis(
|
28
|
-
|
27
|
+
analyses.push(Bibliothecary::Analyser::create_error_analysis("unknown", info.relative_path, "unknown",
|
28
|
+
"No parser for this file type"))
|
29
29
|
end
|
30
30
|
|
31
31
|
analyses
|
@@ -178,4 +178,4 @@ module Bibliothecary
|
|
178
178
|
end
|
179
179
|
end
|
180
180
|
|
181
|
-
require_relative
|
181
|
+
require_relative "./runner/multi_manifest_filter.rb"
|
data/lib/bibliothecary.rb
CHANGED
@@ -9,10 +9,10 @@ require "bibliothecary/purl_util"
|
|
9
9
|
require "find"
|
10
10
|
require "tomlrb"
|
11
11
|
|
12
|
-
Dir[File.expand_path(
|
12
|
+
Dir[File.expand_path("../bibliothecary/multi_parsers/*.rb", __FILE__)].each do |file|
|
13
13
|
require file
|
14
14
|
end
|
15
|
-
Dir[File.expand_path(
|
15
|
+
Dir[File.expand_path("../bibliothecary/parsers/*.rb", __FILE__)].each do |file|
|
16
16
|
require file
|
17
17
|
end
|
18
18
|
|
@@ -80,7 +80,7 @@ module Bibliothecary
|
|
80
80
|
string
|
81
81
|
.dup # ensure we don't have a frozen string
|
82
82
|
.force_encoding("UTF-8") # treat all strings as utf8
|
83
|
-
.sub(/^\xEF\xBB\xBF/,
|
83
|
+
.sub(/^\xEF\xBB\xBF/, "") # remove any Byte Order Marks so JSON, etc don't fail while parsing them.
|
84
84
|
end
|
85
85
|
|
86
86
|
class << self
|
data/lib/sdl_parser.rb
CHANGED
@@ -1,18 +1,18 @@
|
|
1
|
-
require
|
1
|
+
require "sdl4r"
|
2
2
|
|
3
3
|
class SdlParser
|
4
4
|
attr_reader :contents, :type
|
5
5
|
def initialize(type, contents)
|
6
6
|
@contents = contents
|
7
|
-
@type = type ||
|
7
|
+
@type = type || "runtime"
|
8
8
|
end
|
9
9
|
|
10
10
|
def dependencies
|
11
|
-
parse.children(
|
11
|
+
parse.children("dependency").inject([]) do |deps, dep|
|
12
12
|
deps.push({
|
13
13
|
name: dep.value,
|
14
|
-
requirement: dep.attribute(
|
15
|
-
type: type
|
14
|
+
requirement: dep.attribute("version") || ">= 0",
|
15
|
+
type: type,
|
16
16
|
})
|
17
17
|
end.uniq
|
18
18
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bibliothecary
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 8.7.
|
4
|
+
version: 8.7.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Nesbitt
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-01-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: tomlrb
|