spandx 0.13.3 → 0.15.1

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.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +37 -2
  3. data/exe/spandx +0 -1
  4. data/ext/spandx/spandx.c +7 -3
  5. data/lib/spandx.rb +1 -1
  6. data/lib/spandx/cli.rb +2 -2
  7. data/lib/spandx/cli/commands/pull.rb +33 -4
  8. data/lib/spandx/cli/commands/scan.rb +19 -22
  9. data/lib/spandx/cli/main.rb +3 -3
  10. data/lib/spandx/cli/printer.rb +27 -0
  11. data/lib/spandx/cli/printers/csv.rb +17 -0
  12. data/lib/spandx/cli/printers/json.rb +17 -0
  13. data/lib/spandx/cli/printers/table.rb +42 -0
  14. data/lib/spandx/core/dependency.rb +48 -13
  15. data/lib/spandx/core/git.rb +6 -6
  16. data/lib/spandx/core/http.rb +6 -6
  17. data/lib/spandx/core/license_plugin.rb +10 -4
  18. data/lib/spandx/core/parser.rb +9 -4
  19. data/lib/spandx/core/path_traversal.rb +4 -13
  20. data/lib/spandx/core/plugin.rb +6 -0
  21. data/lib/spandx/core/thread_pool.rb +49 -0
  22. data/lib/spandx/dotnet/nuget_gateway.rb +1 -1
  23. data/lib/spandx/dotnet/parsers/csproj.rb +7 -7
  24. data/lib/spandx/dotnet/parsers/packages_config.rb +7 -7
  25. data/lib/spandx/dotnet/parsers/sln.rb +10 -13
  26. data/lib/spandx/dotnet/project_file.rb +3 -3
  27. data/lib/spandx/java/parsers/maven.rb +7 -7
  28. data/lib/spandx/js/parsers/npm.rb +8 -8
  29. data/lib/spandx/js/parsers/yarn.rb +7 -7
  30. data/lib/spandx/js/yarn_pkg.rb +1 -1
  31. data/lib/spandx/os/parsers/apk.rb +51 -0
  32. data/lib/spandx/os/parsers/dpkg.rb +69 -0
  33. data/lib/spandx/php/packagist_gateway.rb +1 -1
  34. data/lib/spandx/php/parsers/composer.rb +7 -7
  35. data/lib/spandx/python/parsers/pipfile_lock.rb +4 -4
  36. data/lib/spandx/python/pypi.rb +19 -7
  37. data/lib/spandx/python/source.rb +1 -1
  38. data/lib/spandx/ruby/gateway.rb +1 -1
  39. data/lib/spandx/ruby/parsers/gemfile_lock.rb +10 -9
  40. data/lib/spandx/spdx/catalogue.rb +1 -1
  41. data/lib/spandx/version.rb +1 -1
  42. data/spandx.gemspec +5 -4
  43. metadata +38 -20
  44. data/lib/spandx/core/report.rb +0 -60
  45. data/lib/spandx/core/spinner.rb +0 -51
  46. data/lib/spandx/core/table.rb +0 -29
@@ -1,60 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Spandx
4
- module Core
5
- class Report
6
- include Enumerable
7
-
8
- FORMATS = {
9
- csv: :to_csv,
10
- hash: :to_h,
11
- json: :to_json,
12
- table: :to_table,
13
- }.freeze
14
-
15
- def initialize
16
- @dependencies = SortedSet.new
17
- end
18
-
19
- def add(dependency)
20
- @dependencies << dependency
21
- end
22
-
23
- def each
24
- @dependencies.each do |dependency|
25
- yield dependency
26
- end
27
- end
28
-
29
- def to(format, formats: FORMATS)
30
- public_send(formats.fetch(format&.to_sym, :to_json))
31
- end
32
-
33
- def to_table
34
- Table.new do |table|
35
- map do |dependency|
36
- table << dependency
37
- end
38
- end
39
- end
40
-
41
- def to_h
42
- { version: '1.0', dependencies: [] }.tap do |report|
43
- each do |dependency|
44
- report[:dependencies].push(dependency.to_h)
45
- end
46
- end
47
- end
48
-
49
- def to_json(*_args)
50
- JSON.pretty_generate(to_h)
51
- end
52
-
53
- def to_csv
54
- map do |dependency|
55
- CSV.generate_line(dependency.to_a)
56
- end
57
- end
58
- end
59
- end
60
- end
@@ -1,51 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Spandx
4
- module Core
5
- class Spinner
6
- NULL = Class.new do
7
- def self.spin(*args); end
8
-
9
- def self.stop(*args); end
10
- end
11
-
12
- attr_reader :columns, :spinner
13
-
14
- def initialize(columns: TTY::Screen.columns, output: $stderr)
15
- @columns = columns
16
- @spinner = Nanospinner.new(output)
17
- @queue = Queue.new
18
- @thread = Thread.new { work }
19
- end
20
-
21
- def spin(message)
22
- @queue.enq(justify(message))
23
- yield if block_given?
24
- end
25
-
26
- def stop
27
- @queue.clear
28
- @queue.enq(:stop)
29
- @thread.join
30
- end
31
-
32
- private
33
-
34
- def justify(message)
35
- message.to_s.ljust(columns - 3)
36
- end
37
-
38
- def work
39
- last_message = justify('')
40
- loop do
41
- message = @queue.empty? ? last_message : @queue.deq
42
- break if message == :stop
43
-
44
- spinner.spin(message)
45
- last_message = message
46
- sleep 0.1
47
- end
48
- end
49
- end
50
- end
51
- end
@@ -1,29 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Spandx
4
- module Core
5
- class Table
6
- def initialize
7
- @rows = []
8
- @max_justification = 0
9
- yield self
10
- end
11
-
12
- def <<(item)
13
- row = item.to_a
14
- new_max = row[0].size
15
- @max_justification = new_max + 1 if new_max > @max_justification
16
- @rows << row
17
- end
18
-
19
- def to_s
20
- @rows.map do |row|
21
- row.each.with_index.map do |cell, index|
22
- justification = index.zero? ? @max_justification : 15
23
- Array(cell).join(', ').ljust(justification, ' ')
24
- end.join
25
- end
26
- end
27
- end
28
- end
29
- end