iron_dome 0.1.2 → 0.1.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 553265fff91bc6fb67adeb16e89182b2895f7692934bb0416e57a3ad2c32b138
4
- data.tar.gz: e89d7904609d52a8e51d45c053f67fa1a99c1adb1c9724068a5ebc825c082566
3
+ metadata.gz: 5a78ecb0117de214b26c07cfcbe0bb9656f1c5cd1c42aa9db5ca40709959f854
4
+ data.tar.gz: 253148e1c1be2caeddc6cfb71083bb1038859d648d25fde208933f9b1f0be0f5
5
5
  SHA512:
6
- metadata.gz: d7d5067dc1b8323a6564f8b1aae41f16c35f9ea2a3afb4fd0d679a973f36dabd0013c9e98a860f15fce66041cc0e58fc188815a8c3046a2c8aa06eb374018366
7
- data.tar.gz: 1363e9613e691ea42c028222f9878d0072c528c9777794cb8a19c9bd841c046266016ba207a05b1bd5620a36bd57c194218873cf81733a05ee9c42c0a5807e54
6
+ metadata.gz: ee17272c99ec3f66ce139214653c6685e208cb6b45a915be8577d4d7a858c0c8c505eb00fbe776118a26a7c96d5958b44807cbcc6f127d26cb644c4ee230a079
7
+ data.tar.gz: cfaa3937060d92c5ec20898c1d2d09334f2f67e8ab79a8fe1e22b2873a85b738a92afee2750cad8b55a7c4648e0b0b7c6cc5bc5e4dd97f8d1609070db7985b1b
data/.rubocop.yml CHANGED
@@ -1,5 +1,5 @@
1
1
  AllCops:
2
- TargetRubyVersion: 2.6
2
+ TargetRubyVersion: 3.0
3
3
 
4
4
  Style/StringLiterals:
5
5
  Enabled: true
data/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
- ## [Unreleased]
1
+ ## [released]
2
2
 
3
3
  ## [0.1.0] - 2024-01-20
4
4
 
5
5
  - Initial release
6
+
7
+ ## [released]
8
+
9
+ ## [0.1.2] - 2024-02-20
10
+
11
+ - Support sarif output
12
+ - Suport output on terminal
13
+ - General improvements
14
+
15
+ ## [released]
16
+
17
+ ## [0.1.3] - 2024-03-02
18
+
19
+ - Improvement in code architecture
20
+ - Improvement in specs
21
+ - When -o or --output is given as a param, theres no output on terminal only on a sarif file
data/README.md CHANGED
@@ -14,10 +14,27 @@ this directory must have the Gemfile.lock, you can also run on a ci/cd pipeline.
14
14
 
15
15
  $ iron_dome
16
16
 
17
+ ### Theres some optional params you can use, like, -o or --output and -d or --detail
18
+
19
+ This will generate a sarif file format.
20
+
21
+ $ iron_dome -o
22
+ $ iron_dome --output
23
+
24
+ This will show details on the current shell session like the output example below.
25
+
26
+ $ iron_dome -d
27
+ $ iron_dome --detail
28
+
17
29
  ## Output Example
18
30
 
19
31
  ![alt text](image.png)
20
32
 
33
+ ## Supported language and lockfile format
34
+
35
+ | Ruby | Gemfile.lock |
36
+ |-----------|-----------------|
37
+
21
38
  ## Development
22
39
 
