Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add explicit webrick dependency #189

Merged

Conversation

adfoster-r7
Copy link
Contributor

Metasploit data models has an implicit dependency on webrick here which breaks and must be updated to work:

+#/Users/user/.rvm/gems/ruby-3.0.0@metasploit-framework/gems/metasploit_data_models-4.1.1/lib/metasploit_data_models.rb:6:in `require': cannot load such file -- webrick (LoadError)

Note that Webrick is no longer included in Ruby 3.0.0 by default:
https://www.ruby-lang.org/en/news/2020/12/25/ruby-3-0-0-released/

rapid7/metasploit-framework#14666

.gitignore Outdated
@@ -19,8 +19,6 @@
coverage
# generated yardocs
doc
# Installed gem versions. Not stored for the same reasons as .rvmrc
Gemfile.lock
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using Gemfiles inside gems

Q: What happens if I put a Gemfile in my gem?

A: When someone installs your gem, the Gemfile and Gemfile.lock files are completely ignored, even if you include them inside the .gem file you upload to rubygems.org. The Gemfile inside your gem is only to make it easy for developers (like you) to install the dependencies needed to do development work on your gem. The Gemfile also provides an easy way to track and install development-only or test-only gems. Read about Gemfiles in gems from the Bundler in gems page and the How to create a gem with Bundler guide.

Q: Should I commit my Gemfile.lock when writing a gem?

A: Yes, you should commit it. The presence of a Gemfile.lock in a gem's repository ensures that a fresh checkout of the repository uses the exact same set of dependencies every time. We believe this makes repositories more friendly towards new and existing contributors. Ideally, anyone should be able to clone the repo, run bundle install, and have passing tests. If you don't check in your Gemfile.lock, new contributors can get different versions of your dependencies, and run into failing tests that they don't know how to fix.

Q: But I have read that gems should not check in the Gemfile.lock!

A: The main advantage of not checking in your Gemfile.lock is that new checkouts (including CI) will immediately have failing tests if one of your dependencies changes in a breaking way. Instead of forcing every fresh checkout (and possible new contributor) to encounter broken builds, the Bundler team recommends either using a tool like Dependabot to automatically create a PR and run the test suite any time your dependencies release new versions. If you don't want to use a dependency monitoring bot, we suggest creating an additional daily CI build that deletes the Gemfile.lock before running bundle install. That way you, and others monitoring your CI status, will be the first to know about any failures from dependency changes.
https://bundler.io/guides/faq.html#using-gemfiles-inside-gems

@adfoster-r7 adfoster-r7 force-pushed the add-explicit-webrick-dependency branch 6 times, most recently from d57f7fd to 08d97e9 Compare February 3, 2021 21:17
@adfoster-r7 adfoster-r7 force-pushed the add-explicit-webrick-dependency branch from 08d97e9 to 64ba704 Compare February 3, 2021 21:22
@adfoster-r7 adfoster-r7 marked this pull request as draft February 3, 2021 21:24
@adfoster-r7
Copy link
Contributor Author

Looks like CI fails on yard:

Coverage report generated for RSpec to /home/runner/work/metasploit_data_models/metasploit_data_models/coverage. 1581 / 1734 LOC (91.18%) covered.
rake aborted!
LoadError: cannot load such file -- e2mmap
/home/runner/work/metasploit_data_models/metasploit_data_models/vendor/bundle/ruby/2.7.0/gems/activesupport-5.2.4.4/lib/active_support/dependencies.rb:291:in `require'

This repo currently pins yard to a version that doesn't support Ruby 2.7:

# documentation
# @note 0.8.7.4 has a bug where attribute writers show up as undocumented
s.add_development_dependency 'yard', '< 0.8.7.4'

@adfoster-r7 adfoster-r7 marked this pull request as ready for review February 3, 2021 21:32
@adfoster-r7
Copy link
Contributor Author

Bumping yard version allows CI to pass now:
image

There are warnings however:

bundle exec rake yard
[error]: Unhandled exception in YARD::Handlers::Ruby::AliasHandler:
  in `app/models/metasploit_data_models/search/operator/ip_address.rb`:25:

	25: alias_method :name, :attribute

[error]: NoMethodError: undefined method `types' for {}:Hash
[error]: Stack trace:
	/Users/adfoster/.rvm/gems/ruby-2.7.2/gems/yard-0.9.26/lib/yard/docstring.rb:217:in `block in to_raw'
	/Users/adfoster/.rvm/gems/ruby-2.7.2/gems/yard-0.9.26/lib/yard/docstring.rb:208:in `map'
	/Users/adfoster/.rvm/gems/ruby-2.7.2/gems/yard-0.9.26/lib/yard/docstring.rb:208:in `to_raw'
	/Users/adfoster/.rvm/gems/ruby-2.7.2/gems/yard-0.9.26/lib/yard/handlers/ruby/alias_handler.rb:35:in `block in <class:AliasHandler>'
	/Users/adfoster/.rvm/gems/ruby-2.7.2/gems/yard-0.9.26/lib/yard/handlers/processor.rb:114:in `block (2 levels) in process'
	/Users/adfoster/.rvm/gems/ruby-2.7.2/gems/yard-0.9.26/lib/yard/handlers/processor.rb:112:in `each'

