polariscope 0.2.0 → 0.3.0
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1c891a85ae5f5fed5a3cba46ddb78c81657baedfac15bcf31de9002fdae9c6df
|
4
|
+
data.tar.gz: 3864c4ecf3833289fb1cb1af30df8316a646f62714962f034e60ab42d0ab11f9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c008254c44678d2a936e027e33bba206ac12f48f7350d5aa63f5105e8897713fc851664d46afa02f665f11d53ad4459094b6795e3ba4caefaf58b3918d74fd47
|
7
|
+
data.tar.gz: 8e123d4cc077831e1fc252d846655b0994e3f78836affdc11af73ad9df9ae87bedf3c5ead5012be77f6b010d38585172d7e31800f23f86241f68b74cae3c97d2
|
data/CHANGELOG.md
CHANGED
@@ -6,6 +6,7 @@ require 'bundler/audit/database'
|
|
6
6
|
require 'set'
|
7
7
|
require_relative 'gem_versions'
|
8
8
|
require_relative 'gem_health_score'
|
9
|
+
require_relative 'ruby_scanner'
|
9
10
|
|
10
11
|
module Polariscope
|
11
12
|
module Scanner
|
@@ -30,6 +31,7 @@ module Polariscope
|
|
30
31
|
update_audit_database: false, bundler_audit_config_path: ''
|
31
32
|
)
|
32
33
|
@lockfile_parser = Bundler::LockfileParser.new(gemfile_lock_content)
|
34
|
+
@ruby_scanner = RubyScanner.new(@lockfile_parser)
|
33
35
|
@gemfile_path = gemfile_path
|
34
36
|
@dependencies = installed_dependencies
|
35
37
|
@gem_priorities = gem_priorities
|
@@ -54,6 +56,7 @@ module Polariscope
|
|
54
56
|
|
55
57
|
attr_reader :dependencies
|
56
58
|
attr_reader :lockfile_parser
|
59
|
+
attr_reader :ruby_scanner
|
57
60
|
attr_reader :advisory_penalty_map
|
58
61
|
attr_reader :fallback_advisory_penalty
|
59
62
|
attr_reader :bundler_audit_config_path
|
@@ -127,6 +130,7 @@ module Polariscope
|
|
127
130
|
|
128
131
|
lockfile_parser.specs
|
129
132
|
.flat_map { |gem| database.check_gem(gem).to_a }
|
133
|
+
.concat(ruby_scanner.vulnerable_advisories)
|
130
134
|
.reject { |advisory| ignored_advisories.intersect?(advisory.identifiers.to_set) }
|
131
135
|
end
|
132
136
|
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'bundler'
|
4
|
+
require 'bundler/audit/database'
|
5
|
+
|
6
|
+
module Polariscope
|
7
|
+
module Scanner
|
8
|
+
class RubyScanner
|
9
|
+
def initialize(lockfile_parser)
|
10
|
+
@lockfile_parser = lockfile_parser
|
11
|
+
end
|
12
|
+
|
13
|
+
def version
|
14
|
+
lockfile_ruby_version&.gem_version
|
15
|
+
end
|
16
|
+
|
17
|
+
def vulnerable_advisories
|
18
|
+
version ? advisories.select { |a| a.vulnerable?(version) } : []
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
attr_reader :lockfile_parser
|
24
|
+
attr_reader :bundler_audit_database
|
25
|
+
|
26
|
+
def advisories
|
27
|
+
cve_paths.map { |path| Bundler::Audit::Advisory.load(path) }
|
28
|
+
end
|
29
|
+
|
30
|
+
# see https://github.com/rubysec/ruby-advisory-db?tab=readme-ov-file#directory-structure
|
31
|
+
# and https://github.com/rubysec/bundler-audit/blob/da0eff072a9521dc2995483a8978d5a7dd4e328a/lib/bundler/audit/database.rb#L364
|
32
|
+
def cve_paths
|
33
|
+
Dir.glob(File.join(Bundler::Audit::Database.path, 'rubies', engine, '*.yml'))
|
34
|
+
end
|
35
|
+
|
36
|
+
def engine
|
37
|
+
lockfile_ruby_version.engine
|
38
|
+
end
|
39
|
+
|
40
|
+
def lockfile_ruby_version
|
41
|
+
@lockfile_ruby_version ||= Bundler::RubyVersion.from_string(@lockfile_parser.ruby_version)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
data/lib/polariscope/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: polariscope
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rails team
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-10-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -60,6 +60,7 @@ files:
|
|
60
60
|
- lib/polariscope/scanner/gem_health_score.rb
|
61
61
|
- lib/polariscope/scanner/gem_versions.rb
|
62
62
|
- lib/polariscope/scanner/gemfile_health_score.rb
|
63
|
+
- lib/polariscope/scanner/ruby_scanner.rb
|
63
64
|
- lib/polariscope/version.rb
|
64
65
|
- polariscope.gemspec
|
65
66
|
homepage: https://github.com/infinum/polariscope
|