Module: Bibliothecary

Defined in:
lib/bibliothecary/parsers/maven.rb,
lib/bibliothecary.rb,
lib/bibliothecary/cli.rb,
lib/bibliothecary/runner.rb,
lib/bibliothecary/version.rb,
lib/bibliothecary/analyser.rb,
lib/bibliothecary/file_info.rb,
lib/bibliothecary/purl_util.rb,
lib/bibliothecary/exceptions.rb,
lib/bibliothecary/parsers/go.rb,
lib/bibliothecary/parsers/dub.rb,
lib/bibliothecary/parsers/elm.rb,
lib/bibliothecary/parsers/hex.rb,
lib/bibliothecary/parsers/npm.rb,
lib/bibliothecary/parsers/pub.rb,
lib/bibliothecary/parsers/cpan.rb,
lib/bibliothecary/parsers/cran.rb,
lib/bibliothecary/parsers/pypi.rb,
lib/bibliothecary/configuration.rb,
lib/bibliothecary/parsers/bower.rb,
lib/bibliothecary/parsers/cargo.rb,
lib/bibliothecary/parsers/conda.rb,
lib/bibliothecary/parsers/julia.rb,
lib/bibliothecary/parsers/nuget.rb,
lib/bibliothecary/parsers/shard.rb,
lib/bibliothecary/parsers/meteor.rb,
lib/bibliothecary/parsers/clojars.rb,
lib/bibliothecary/parsers/hackage.rb,
lib/bibliothecary/parsers/haxelib.rb,
lib/bibliothecary/parsers/carthage.rb,
lib/bibliothecary/parsers/rubygems.rb,
lib/bibliothecary/parsers/swift_pm.rb,
lib/bibliothecary/analyser/analysis.rb,
lib/bibliothecary/analyser/matchers.rb,
lib/bibliothecary/parsers/cocoapods.rb,
lib/bibliothecary/parsers/packagist.rb,
lib/bibliothecary/multi_parsers/spdx.rb,
lib/bibliothecary/related_files_info.rb,
lib/bibliothecary/analyser/determinations.rb,
lib/bibliothecary/multi_parsers/cyclonedx.rb,
lib/bibliothecary/multi_parsers/json_runtime.rb,
lib/bibliothecary/runner/multi_manifest_filter.rb,
lib/bibliothecary/multi_parsers/dependencies_csv.rb,
lib/bibliothecary/multi_parsers/bundler_like_manifest.rb

Overview

Known shortcomings and unimplemented Maven features:

pom.xml
  <exclusions> cannot be taken into account (because it requires knowledge of transitive deps)
  <properties> are the only thing inherited from parent poms currenly

Defined Under Namespace

Modules: Analyser, MultiParsers, Parsers Classes: CLI, Configuration, FileInfo, FileParsingError, RelatedFilesInfo, RemoteParsingError, Runner

Constant Summary collapse