[warn]: in YARD::Handlers::Ruby::ClassHandler: Undocumentable superclass (class was added without superclass)
	in file 'lib/metasploit_data_models/change_required_columns_to_null_false.rb':5:

	5: class MetasploitDataModels::ChangeRequiredColumnsToNullFalse < ActiveRecord::Migration[4.2]

Warning: Ignoring invalid association :task_creds on Mdm::Cred (model Mdm::TaskCred exists, but is not included in domain)
Warning: Ignoring invalid association :tasks on Mdm::Cred (model Mdm::Task exists, but is not included in domain)
Warning: Ignoring invalid association :task_hosts on Mdm::Host (model Mdm::TaskHost exists, but is not included in domain)
Warning: Ignoring invalid association :tasks on Mdm::Host (model Mdm::Task exists, but is not included in domain)
Warning: Ignoring invalid association :task on Mdm::Listener (model Mdm::Task exists, but is not included in domain)
Warning: Ignoring invalid association :task_services on Mdm::Service (model Mdm::TaskService exists, but is not included in domain)
Warning: Ignoring invalid association :tasks on Mdm::Service (model Mdm::Task exists, but is not included in domain)
Warning: Ignoring invalid association :task_sessions on Mdm::Session (model Mdm::TaskSession exists, but is not included in domain)
Warning: Ignoring invalid association :tasks on Mdm::Session (model Mdm::Task exists, but is not included in domain)
Warning: Ignoring invalid association :origin on Mdm::Vuln (polymorphic interface Origin does not exist)
Warning: Ignoring invalid association :automatic_exploitation_match_sets on Mdm::Workspace (uninitialized constant Mdm::Workspace::MetasploitDataModels::AutomaticExploitation:MatchSet)
Warning: Ignoring invalid association :tasks on Mdm::Workspace (model Mdm::Task exists, but is not included in domain)
Warning: Ignoring invalid association :match_results on MetasploitDataModels::AutomaticExploitation::Match (model MetasploitDataModels::AutomaticExploitation::MatchResult exists, but is not included in domain)
Warning: Ignoring invalid association :match_results on MetasploitDataModels::AutomaticExploitation::Run (model MetasploitDataModels::AutomaticExploitation::MatchResult exists, but is not included in domain)
[warn]: In file `app/models/mdm/task.rb':1: Cannot resolve link to Mdm::Module::Class#full_name from text:
	...{Mdm::Module::Class#full_name Module full name}...
[warn]: In file `app/models/mdm/task.rb':1: Cannot resolve link to Mdm::Module::Class#full_name from text:
	...{Mdm::Module::Class#full_name Module full name}...
[warn]: In file `app/models/mdm/exploited_host.rb':1: Cannot resolve link to Mdm::Module::Class#full_name from text:
	...{Mdm::Module::Class#full_name Full name of the payload module}...
[warn]: In file `app/models/mdm/exploited_host.rb':1: Cannot resolve link to Mdm::Module::Class#full_name from text:
	...{Mdm::Module::Class#full_name Full name of the payload module}...
Files:         100
Modules:        24 (    0 undocumented)
Classes:        78 (    0 undocumented)
Constants:      54 (    0 undocumented)
Attributes:    251 (    0 undocumented)
Methods:      1127 (    0 undocumented)
 100.00% documented

@adfoster-r7 adfoster-r7 force-pushed the add-explicit-webrick-dependency branch 2 times, most recently from c0525cc to 846d818 Compare February 3, 2021 21:35
@adfoster-r7 adfoster-r7 force-pushed the add-explicit-webrick-dependency branch from 846d818 to d5784d0 Compare February 4, 2021 16:26
@adfoster-r7 adfoster-r7 merged commit 063e4dc into rapid7:master Feb 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant