bibliothecary 8.7.5 → 8.7.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3fbd83e689755fcae99771b12a88ce74a9c31c22d60b11b40fcb552987628f45
4
- data.tar.gz: deb85d3948752fd0a3142bb41d5cd07bde78b4604b95a77eb652b2d7a6d2634b
3
+ metadata.gz: 9c0af4f20a3dda13587bef4ed23446be465960fb69970f0f6b928b01dedb5599
4
+ data.tar.gz: ac0b2b21d35c70ff4c58c9470691a1dcd9f9080ece1a0e4d7606b39292d4022b
5
5
  SHA512:
6
- metadata.gz: f72d8392eae9835fa51ce423d76f2664592e666964dbf921d25b03d0edef6c5f79adb64e3527c89a2f0ecc9c88958e51de223c93b405a70d28e1a1ca73626dcf
7
- data.tar.gz: d9928f3e5181293c015bbf72985bd7baf50f5126655e96cbb5d64d0abbe88c0a061b37a672ce7ea06869d6c1aedcec68fa02ea89fc7a4bc0ba45e32ad692b35d
6
+ metadata.gz: b2cbe6f624584fded45298b635105e68c41cf7e857472f94ac47582bdd57273339373c21c18982c87bd1556c559f2f58fb1949c25f21cffb04ae082efc16d46e
7
+ data.tar.gz: 8d35a25784b49e90f639ba0678be9d802e77f66b9e81376d042ce5d7e79af68f5101922bc35b2fff8233c56b9a90759b64dbc492a8bf4104643099bc8fc66eab
@@ -81,11 +81,21 @@ module Bibliothecary
81
81
  parser: :parse_cyclonedx_json,
82
82
  ungroupable: true,
83
83
  },
84
+ match_extension("cdx.json") => {
85
+ kind: "lockfile",
86
+ parser: :parse_cyclonedx_json,
87
+ ungroupable: true,
88
+ },
84
89
  match_filename("cyclonedx.xml") => {
85
90
  kind: "lockfile",
86
91
  parser: :parse_cyclonedx_xml,
87
92
  ungroupable: true,
88
93
  },
94
+ match_extension(".cdx.xml") => {
95
+ kind: "lockfile",
96
+ parser: :parse_cyclonedx_xml,
97
+ ungroupable: true,
98
+ },
89
99
  }
90
100
  end
91
101
 
@@ -129,8 +129,12 @@ module Bibliothecary
129
129
 
130
130
  deps = categorized_deps["require"]
131
131
  .map do |dep|
132
- # A "replace" directive doesn't add the dep to the module graph unless the original dep is also in a "require" directive,
132
+ # NOTE: A "replace" directive doesn't add the dep to the module graph unless the original dep is also in a "require" directive,
133
133
  # so we need to track down replacements here and use those instead of the originals, if present.
134
+ #
135
+ # NOTE: The "replace" directive doesn't actually change the version reported from Go (e.g. "go mod graph"), it only changes
136
+ # the *source code*. So by replacing the deps here, we're giving more honest results than you'd get when asking go
137
+ # about the versions used.
134
138
  replaced_dep = categorized_deps["replace"]
135
139
  .find do |replacement_dep|
136
140
  replacement_dep[:original_name] == dep[:name] &&
@@ -187,7 +191,18 @@ module Bibliothecary
187
191
  def self.parse_go_resolved(file_contents, options: {}) # rubocop:disable Lint/UnusedMethodArgument
188
192
  JSON.parse(file_contents)
189
193
  .select { |dep| dep["Main"] != "true" }
190
- .map { |dep| { name: dep["Path"], requirement: dep["Version"], type: dep.fetch("Scope") { "runtime" } } }
194
+ .map do |dep|
195
+ if dep["Replace"].is_a?(String) && dep["Replace"] != "<nil>" && dep["Replace"] != ""
196
+ # NOTE: The "replace" directive doesn't actually change the version reported from Go (e.g. "go mod graph"), it only changes
197
+ # the *source code*. So by replacing the deps here, we're giving more honest results than you'd get when asking go
198
+ # about the versions used.
199
+ name, requirement = dep["Replace"].split(" ", 2)
200
+ requirement = "*" if requirement.to_s.strip == ""
201
+ { name: name, requirement: requirement, original_name: dep["Path"], original_requirement: dep["Version"], type: dep.fetch("Scope") { "runtime" } }
202
+ else
203
+ { name: dep["Path"], requirement: dep["Version"], type: dep.fetch("Scope") { "runtime" } }
204
+ end
205
+ end
191
206
  end
192
207
 
193
208
  def self.map_dependencies(manifest, attr_name, dep_attr_name, version_attr_name, type)
@@ -12,6 +12,7 @@ module Bibliothecary
12
12
 
13
13
  REQUIREMENTS_REGEXP = /^#{REQUIRE_REGEXP}/
14
14
  MANIFEST_REGEXP = /.*require[^\/]*(\/)?[^\/]*\.(txt|pip|in)$/
15
+ # TODO: can this be a more specific regexp so it doesn't match something like ".yarn/cache/create-require-npm-1.0.0.zip"?
15
16
  PIP_COMPILE_REGEXP = /.*require.*$/
16
17
 
17
18
  # Adapted from https://peps.python.org/pep-0508/#names
@@ -1,3 +1,3 @@
1
1
  module Bibliothecary
2
- VERSION = "8.7.5"
2
+ VERSION = "8.7.7"
3
3
  end
data/lib/bibliothecary.rb CHANGED
@@ -17,7 +17,8 @@ Dir[File.expand_path("../bibliothecary/parsers/*.rb", __FILE__)].each do |file|
17
17
  end
18
18
 
19
19
  module Bibliothecary
20
- VERSION_OPERATORS = /[~^<>*"]/
20
+ VERSION_OPERATORS = /[~^<>*"]/.freeze
21
+ INVALID_UTF8_ERROR_REGEXP = /invalid byte sequence/.freeze
21
22
 
22
23
  def self.analyse(path, ignore_unparseable_files: true)
23
24
  runner.analyse(path, ignore_unparseable_files: ignore_unparseable_files)
@@ -81,6 +82,10 @@ module Bibliothecary
81
82
  .dup # ensure we don't have a frozen string
82
83
  .force_encoding("UTF-8") # treat all strings as utf8
83
84
  .sub(/^\xEF\xBB\xBF/, "") # remove any Byte Order Marks so JSON, etc don't fail while parsing them.
85
+ rescue ArgumentError => e
86
+ # Bibliothecary doesn't need to analyze non-UTF8 files like binary files, so just return blank.
87
+ return "" if e.message.match?(INVALID_UTF8_ERROR_REGEXP)
88
+ raise e
84
89
  end
85
90
 
86
91
  class << self
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.5
4
+ version: 8.7.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Nesbitt
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-01-08 00:00:00.000000000 Z
11
+ date: 2024-03-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tomlrb