rubion 0.3.6 → 0.3.8
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/lib/rubion/reporter.rb +34 -2
- data/lib/rubion/version.rb +1 -1
- data/lib/rubion.rb +47 -40
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 66ea41e904499824e1e29a1fd89fe83860215fe8447ce510bb8ddcbd1cbde9f9
|
|
4
|
+
data.tar.gz: 9faa8f3ee26ceec360b6b73b3ba8b2948cad9277c98dea8c7c8357485de23b31
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 974ae2a4d695380c0c824fc81bfd49e48ed452cdb4abc3e7271a0a1c47e980a185024d8a1e0951e81046b31276c501dd4f1fcc3395a3d69d551fe2b24ba82113
|
|
7
|
+
data.tar.gz: 92075925c5f29a06da7a3fe1a454c523846a65a27a2f4ac2085cd5475b8042c9ae3ee3de6d5cb57acf7112a665341b60508f31cc25d08d47cbe44709dbee8cc8
|
data/lib/rubion/reporter.rb
CHANGED
|
@@ -88,7 +88,7 @@ module Rubion
|
|
|
88
88
|
versions = sort_versions(versions, :gem) if @sort_by
|
|
89
89
|
|
|
90
90
|
table = Terminal::Table.new do |t|
|
|
91
|
-
t.headings =
|
|
91
|
+
t.headings = format_version_headings
|
|
92
92
|
|
|
93
93
|
versions.each do |gem|
|
|
94
94
|
# Make direct dependencies bold
|
|
@@ -156,7 +156,7 @@ module Rubion
|
|
|
156
156
|
versions = sort_versions(versions, :package) if @sort_by
|
|
157
157
|
|
|
158
158
|
table = Terminal::Table.new do |t|
|
|
159
|
-
t.headings =
|
|
159
|
+
t.headings = format_version_headings
|
|
160
160
|
|
|
161
161
|
versions.each do |pkg|
|
|
162
162
|
# Make direct dependencies bold
|
|
@@ -234,6 +234,38 @@ module Rubion
|
|
|
234
234
|
"\033[1m#{text}\033[0m"
|
|
235
235
|
end
|
|
236
236
|
|
|
237
|
+
# Format version table headings with sorting indicator
|
|
238
|
+
def format_version_headings
|
|
239
|
+
base_headings = ['Name', 'Current', 'Date', 'Latest', 'Date', 'Behind By(Time)', 'Behind By(Versions)']
|
|
240
|
+
|
|
241
|
+
return base_headings unless @sort_by
|
|
242
|
+
|
|
243
|
+
# Map sort_by value to column index
|
|
244
|
+
column_map = {
|
|
245
|
+
'name' => 0,
|
|
246
|
+
'current' => 1,
|
|
247
|
+
'date' => 2, # First Date column (current_date)
|
|
248
|
+
'latest' => 4,
|
|
249
|
+
'behind by(time)' => 5,
|
|
250
|
+
'behind by time' => 5,
|
|
251
|
+
'time' => 5,
|
|
252
|
+
'behind by(versions)' => 6,
|
|
253
|
+
'behind by versions' => 6,
|
|
254
|
+
'versions' => 6
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
column_name = @sort_by.strip.downcase
|
|
258
|
+
column_index = column_map[column_name]
|
|
259
|
+
|
|
260
|
+
return base_headings unless column_index
|
|
261
|
+
|
|
262
|
+
# Add sorting indicator (↑ for ascending, ↓ for descending)
|
|
263
|
+
indicator = @sort_desc ? ' ↓' : ' ↑'
|
|
264
|
+
base_headings[column_index] = "#{base_headings[column_index]}#{indicator}"
|
|
265
|
+
|
|
266
|
+
base_headings
|
|
267
|
+
end
|
|
268
|
+
|
|
237
269
|
def version_difference(current, latest)
|
|
238
270
|
# Simple version difference calculation
|
|
239
271
|
current_parts = current.split('.').map(&:to_i)
|
data/lib/rubion/version.rb
CHANGED
data/lib/rubion.rb
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require_relative
|
|
4
|
-
require_relative
|
|
5
|
-
require_relative
|
|
3
|
+
require_relative 'rubion/version'
|
|
4
|
+
require_relative 'rubion/scanner'
|
|
5
|
+
require_relative 'rubion/reporter'
|
|
6
6
|
|
|
7
7
|
module Rubion
|
|
8
8
|
class Error < StandardError; end
|
|
@@ -10,7 +10,7 @@ module Rubion
|
|
|
10
10
|
class CLI
|
|
11
11
|
def self.start(args)
|
|
12
12
|
command = args[0]
|
|
13
|
-
|
|
13
|
+
|
|
14
14
|
case command
|
|
15
15
|
when 'scan'
|
|
16
16
|
# Parse options
|
|
@@ -29,8 +29,8 @@ module Rubion
|
|
|
29
29
|
|
|
30
30
|
def self.parse_scan_options(args)
|
|
31
31
|
# Default to sorting by "Behind By(Time)" in descending order
|
|
32
|
-
options = { gems: true, packages: true, sort_by:
|
|
33
|
-
|
|
32
|
+
options = { gems: true, packages: true, sort_by: 'Behind By(Time)', sort_desc: true, exclude_dependencies: false }
|
|
33
|
+
|
|
34
34
|
# Check for --gems-only or --packages-only flags
|
|
35
35
|
if args.include?('--gems-only') || args.include?('-g')
|
|
36
36
|
options[:gems] = true
|
|
@@ -43,50 +43,54 @@ module Rubion
|
|
|
43
43
|
options[:gems] = args.include?('--gems')
|
|
44
44
|
options[:packages] = args.include?('--packages')
|
|
45
45
|
end
|
|
46
|
-
|
|
46
|
+
|
|
47
47
|
# Parse --sort-by or -s option
|
|
48
48
|
sort_index = args.index('--sort-by') || args.index('-s')
|
|
49
|
-
if sort_index && args[sort_index + 1]
|
|
50
|
-
|
|
49
|
+
options[:sort_by] = args[sort_index + 1] if sort_index && args[sort_index + 1]
|
|
50
|
+
|
|
51
|
+
# Parse --asc/--ascending or --desc/--descending for sort order
|
|
52
|
+
if args.include?('--asc') || args.include?('--ascending')
|
|
53
|
+
options[:sort_desc] = false
|
|
54
|
+
elsif args.include?('--desc') || args.include?('--descending')
|
|
55
|
+
options[:sort_desc] = true
|
|
51
56
|
end
|
|
52
|
-
|
|
53
|
-
# Parse --asc or --ascending for ascending order (descending is default)
|
|
54
|
-
options[:sort_desc] = false if args.include?('--asc') || args.include?('--ascending')
|
|
55
|
-
|
|
57
|
+
|
|
56
58
|
# Parse --exclude-dependencies flag
|
|
57
59
|
options[:exclude_dependencies] = true if args.include?('--exclude-dependencies')
|
|
58
|
-
|
|
60
|
+
|
|
59
61
|
options
|
|
60
62
|
end
|
|
61
63
|
|
|
62
|
-
def self.scan(options = { gems: true, packages: true, sort_by:
|
|
64
|
+
def self.scan(options = { gems: true, packages: true, sort_by: 'Behind By(Time)', sort_desc: true,
|
|
65
|
+
exclude_dependencies: false })
|
|
63
66
|
project_path = Dir.pwd
|
|
64
|
-
|
|
67
|
+
|
|
65
68
|
scanner = Scanner.new(project_path: project_path)
|
|
66
69
|
result = scanner.scan_incremental(options)
|
|
67
|
-
|
|
70
|
+
|
|
68
71
|
# Results are already printed incrementally based on options
|
|
69
72
|
# Package results are printed in scan_incremental, but we need to ensure
|
|
70
73
|
# they use the same reporter instance with sort_by
|
|
71
74
|
# Actually, scan_incremental handles gem printing, but package printing
|
|
72
75
|
# happens here, so we need a reporter for packages
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
76
|
+
return unless options[:packages]
|
|
77
|
+
|
|
78
|
+
reporter = Reporter.new(result, sort_by: options[:sort_by], sort_desc: options[:sort_desc],
|
|
79
|
+
exclude_dependencies: options[:exclude_dependencies])
|
|
80
|
+
reporter.print_package_vulnerabilities
|
|
81
|
+
reporter.print_package_versions
|
|
78
82
|
end
|
|
79
83
|
|
|
80
84
|
def self.print_help
|
|
81
85
|
puts <<~HELP
|
|
82
|
-
|
|
86
|
+
|
|
83
87
|
🔒 Rubion - Security & Version Scanner for Ruby and JavaScript projects
|
|
84
|
-
|
|
88
|
+
|
|
85
89
|
USAGE:
|
|
86
90
|
rubion scan [OPTIONS] Scan current project for vulnerabilities and outdated versions
|
|
87
91
|
rubion version Display Rubion version
|
|
88
92
|
rubion help Display this help message
|
|
89
|
-
|
|
93
|
+
|
|
90
94
|
SCAN OPTIONS:
|
|
91
95
|
--gems, --gem, -g Scan only Ruby gems (skip NPM packages)
|
|
92
96
|
--packages, --npm, -p Scan only NPM packages (skip Ruby gems)
|
|
@@ -94,61 +98,64 @@ module Rubion
|
|
|
94
98
|
--sort-by COLUMN, -s COLUMN Sort results by column (Name, Current, Date, Latest, Behind By(Time), Behind By(Versions))
|
|
95
99
|
(default: "Behind By(Time)" in descending order)
|
|
96
100
|
--asc, --ascending Sort in ascending order (use with --sort-by)
|
|
101
|
+
--desc, --descending Sort in descending order (use with --sort-by, default)
|
|
97
102
|
--exclude-dependencies Show only direct dependencies (from Gemfile/package.json)
|
|
98
|
-
|
|
103
|
+
|
|
99
104
|
DESCRIPTION:
|
|
100
105
|
Rubion scans your project for:
|
|
101
106
|
- Ruby gem vulnerabilities (using bundler-audit)
|
|
102
107
|
- Outdated Ruby gems (using bundle outdated)
|
|
103
108
|
- NPM/JavaScript package vulnerabilities (using npm audit or yarn audit)
|
|
104
109
|
- Outdated NPM/JavaScript packages (using npm outdated or yarn outdated)
|
|
105
|
-
|
|
110
|
+
|
|
106
111
|
OUTPUT:
|
|
107
112
|
Results are displayed in organized tables with:
|
|
108
113
|
📛 Vulnerabilities with severity icons (🔴 Critical, 🟠 High, 🟡 Medium, 🟢 Low)
|
|
109
114
|
📦 Version information with release dates
|
|
110
115
|
⏱️ Time difference ("Behind By" column)
|
|
111
116
|
🔢 Version count between current and latest
|
|
112
|
-
|
|
117
|
+
|
|
113
118
|
EXAMPLES:
|
|
114
119
|
# Scan both gems and packages (default)
|
|
115
120
|
rubion scan
|
|
116
|
-
|
|
121
|
+
#{' '}
|
|
117
122
|
# Scan only Ruby gems
|
|
118
123
|
rubion scan --gems
|
|
119
|
-
|
|
124
|
+
#{' '}
|
|
120
125
|
# Scan only NPM packages
|
|
121
126
|
rubion scan --packages
|
|
122
|
-
|
|
127
|
+
#{' '}
|
|
123
128
|
# Sort by name
|
|
124
129
|
rubion scan --sort-by Name
|
|
125
|
-
|
|
130
|
+
#{' '}
|
|
126
131
|
# Sort by versions behind
|
|
127
132
|
rubion scan -s "Behind By(Versions)"
|
|
128
|
-
|
|
133
|
+
#{' '}
|
|
129
134
|
# Sort by name in descending order (default)
|
|
130
135
|
rubion scan --sort-by Name
|
|
131
|
-
|
|
136
|
+
#{' '}
|
|
132
137
|
# Sort by name in ascending order
|
|
133
138
|
rubion scan --sort-by Name --asc
|
|
134
|
-
|
|
139
|
+
#{' '}
|
|
140
|
+
# Sort by name in descending order
|
|
141
|
+
rubion scan --sort-by Name --desc
|
|
142
|
+
#{' '}
|
|
135
143
|
# Show only direct dependencies
|
|
136
144
|
rubion scan --exclude-dependencies
|
|
137
|
-
|
|
145
|
+
#{' '}
|
|
138
146
|
# Get help
|
|
139
147
|
rubion help
|
|
140
|
-
|
|
148
|
+
|
|
141
149
|
REQUIREMENTS:
|
|
142
150
|
- Ruby 2.6+
|
|
143
151
|
- Bundler (for gem scanning)
|
|
144
152
|
- NPM or Yarn (for package scanning, optional)
|
|
145
153
|
- bundler-audit (optional, install with: gem install bundler-audit)
|
|
146
|
-
|
|
154
|
+
#{' '}
|
|
147
155
|
NOTE:
|
|
148
156
|
If both npm and yarn are available, you will be prompted to choose which one to use.
|
|
149
|
-
|
|
157
|
+
|
|
150
158
|
HELP
|
|
151
159
|
end
|
|
152
160
|
end
|
|
153
161
|
end
|
|
154
|
-
|