bundler-sbom 0.1.5 → 0.1.6
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 +4 -4
- data/Gemfile +1 -0
- data/LICENSE +21 -0
- data/lib/bundler/sbom/cli.rb +2 -1
- data/lib/bundler/sbom/generator.rb +7 -44
- data/lib/bundler/sbom/reporter.rb +47 -0
- data/lib/bundler/sbom/version.rb +1 -1
- metadata +7 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bb720a4c1407de48380f89d81cfb76c76c9aaf72477e06de9d42e2154b278ddf
|
4
|
+
data.tar.gz: '0596c33babc35714c4515f6eb7f018bbabbe22350734650c060f34788a28bb0f'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a1878c226f0f1dc92967c05dcb52539de886734eed0395a734164c426d14cffcccebf53c13dab7f5113c4497efe44c9b7bcca2898d638a1f84cc88362502f1f8
|
7
|
+
data.tar.gz: 5fb51be53f651ec22422f33fdbb8859842cef43911681ed70d104f9582856f741816491df1a8b67a322122f4eecb21355dabdd9e6d103ab85016f08ea5506a90
|
data/Gemfile
CHANGED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2025 SHIBATA Hiroshi
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/lib/bundler/sbom/cli.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require "json"
|
2
2
|
require "bundler/sbom/generator"
|
3
|
+
require "bundler/sbom/reporter"
|
3
4
|
|
4
5
|
module Bundler
|
5
6
|
module Sbom
|
@@ -20,7 +21,7 @@ module Bundler
|
|
20
21
|
|
21
22
|
begin
|
22
23
|
sbom = JSON.parse(File.read("bom.json"))
|
23
|
-
Bundler::Sbom::
|
24
|
+
Bundler::Sbom::Reporter.display_license_report(sbom)
|
24
25
|
rescue JSON::ParserError
|
25
26
|
Bundler.ui.error("Error: bom.json is not a valid JSON file")
|
26
27
|
exit 1
|
@@ -3,11 +3,14 @@ require "securerandom"
|
|
3
3
|
|
4
4
|
module Bundler
|
5
5
|
module Sbom
|
6
|
+
class GemfileLockNotFoundError < StandardError; end
|
7
|
+
|
6
8
|
class Generator
|
7
9
|
def self.generate_sbom
|
8
10
|
lockfile_path = Bundler.default_lockfile
|
9
|
-
|
10
|
-
|
11
|
+
if !lockfile_path || !lockfile_path.exist?
|
12
|
+
Bundler.ui.error "No Gemfile.lock found. Run `bundle install` first."
|
13
|
+
raise GemfileLockNotFoundError, "No Gemfile.lock found"
|
11
14
|
end
|
12
15
|
|
13
16
|
lockfile = Bundler::LockfileParser.new(lockfile_path.read)
|
@@ -57,6 +60,7 @@ module Bundler
|
|
57
60
|
"filesAnalyzed" => false,
|
58
61
|
"licenseConcluded" => license_string,
|
59
62
|
"licenseDeclared" => license_string,
|
63
|
+
"copyrightText" => "NOASSERTION",
|
60
64
|
"supplier" => "NOASSERTION",
|
61
65
|
"externalRefs" => [
|
62
66
|
{
|
@@ -69,50 +73,9 @@ module Bundler
|
|
69
73
|
sbom["packages"] << package
|
70
74
|
end
|
71
75
|
|
76
|
+
sbom["documentDescribes"] = sbom["packages"].map { |p| p["SPDXID"] }
|
72
77
|
sbom
|
73
78
|
end
|
74
|
-
|
75
|
-
def self.display_license_report(sbom)
|
76
|
-
license_count = analyze_licenses(sbom)
|
77
|
-
sorted_licenses = license_count.sort_by { |_, count| -count }
|
78
|
-
|
79
|
-
puts "=== License Usage in SBOM ==="
|
80
|
-
puts "Total packages: #{sbom["packages"].size}"
|
81
|
-
puts
|
82
|
-
|
83
|
-
sorted_licenses.each do |license, count|
|
84
|
-
puts "#{license}: #{count} package(s)"
|
85
|
-
end
|
86
|
-
|
87
|
-
puts "\n=== Packages by License ==="
|
88
|
-
sorted_licenses.each do |license, _|
|
89
|
-
packages = sbom["packages"].select do |package|
|
90
|
-
if package["licenseDeclared"].include?(",")
|
91
|
-
package["licenseDeclared"].split(",").map(&:strip).include?(license)
|
92
|
-
else
|
93
|
-
package["licenseDeclared"] == license
|
94
|
-
end
|
95
|
-
end
|
96
|
-
|
97
|
-
puts "\n#{license} (#{packages.size} package(s)):"
|
98
|
-
packages.each do |package|
|
99
|
-
puts " - #{package["name"]} (#{package["versionInfo"]})"
|
100
|
-
end
|
101
|
-
end
|
102
|
-
end
|
103
|
-
|
104
|
-
private
|
105
|
-
|
106
|
-
def self.analyze_licenses(sbom)
|
107
|
-
license_count = Hash.new(0)
|
108
|
-
sbom["packages"].each do |package|
|
109
|
-
licenses = package["licenseDeclared"].split(",").map(&:strip)
|
110
|
-
licenses.each do |license|
|
111
|
-
license_count[license] += 1
|
112
|
-
end
|
113
|
-
end
|
114
|
-
license_count
|
115
|
-
end
|
116
79
|
end
|
117
80
|
end
|
118
81
|
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module Bundler
|
2
|
+
module Sbom
|
3
|
+
class Reporter
|
4
|
+
def self.display_license_report(sbom)
|
5
|
+
license_count = analyze_licenses(sbom)
|
6
|
+
sorted_licenses = license_count.sort_by { |_, count| -count }
|
7
|
+
|
8
|
+
puts "=== License Usage in SBOM ==="
|
9
|
+
puts "Total packages: #{sbom["packages"].size}"
|
10
|
+
puts
|
11
|
+
|
12
|
+
sorted_licenses.each do |license, count|
|
13
|
+
puts "#{license}: #{count} package(s)"
|
14
|
+
end
|
15
|
+
|
16
|
+
puts "\n=== Packages by License ==="
|
17
|
+
sorted_licenses.each do |license, _|
|
18
|
+
packages = sbom["packages"].select do |package|
|
19
|
+
if package["licenseDeclared"].include?(",")
|
20
|
+
package["licenseDeclared"].split(",").map(&:strip).include?(license)
|
21
|
+
else
|
22
|
+
package["licenseDeclared"] == license
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
puts "\n#{license} (#{packages.size} package(s)):"
|
27
|
+
packages.each do |package|
|
28
|
+
puts " - #{package["name"]} (#{package["versionInfo"]})"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def self.analyze_licenses(sbom)
|
36
|
+
license_count = Hash.new(0)
|
37
|
+
sbom["packages"].each do |package|
|
38
|
+
licenses = package["licenseDeclared"].split(",").map(&:strip)
|
39
|
+
licenses.each do |license|
|
40
|
+
license_count[license] += 1
|
41
|
+
end
|
42
|
+
end
|
43
|
+
license_count
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
data/lib/bundler/sbom/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bundler-sbom
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- SHIBATA Hiroshi
|
@@ -23,7 +23,7 @@ dependencies:
|
|
23
23
|
- - ">="
|
24
24
|
- !ruby/object:Gem::Version
|
25
25
|
version: '2.0'
|
26
|
-
description: Generate
|
26
|
+
description: Generate SPDX SBOM(Software Bill of Materials) files with Bundler
|
27
27
|
email:
|
28
28
|
- hsbt@ruby-lang.org
|
29
29
|
executables: []
|
@@ -31,15 +31,18 @@ extensions: []
|
|
31
31
|
extra_rdoc_files: []
|
32
32
|
files:
|
33
33
|
- Gemfile
|
34
|
+
- LICENSE
|
34
35
|
- README.md
|
35
36
|
- Rakefile
|
36
37
|
- lib/bundler/sbom.rb
|
37
38
|
- lib/bundler/sbom/cli.rb
|
38
39
|
- lib/bundler/sbom/generator.rb
|
40
|
+
- lib/bundler/sbom/reporter.rb
|
39
41
|
- lib/bundler/sbom/version.rb
|
40
42
|
- plugins.rb
|
41
43
|
homepage: https://github.com/hsbt/bundler-sbom
|
42
|
-
licenses:
|
44
|
+
licenses:
|
45
|
+
- MIT
|
43
46
|
metadata:
|
44
47
|
homepage_uri: https://github.com/hsbt/bundler-sbom
|
45
48
|
source_code_uri: https://github.com/hsbt/bundler-sbom
|
@@ -61,5 +64,5 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
61
64
|
requirements: []
|
62
65
|
rubygems_version: 3.6.2
|
63
66
|
specification_version: 4
|
64
|
-
summary: Generate
|
67
|
+
summary: Generate SPDX SBOM(Software Bill of Materials) files with Bundler
|
65
68
|
test_files: []
|