Defer loading rex/metasm/octokit/etc dependencies#21342
Merged
adfoster-r7 merged 1 commit intorapid7:masterfrom May 1, 2026
Merged
Defer loading rex/metasm/octokit/etc dependencies#21342adfoster-r7 merged 1 commit intorapid7:masterfrom
adfoster-r7 merged 1 commit intorapid7:masterfrom
Conversation
b07a040 to
9adf8e8
Compare
9adf8e8 to
0724b0d
Compare
0724b0d to
b4d2c10
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
This PR defers loading several heavy gem dependencies (dnsruby/metasm/rkelly/octokit/bcrypt/recog/zip) to reduce boot-time cost, primarily by replacing eager requires with autoloads and localized requires, and by avoiding dnsruby constants in Rex::Proto::DNS::StaticHostnames.
Changes:
- Add global gem autoloads in
msf_autoload.rband move some requires (e.g.,octokit,rkelly) to first-use sites. - Update Rex DNS static hostnames to use locally-defined A/AAAA type constants instead of referencing dnsruby during boot, with added spec coverage.
- Update bundled dependencies (Gemfile.lock) and schema.rb to reflect upstream gem updates.
Reviewed changes
Copilot reviewed 19 out of 20 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| spec/lib/rex/proto/dns/static_hostnames_spec.rb | Adds assertions that local DNS type constants match dnsruby types. |
| modules/payloads/stages/netware/shell.rb | Removes eager require 'metasm' for deferred loading. |
| modules/payloads/stagers/netware/reverse_tcp.rb | Removes eager require 'metasm' for deferred loading. |
| lib/rex/proto/http/response.rb | Defers rkelly loading to get_html_scripts; trims whitespace. |
| lib/rex/proto/dns/static_hostnames.rb | Introduces local TYPE_A / TYPE_AAAA to avoid dnsruby load at boot. |
| lib/rex/proto/dns/resolver.rb | Removes eager require 'dnsruby' (now relies on deferred loading). |
| lib/rex/proto/dns/packet.rb | Removes eager require 'dnsruby' (now relies on deferred loading). |
| lib/rex.rb | Adds Rex-level autoloads for several subcomponents; removes eager requires for those. |
| lib/msf_autoload.rb | Adds top-level autoloads for common gems (BCrypt/Dnsruby/Metasm/Recog/Zip). |
| lib/msf/util/exe/common.rb | Removes eager require 'metasm'. |
| lib/msf/util/document_generator/pull_request_finder.rb | Defers octokit require until initialization. |
| lib/msf/core/payload.rb | Removes eager require 'metasm'. |
| lib/msf/core/framework.rb | Removes eager require 'rex/socket/ssl' (still loaded via cert provider path). |
| lib/msf/core/exploit/remote/smb/client.rb | Removes eager require 'recog' to rely on deferred loading. |
| lib/msf/core/exe/segment_injector.rb | Removes eager require 'metasm'. |
| lib/msf/core/exe/segment_appender.rb | Removes eager require 'metasm'. |
| lib/msf/core/db_manager/user.rb | Removes eager require 'bcrypt' to rely on deferred loading. |
| lib/metasploit/framework.rb | Removes eager requires for several gems now intended to load on demand. |
| db/schema.rb | Updates schema version and adds new columns reflecting upstream model changes. |
| Gemfile.lock | Bumps several gem versions required for the dependency deferral work. |
Impact Analysis:
- Blast radius: high (boot/loading path touches Rex and Msf initialization; downstream consumers include most framework entrypoints and modules); some effects are Unknown outside typical
require 'msf'load order. - Data and contract effects: adds
check_code/check_detailcolumns and updates schema version; dependency versions changed (potential compatibility impacts with external tooling/plugins are Unknown from diff). - Rollback and test focus: rollback is mostly reverting require/autoload changes plus gem lock/schema; focus validation on DNS resolution paths, payload/exe generation paths that use Metasm, and any callers using Rex DNS components outside the normal
msf_autoloadinitialization path.
b4d2c10 to
715e41e
Compare
715e41e to
557ff0d
Compare
Contributor
|
Benchmarks: |
Contributor
Release NotesDefers the loading of some dependencies to improve console boot time. |
cgranleese-r7
approved these changes
May 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Defer loading dependencies
Requires
Verification