23
40
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
data/iron_dome.gemspec ADDED
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/iron_dome/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "iron_dome"
7
+ spec.version = IronDome::VERSION
8
+ spec.authors = ["Jose Augusto"]
9
+ spec.email = ["joseaugusto.881@outlook.com"]
10
+
11
+ spec.summary = "A vulnerability scanner for ruby projects dependencies"
12
+ spec.homepage = "https://github.com/JAugusto42/iron_dome"
13
+ spec.license = "MIT"
14
+ spec.required_ruby_version = ">= 3.0.0"
15
+
16
+ spec.metadata["homepage_uri"] = spec.homepage
17
+ spec.metadata["source_code_uri"] = "https://github.com/JAugusto42/iron_dome"
18
+ spec.metadata["changelog_uri"] = "https://github.com/JAugusto42/iron_dome/CHANGELOG.md"
19
+
20
+ spec.executables << "iron_dome"
21
+
22
+ # Specify which files should be added to the gem when it is released.
23
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
24
+ spec.files = Dir.chdir(__dir__) do
25
+ `git ls-files -z`.split("\x0").reject do |f|
26
+ (File.expand_path(f) == __FILE__) ||
27
+ f.start_with?(*%w[bin/ test/ spec/ features/ .git appveyor Gemfile])
28
+ end
29
+ end
30
+ spec.bindir = "exe"
31
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
32
+ spec.require_paths = ["lib"]
33
+
34
+ spec.add_dependency "colorize", "~> 1.1"
35
+ spec.add_dependency "concurrent-ruby", "~> 1.2"
36
+ spec.add_dependency "faraday", "~> 2.9"
37
+ spec.add_dependency "rake", "~> 13.0"
38
+ end
@@ -10,15 +10,19 @@ module IronDome
10
10
  end
11
11
 
12
12
  def call
13
- read_file
13
+ read_lock_file
14
14
  end
15
15
 
16
16
  private
17
17
 
18
- def read_file
19
- # read the lockfile, Gemfile.lock for now
20
- lock_files = Dir.glob("Gemfile.lock")
21
- lock_files.map { |file| process_lock_file(file) }
18
+ def read_lock_file
19
+ lock_file = Dir.glob("Gemfile.lock")
20
+ if lock_file.empty?
21
+ puts "Not able to find Gemfile.lock ..."
22
+ return
23
+ end
24
+
25
+ lock_file.map { |file| process_lock_file(file) }
22
26
  end
23
27
 
24
28
  def process_lock_file(file)
@@ -27,7 +31,7 @@ module IronDome
27
31
  puts "Verifying vulnerabilities on osv database ..."
28
32
  results = Requester.osv_request(packages_and_versions)
29
33
  results.compact!
30
- system_output(results)
34
+ system_output(results) unless options[:sarif_output] == true
31
35
  output_sarif_file_format(results) if options[:sarif_output] == true
32
36
  end
33
37
 
@@ -35,7 +39,7 @@ module IronDome
35
39
  # method to call the module to generate the sarif report
36
40
  puts "Generating the sarif output ..."
37
41
  IronDome::Sarif::Output.new.output_report(results)
38
- puts "Sarif file outputed"
42
+ puts "Sarif file outputted"
39
43
  end
40
44
 
41
45
  def system_output(results)
@@ -50,35 +54,35 @@ module IronDome
50
54
 
51
55
  def build_output(results)
52
56
  # Build the terminal output but maybe we will need to improve this methods.
53
- total_vulns = 0
57
+ total_vulnerabilities = 0
54
58
 
55
- puts ":: Vulnerabilities found:"
59
+ puts ":: Vulnerabilities found:".colorize(:red)
56
60
  results.each do |result|
57
- result["vulns"].each do |vuln|
58
- print_vulnerability_info(vuln)
59
- total_vulns += 1
61
+ result["vulns"].each do |vulnerability|
62
+ print_vulnerability_info(vulnerability)
63
+ total_vulnerabilities += 1
60
64
  end
61
65
  end
62
66
 
63
- puts "#{total_vulns} vulnerabilities founded.".colorize(:red)
67
+ puts "#{total_vulnerabilities} vulnerabilities founded.".colorize(:light_red)
64
68
  end
65
69
 
66
- def print_vulnerability_info(vuln)
67
- package_name = extract_package_name(vuln)
68
- version_fixed = extract_version_fixed(vuln)
69
- summary = vuln["summary"]
70
- details = vuln["details"]
70
+ def print_vulnerability_info(vulnerabilities)
71
+ package_name = extract_package_name(vulnerabilities)
72
+ version_fixed = extract_version_fixed(vulnerabilities)
73
+ summary = vulnerabilities["summary"]
74
+ details = vulnerabilities["details"]
71
75
 
72
76
  print_info(package_name, version_fixed, summary, details)
