iron_dome 0.1.0
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 +7 -0
- data/.rspec +3 -0
- data/.rubocop.yml +17 -0
- data/CHANGELOG.md +5 -0
- data/CODE_OF_CONDUCT.md +84 -0
- data/LICENSE.txt +21 -0
- data/README.md +37 -0
- data/Rakefile +36 -0
- data/exe/iron_dome +7 -0
- data/image.png +0 -0
- data/iron_dome.gemspec +38 -0
- data/lib/iron_dome/output.rb +6 -0
- data/lib/iron_dome/reader.rb +95 -0
- data/lib/iron_dome/requester.rb +34 -0
- data/lib/iron_dome/sarif/output.rb +70 -0
- data/lib/iron_dome/version.rb +5 -0
- data/lib/iron_dome.rb +34 -0
- data/sig/iron_dome.rbs +4 -0
- metadata +120 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: d5592a27dfe1fd191cdb3bdab7629e60694c8958d451b23c78d96b7e4737c29c
|
|
4
|
+
data.tar.gz: b087cfdd594444719c26309484ba4d6e1b34ea4768b15868952546ada6908ae8
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 6aebd3eaa08bfa52819514053bdffa3b14a8623283095245b7fe112369dc79e828bfaeb2943c5cf64227b9c8ac25202cd213e915378698246007ff8f894075df
|
|
7
|
+
data.tar.gz: c4fe08d5f95549979c19d147fca64bc46b89197ff1b402113d88a0576acf3f3488d63ca1a04659fdbe0911b40a90b6050819b3a5e94da1bdc0c4077ff2b86e98
|
data/.rspec
ADDED
data/.rubocop.yml
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
AllCops:
|
|
2
|
+
TargetRubyVersion: 2.6
|
|
3
|
+
|
|
4
|
+
Style/StringLiterals:
|
|
5
|
+
Enabled: true
|
|
6
|
+
EnforcedStyle: double_quotes
|
|
7
|
+
|
|
8
|
+
Style/StringLiteralsInInterpolation:
|
|
9
|
+
Enabled: true
|
|
10
|
+
EnforcedStyle: double_quotes
|
|
11
|
+
|
|
12
|
+
Layout/LineLength:
|
|
13
|
+
Max: 120
|
|
14
|
+
|
|
15
|
+
Metrics/BlockLength:
|
|
16
|
+
Exclude:
|
|
17
|
+
- spec/**/* # nearly all spec files go over 25 lines
|
data/CHANGELOG.md
ADDED
data/CODE_OF_CONDUCT.md
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
|
2
|
+
|
|
3
|
+
## Our Pledge
|
|
4
|
+
|
|
5
|
+
We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
|
|
6
|
+
|
|
7
|
+
We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
|
|
8
|
+
|
|
9
|
+
## Our Standards
|
|
10
|
+
|
|
11
|
+
Examples of behavior that contributes to a positive environment for our community include:
|
|
12
|
+
|
|
13
|
+
* Demonstrating empathy and kindness toward other people
|
|
14
|
+
* Being respectful of differing opinions, viewpoints, and experiences
|
|
15
|
+
* Giving and gracefully accepting constructive feedback
|
|
16
|
+
* Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
|
|
17
|
+
* Focusing on what is best not just for us as individuals, but for the overall community
|
|
18
|
+
|
|
19
|
+
Examples of unacceptable behavior include:
|
|
20
|
+
|
|
21
|
+
* The use of sexualized language or imagery, and sexual attention or
|
|
22
|
+
advances of any kind
|
|
23
|
+
* Trolling, insulting or derogatory comments, and personal or political attacks
|
|
24
|
+
* Public or private harassment
|
|
25
|
+
* Publishing others' private information, such as a physical or email
|
|
26
|
+
address, without their explicit permission
|
|
27
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
|
28
|
+
professional setting
|
|
29
|
+
|
|
30
|
+
## Enforcement Responsibilities
|
|
31
|
+
|
|
32
|
+
Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
|
|
33
|
+
|
|
34
|
+
Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
|
|
35
|
+
|
|
36
|
+
## Scope
|
|
37
|
+
|
|
38
|
+
This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
|
|
39
|
+
|
|
40
|
+
## Enforcement
|
|
41
|
+
|
|
42
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at joseaugusto.881@outlook.com. All complaints will be reviewed and investigated promptly and fairly.
|
|
43
|
+
|
|
44
|
+
All community leaders are obligated to respect the privacy and security of the reporter of any incident.
|
|
45
|
+
|
|
46
|
+
## Enforcement Guidelines
|
|
47
|
+
|
|
48
|
+
Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
|
|
49
|
+
|
|
50
|
+
### 1. Correction
|
|
51
|
+
|
|
52
|
+
**Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
|
|
53
|
+
|
|
54
|
+
**Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
|
|
55
|
+
|
|
56
|
+
### 2. Warning
|
|
57
|
+
|
|
58
|
+
**Community Impact**: A violation through a single incident or series of actions.
|
|
59
|
+
|
|
60
|
+
**Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
|
|
61
|
+
|
|
62
|
+
### 3. Temporary Ban
|
|
63
|
+
|
|
64
|
+
**Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
|
|
65
|
+
|
|
66
|
+
**Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
|
|
67
|
+
|
|
68
|
+
### 4. Permanent Ban
|
|
69
|
+
|
|
70
|
+
**Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
|
|
71
|
+
|
|
72
|
+
**Consequence**: A permanent ban from any sort of public interaction within the community.
|
|
73
|
+
|
|
74
|
+
## Attribution
|
|
75
|
+
|
|
76
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
|
|
77
|
+
available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
|
|
78
|
+
|
|
79
|
+
Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
|
|
80
|
+
|
|
81
|
+
[homepage]: https://www.contributor-covenant.org
|
|
82
|
+
|
|
83
|
+
For answers to common questions about this code of conduct, see the FAQ at
|
|
84
|
+
https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
|
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Jose Augusto
|
|
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
|
|
13
|
+
all 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
|
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# IronDome
|
|
2
|
+

|
|
3
|
+
|
|
4
|
+
A SCA scanner for ruby applications, read the gemfile.lock verify vulnerabilities use osv database.
|
|
5
|
+
|
|
6
|
+
## Installation
|
|
7
|
+
On root dir of the gem run:
|
|
8
|
+
|
|
9
|
+
$ gem build
|
|
10
|
+
$ gem install iron_dome
|
|
11
|
+
|
|
12
|
+
## Usage
|
|
13
|
+
|
|
14
|
+
After install the gem just run the follow command on main directory of your application
|
|
15
|
+
this directory must have the Gemfile.lock
|
|
16
|
+
|
|
17
|
+
$ iron_dome
|
|
18
|
+
|
|
19
|
+
## Output Example
|
|
20
|
+

|
|
21
|
+
## Development
|
|
22
|
+
|
|
23
|
+
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.
|
|
24
|
+
|
|
25
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
|
26
|
+
|
|
27
|
+
## Contributing
|
|
28
|
+
|
|
29
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/JAugusto42/iron_dome. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/iron_dome/blob/main/CODE_OF_CONDUCT.md).
|
|
30
|
+
|
|
31
|
+
## License
|
|
32
|
+
|
|
33
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
|
34
|
+
|
|
35
|
+
## Code of Conduct
|
|
36
|
+
|
|
37
|
+
Everyone interacting in the IronDome project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/iron_dome/blob/main/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "bundler/gem_tasks"
|
|
4
|
+
require "rspec/core/rake_task"
|
|
5
|
+
|
|
6
|
+
RSpec::Core::RakeTask.new(:spec)
|
|
7
|
+
|
|
8
|
+
require "rubocop/rake_task"
|
|
9
|
+
|
|
10
|
+
RuboCop::RakeTask.new
|
|
11
|
+
|
|
12
|
+
task default: %i[spec rubocop]
|
|
13
|
+
|
|
14
|
+
##################################
|
|
15
|
+
# Useful Rake Automation for gem #
|
|
16
|
+
##################################
|
|
17
|
+
GEM_NAME = "iron_dome"
|
|
18
|
+
GEM_VERSION = "0.1.0"
|
|
19
|
+
|
|
20
|
+
task default: :build
|
|
21
|
+
|
|
22
|
+
task :build do
|
|
23
|
+
system "gem build #{GEM_NAME}.gemspec"
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
task install: :build do
|
|
27
|
+
system "gem install #{GEM_NAME}-#{GEM_VERSION}.gem"
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
task publish: :build do
|
|
31
|
+
system "gem push #{GEM_NAME}-#{GEM_VERSION}.gem"
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
task :clean do
|
|
35
|
+
system "rm *.gem"
|
|
36
|
+
end
|
data/exe/iron_dome
ADDED
data/image.png
ADDED
|
Binary file
|
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 dependencies."
|
|
12
|
+
spec.homepage = "https://github.com/JAugusto42/iron_dome"
|
|
13
|
+
spec.license = "MIT"
|
|
14
|
+
spec.required_ruby_version = ">= 2.6.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
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module IronDome
|
|
4
|
+
# The Reader class is responsible for reading lock files from the project and generating SARIF reports.
|
|
5
|
+
class Reader
|
|
6
|
+
attr_reader :options
|
|
7
|
+
|
|
8
|
+
def initialize(options)
|
|
9
|
+
@options = options
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def call
|
|
13
|
+
read_file
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
private
|
|
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) }
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def process_lock_file(file)
|
|
25
|
+
file_lines = File.read(file).lines
|
|
26
|
+
packages_and_versions = file_lines.flat_map { |line| line.scan(/\b(\w+) \(([\d.]+)\)/) }.to_h
|
|
27
|
+
puts "Verifying vulnerabilities on osv database ..."
|
|
28
|
+
results = Requester.osv_request(packages_and_versions)
|
|
29
|
+
results.compact!
|
|
30
|
+
system_output(results)
|
|
31
|
+
output_sarif_file_format(results) if options[:sarif_output] == true
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def output_sarif_file_format(results)
|
|
35
|
+
# method to call the module to generate the sarif report
|
|
36
|
+
puts "Generating the sarif output ..."
|
|
37
|
+
IronDome::Sarif::Output.new.output_report(results)
|
|
38
|
+
puts "Sarif file outputed"
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def system_output(results)
|
|
42
|
+
# method to call module to output the results on current shell.
|
|
43
|
+
if results.empty?
|
|
44
|
+
puts "No vulnerabiities founded".colorize(:green)
|
|
45
|
+
return
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
build_output(results)
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def build_output(results)
|
|
52
|
+
# Build the terminal output but maybe we will need to improve this methods.
|
|
53
|
+
total_vulns = 0
|
|
54
|
+
|
|
55
|
+
puts ":: Vulnerabilities found:"
|
|
56
|
+
results.each do |result|
|
|
57
|
+
result["vulns"].each do |vuln|
|
|
58
|
+
print_vulnerability_info(vuln)
|
|
59
|
+
total_vulns += 1
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
puts "#{total_vulns} vulnerabilities founded.".colorize(:red)
|
|
64
|
+
end
|
|
65
|
+
|
|
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"]
|
|
71
|
+
|
|
72
|
+
print_info(package_name, version_fixed, summary, details)
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
def extract_package_name(vuln)
|
|
76
|
+
affected_package = vuln["affected"].first
|
|
77
|
+
affected_package["package"]["name"]
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
def extract_version_fixed(vuln)
|
|
81
|
+
affected_package = vuln["affected"].first
|
|
82
|
+
version_ranges = affected_package["ranges"].first
|
|
83
|
+
version_ranges["events"].last["fixed"]
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
def print_info(package_name, version_fixed, summary, details)
|
|
87
|
+
puts "-------------------------------------".colorize(:blue)
|
|
88
|
+
puts "Package Name: #{package_name}".colorize(:magenta)
|
|
89
|
+
puts "Summary: #{summary}".colorize(:yellow)
|
|
90
|
+
puts "Details: #{details}".colorize(:cyan) if options[:detail] == true
|
|
91
|
+
puts "Version fixed: #{version_fixed}".colorize(:green)
|
|
92
|
+
puts "-------------------------------------".colorize(:blue)
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
end
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "json"
|
|
4
|
+
require "faraday"
|
|
5
|
+
require "concurrent"
|
|
6
|
+
|
|
7
|
+
module IronDome
|
|
8
|
+
# The requester class responsable to deal with osv database request and result.
|
|
9
|
+
class Requester
|
|
10
|
+
URL = "https://api.osv.dev/v1/query"
|
|
11
|
+
FARADAY_OPTIONS = { headers: { "Content-Type" => "application/json" } }.freeze
|
|
12
|
+
CONN = Faraday.new(URL, FARADAY_OPTIONS)
|
|
13
|
+
|
|
14
|
+
def self.osv_request(packages_and_versions)
|
|
15
|
+
futures = packages_and_versions.each_slice(5).map do |batch|
|
|
16
|
+
Concurrent::Future.execute { process_batch(batch) }
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
futures.flat_map(&:value).compact
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def self.process_batch(batch)
|
|
23
|
+
batch.map { |package, version| query_osv(package, version) }
|
|
24
|
+
rescue Faraday::ClientError, Faraday::ConnectionFailed, Faraday::TimeoutError => e
|
|
25
|
+
puts "Error: #{e.message}"
|
|
26
|
+
[]
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def self.query_osv(package, version)
|
|
30
|
+
response = CONN.post("/v1/query", { version: version, package: { name: package, ecosystem: "RubyGems" } }.to_json)
|
|
31
|
+
JSON.parse(response.body) unless response.body == "{}"
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module IronDome
|
|
4
|
+
module Sarif
|
|
5
|
+
# this class deal with sarif output
|
|
6
|
+
class Output
|
|
7
|
+
def initialize; end
|
|
8
|
+
|
|
9
|
+
def output_report(result)
|
|
10
|
+
sarif_json = convert_to_sarif(result)
|
|
11
|
+
File.write("result.sarif", JSON.pretty_generate(sarif_json))
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def convert_to_sarif(result)
|
|
15
|
+
sarif_result = sarif_schema
|
|
16
|
+
result.each { |vulnerability| process_vulnerability(sarif_result, vulnerability) }
|
|
17
|
+
JSON.pretty_generate(sarif_result)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def process_vulnerability(sarif_result, vulnerability)
|
|
21
|
+
vulnerability["vulns"].each do |vuln|
|
|
22
|
+
sarif_result[:runs][0][:results] << generate_sarif_result(vuln)
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def generate_sarif_result(vuln)
|
|
27
|
+
{
|
|
28
|
+
ruleId: vuln["id"],
|
|
29
|
+
message: { text: vuln["summary"] },
|
|
30
|
+
locations: build_physical_location(vuln),
|
|
31
|
+
references: build_references(vuln)
|
|
32
|
+
}
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def build_physical_location(vuln)
|
|
36
|
+
affected_package = vuln["affected"][0]["package"]
|
|
37
|
+
{
|
|
38
|
+
physicalLocation: {
|
|
39
|
+
artifactLocation: { uri: affected_package["purl"] },
|
|
40
|
+
region: { startLine: nil, startColumn: nil }
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def build_references(vuln)
|
|
46
|
+
vuln["references"].map { |ref| { type: "WEB", url: ref["url"] } }
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def sarif_schema
|
|
50
|
+
{
|
|
51
|
+
schema: "https://raw.githubusercontent.com/oasis-tcs/sarif-spec/master/Schemata/sarif-schema-2.1.0.json",
|
|
52
|
+
version: "2.1.0",
|
|
53
|
+
runs: [build_run_info]
|
|
54
|
+
}
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def build_run_info
|
|
58
|
+
{
|
|
59
|
+
tool: {
|
|
60
|
+
driver: {
|
|
61
|
+
name: "OSv.dev API",
|
|
62
|
+
version: "1.0"
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
results: []
|
|
66
|
+
}
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
end
|
data/lib/iron_dome.rb
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "json"
|
|
4
|
+
require "faraday"
|
|
5
|
+
require "colorize"
|
|
6
|
+
require "optparse"
|
|
7
|
+
|
|
8
|
+
require_relative "iron_dome/requester"
|
|
9
|
+
require_relative "iron_dome/sarif/output"
|
|
10
|
+
require_relative "iron_dome/output"
|
|
11
|
+
require_relative "iron_dome/version"
|
|
12
|
+
require_relative "iron_dome/reader"
|
|
13
|
+
|
|
14
|
+
module IronDome
|
|
15
|
+
class Error < StandardError; end
|
|
16
|
+
|
|
17
|
+
# class entry, this is the entrypoint of the gem.
|
|
18
|
+
class Entry
|
|
19
|
+
def main
|
|
20
|
+
options = {}
|
|
21
|
+
OptionParser.new do |opts|
|
|
22
|
+
opts.on("-o", "--output", "Generate a sarif format file report.") do |output|
|
|
23
|
+
options[:sarif_output] = output
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
opts.on("-d", "--detail", "Show vulnerability details.") do |detail|
|
|
27
|
+
options[:detail] = detail
|
|
28
|
+
end
|
|
29
|
+
end.parse!
|
|
30
|
+
|
|
31
|
+
Reader.new(options).call
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
data/sig/iron_dome.rbs
ADDED
metadata
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: iron_dome
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Jose Augusto
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: exe
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2024-02-19 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: colorize
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - "~>"
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '1.1'
|
|
20
|
+
type: :runtime
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - "~>"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '1.1'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: concurrent-ruby
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - "~>"
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '1.2'
|
|
34
|
+
type: :runtime
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - "~>"
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '1.2'
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: faraday
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - "~>"
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '2.9'
|
|
48
|
+
type: :runtime
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - "~>"
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '2.9'
|
|
55
|
+
- !ruby/object:Gem::Dependency
|
|
56
|
+
name: rake
|
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - "~>"
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: '13.0'
|
|
62
|
+
type: :runtime
|
|
63
|
+
prerelease: false
|
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - "~>"
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: '13.0'
|
|
69
|
+
description:
|
|
70
|
+
email:
|
|
71
|
+
- joseaugusto.881@outlook.com
|
|
72
|
+
executables:
|
|
73
|
+
- iron_dome
|
|
74
|
+
extensions: []
|
|
75
|
+
extra_rdoc_files: []
|
|
76
|
+
files:
|
|
77
|
+
- ".rspec"
|
|
78
|
+
- ".rubocop.yml"
|
|
79
|
+
- CHANGELOG.md
|
|
80
|
+
- CODE_OF_CONDUCT.md
|
|
81
|
+
- LICENSE.txt
|
|
82
|
+
- README.md
|
|
83
|
+
- Rakefile
|
|
84
|
+
- exe/iron_dome
|
|
85
|
+
- image.png
|
|
86
|
+
- iron_dome.gemspec
|
|
87
|
+
- lib/iron_dome.rb
|
|
88
|
+
- lib/iron_dome/output.rb
|
|
89
|
+
- lib/iron_dome/reader.rb
|
|
90
|
+
- lib/iron_dome/requester.rb
|
|
91
|
+
- lib/iron_dome/sarif/output.rb
|
|
92
|
+
- lib/iron_dome/version.rb
|
|
93
|
+
- sig/iron_dome.rbs
|
|
94
|
+
homepage: https://github.com/JAugusto42/iron_dome
|
|
95
|
+
licenses:
|
|
96
|
+
- MIT
|
|
97
|
+
metadata:
|
|
98
|
+
homepage_uri: https://github.com/JAugusto42/iron_dome
|
|
99
|
+
source_code_uri: https://github.com/JAugusto42/iron_dome
|
|
100
|
+
changelog_uri: https://github.com/JAugusto42/iron_dome/CHANGELOG.md
|
|
101
|
+
post_install_message:
|
|
102
|
+
rdoc_options: []
|
|
103
|
+
require_paths:
|
|
104
|
+
- lib
|
|
105
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
106
|
+
requirements:
|
|
107
|
+
- - ">="
|
|
108
|
+
- !ruby/object:Gem::Version
|
|
109
|
+
version: 2.6.0
|
|
110
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
111
|
+
requirements:
|
|
112
|
+
- - ">="
|
|
113
|
+
- !ruby/object:Gem::Version
|
|
114
|
+
version: '0'
|
|
115
|
+
requirements: []
|
|
116
|
+
rubygems_version: 3.5.6
|
|
117
|
+
signing_key:
|
|
118
|
+
specification_version: 4
|
|
119
|
+
summary: A vulnerability scanner for dependencies.
|
|
120
|
+
test_files: []
|