VERSION_OPERATORS =
/[~^<>*"]/.freeze
INVALID_UTF8_ERROR_REGEXP =
/invalid byte sequence/.freeze
VERSION =
"8.7.7"
PURL_TYPE_MAPPING =

If a purl type (key) exists, it will be used in a manifest for the key’s value. If not, it’s ignored.

github.com/package-url/purl-spec/blob/master/PURL-TYPES.rst

{
  "golang" => :go,
  "maven" => :maven,
  "npm" => :npm,
  "cargo" => :cargo,
  "composer" => :packagist,
  "conda" => :conda,
  "cran" => :cran,
  "gem" => :rubygems,
  "hackage" => :hackage,
  "hex" => :hex,
  "nuget" => :nuget,
  "pypi" => :pypi,
  "swift" => :swift_pm,
}.freeze

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.configurationObject



102
103
104
105
106
# File 'lib/bibliothecary.rb', line 102

def self.configuration
  @configuration ||= Configuration.new
  @runner = Runner.new(@configuration)
  @configuration
end

Class Method Details

.analyse(path, ignore_unparseable_files: true) ⇒ Object Also known as: analyze



23
24
25
# File 'lib/bibliothecary.rb', line 23

def self.analyse(path, ignore_unparseable_files: true)
  runner.analyse(path, ignore_unparseable_files: ignore_unparseable_files)
end

.analyse_file(file_path, contents) ⇒ Object Also known as: analyze_file



48
49
50
# File 'lib/bibliothecary.rb', line 48

def self.analyse_file(file_path, contents)
  runner.analyse_file(file_path, contents)
end

.applicable_package_managers(info) ⇒ Object



32
33
34
# File 'lib/bibliothecary.rb', line 32

def self.applicable_package_managers(info)
  runner.applicable_package_managers(info)
end

.configure {|configuration| ... } ⇒ Object

Yields:



113
114
115
# File 'lib/bibliothecary.rb', line 113

def self.configure
  yield(configuration)
end

.find_manifests(path) ⇒ Object



60
61
62
# File 'lib/bibliothecary.rb', line 60

def self.find_manifests(path)
  runner.find_manifests(path)
end

.find_manifests_from_contents(file_path_contents_hash) ⇒ Object



68
69
70
# File 'lib/bibliothecary.rb', line 68

def self.find_manifests_from_contents(file_path_contents_hash)
  runner.find_manifests_from_contents(file_path_contents_hash)
end

.find_manifests_from_paths(paths) ⇒ Object



64
65
66
# File 'lib/bibliothecary.rb', line 64

def self.find_manifests_from_paths(paths)
  runner.find_manifests_from_paths(paths)
end

.identify_manifests(file_list) ⇒ Object



52
53
54
# File 'lib/bibliothecary.rb', line 52

def self.identify_manifests(file_list)
  runner.identify_manifests(file_list)
end

.ignored_dirsObject



72
73
74
# File 'lib/bibliothecary.rb', line 72

def self.ignored_dirs
  configuration.ignored_dirs
end

.ignored_filesObject



76
77
78
# File 'lib/bibliothecary.rb', line 76

def self.ignored_files
  configuration.ignored_files
end

.load_file_info_list(path) ⇒ Object



36
37
38
# File 'lib/bibliothecary.rb', line 36

def self.load_file_info_list(path)
  runner.load_file_info_list(path)
end

.load_file_info_list_from_contents(file_path_contents_hash) ⇒ Object



44
45
46
# File 'lib/bibliothecary.rb', line 44

def self.load_file_info_list_from_contents(file_path_contents_hash)
  runner.load_file_info_list_from_contents(file_path_contents_hash)
end

.load_file_info_list_from_paths(paths) ⇒ Object



40
41
42
# File 'lib/bibliothecary.rb', line 40

def self.load_file_info_list_from_paths(paths)
  runner.load_file_info_list_from_paths(paths)
end

.load_file_list(path) ⇒ Object

deprecated; use load_file_info_list.



28
29
30
# File 'lib/bibliothecary.rb', line 28

def self.load_file_list(path)
  runner.load_file_list(path)
end

.package_managersObject



56
57
58
# File 'lib/bibliothecary.rb', line 56

def self.package_managers
  runner.package_managers
end

.resetObject



108
109
110
111
# File 'lib/bibliothecary.rb', line 108

def self.reset
  @configuration = Configuration.new
  @runner = Runner.new(@configuration)
end

.runnerObject



97
98
99
100
# File 'lib/bibliothecary.rb', line 97

def self.runner
  configuration
  @runner
end

.utf8_string(string) ⇒ Object



80
81
82
83
84
85
86
87
88
89
# File 'lib/bibliothecary.rb', line 80

def self.utf8_string(string)
  string
    .dup # ensure we don't have a frozen string
    .force_encoding("UTF-8") # treat all strings as utf8
    .sub(/^\xEF\xBB\xBF/, "") # remove any Byte Order Marks so JSON, etc don't fail while parsing them.
rescue ArgumentError => e
  # Bibliothecary doesn't need to analyze non-UTF8 files like binary files, so just return blank.
  return "" if e.message.match?(INVALID_UTF8_ERROR_REGEXP)
  raise e
end