73
77
  end
74
78
 
75
- def extract_package_name(vuln)
76
- affected_package = vuln["affected"].first
79
+ def extract_package_name(vulnerability)
80
+ affected_package = vulnerability["affected"].first
77
81
  affected_package["package"]["name"]
78
82
  end
79
83
 
80
- def extract_version_fixed(vuln)
81
- affected_package = vuln["affected"].first
84
+ def extract_version_fixed(vulnerability)
85
+ affected_package = vulnerability["affected"].first
82
86
  version_ranges = affected_package["ranges"].first
83
87
  version_ranges["events"].last["fixed"]
84
88
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module IronDome
4
- VERSION = "0.1.2"
4
+ VERSION = "0.1.4"
5
5
  end
data/lib/iron_dome.rb CHANGED
@@ -14,9 +14,12 @@ require_relative "iron_dome/reader"
14
14
  module IronDome
15
15
  class Error < StandardError; end
16
16
 
17
- # class entry, this is the entrypoint of the gem.
17
+ # class entry, this is the main class of the gem.
18
18
  class Entry
19
+ # rubocop:disable Metrics/MethodLength
19
20
  def main
21
+ puts display_ascii_art
22
+
20
23
  options = {}
21
24
  OptionParser.new do |opts|
22
25
  opts.on("-o", "--output", "Generate a sarif format file report.") do |output|
@@ -30,5 +33,19 @@ module IronDome
30
33
 
31
34
  Reader.new(options).call
32
35
  end
36
+ # rubocop:enable Metrics/MethodLength
37
+
38
+ def display_ascii_art
39
+ <<-ART
40
+
41
+ ██╗██████╗ ██████╗ ███╗ ██╗██████╗ ██████╗ ███╗ ███╗███████╗
42
+ ██║██╔══██╗██╔═══██╗████╗ ██║██╔══██╗██╔═══██╗████╗ ████║██╔════╝
43
+ ██║██████╔╝██║ ██║██╔██╗ ██║██║ ██║██║ ██║██╔████╔██║█████╗
44
+ ██║██╔══██╗██║ ██║██║╚██╗██║██║ ██║██║ ██║██║╚██╔╝██║██╔══╝
45
+ ██║██║ ██║╚██████╔╝██║ ╚████║██████╔╝╚██████╔╝██║ ╚═╝ ██║███████╗
46
+ ╚═╝╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═══╝╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝ v#{IronDome::VERSION}
47
+
48
+ ART
49
+ end
33
50
  end
34
51
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: iron_dome
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jose Augusto
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-02-21 00:00:00.000000000 Z
11
+ date: 2024-07-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colorize
@@ -83,13 +83,13 @@ files:
83
83
  - Rakefile
84
84
  - exe/iron_dome
85
85
  - image.png
86
+ - iron_dome.gemspec
86
87
  - lib/iron_dome.rb
87
88
  - lib/iron_dome/output.rb
88
89
  - lib/iron_dome/reader.rb
89
90
  - lib/iron_dome/requester.rb
90
91
  - lib/iron_dome/sarif/output.rb
91
92
  - lib/iron_dome/version.rb
92
- - sig/iron_dome.rbs
93
93
  homepage: https://github.com/JAugusto42/iron_dome
94
94
  licenses:
95
95
  - MIT
@@ -105,14 +105,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
105
105
  requirements:
106
106
  - - ">="
107
107
  - !ruby/object:Gem::Version
108
- version: 2.6.0
108
+ version: 3.0.0
109
109
  required_rubygems_version: !ruby/object:Gem::Requirement
110
110
  requirements:
111
111
  - - ">="
112
112
  - !ruby/object:Gem::Version
113
113
  version: '0'
114
114
  requirements: []
115
- rubygems_version: 3.5.6
115
+ rubygems_version: 3.5.14
116
116
  signing_key:
117
117
  specification_version: 4
118
118
  summary: A vulnerability scanner for ruby projects dependencies
data/sig/iron_dome.rbs DELETED
@@ -1,4 +0,0 @@
1
- module IronDome
2
- VERSION: String
3
- # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
- end