From 3653b92e473b228ee3ac10463129b604ad3aaccd Mon Sep 17 00:00:00 2001 From: Dean Welch Date: Fri, 3 Jul 2026 16:59:31 +0100 Subject: [PATCH] Add feature flag to skip checksum validation for faster development boot --- lib/msf/core/feature_manager.rb | 8 ++++++++ lib/msf/ui/console/driver.rb | 20 +++++++++++-------- .../ui/console/driver_skip_checksum_spec.rb | 20 +++++++++++++++++++ 3 files changed, 40 insertions(+), 8 deletions(-) create mode 100644 spec/lib/msf/ui/console/driver_skip_checksum_spec.rb diff --git a/lib/msf/core/feature_manager.rb b/lib/msf/core/feature_manager.rb index 27e0619193d59..362c41489461b 100644 --- a/lib/msf/core/feature_manager.rb +++ b/lib/msf/core/feature_manager.rb @@ -19,6 +19,7 @@ class FeatureManager MANAGER_COMMANDS = 'manager_commands' METASPLOIT_PAYLOAD_WARNINGS = 'metasploit_payload_warnings' DEFER_MODULE_LOADS = 'defer_module_loads' + SKIP_CHECKSUM_VALIDATION = 'skip_checksum_validation' DNS = 'dns' HIERARCHICAL_SEARCH_TABLE = 'hierarchical_search_table' SMB_SESSION_TYPE = 'smb_session_type' @@ -62,6 +63,13 @@ class FeatureManager default_value: true, developer_notes: 'Enabled in Metasploit 6.4.x' }.freeze, + { + name: SKIP_CHECKSUM_VALIDATION, + description: 'When enabled skips module file checksum validation at boot, improving startup time. Use reload_all to refresh modules after changes.', + requires_restart: true, + default_value: false, + developer_notes: 'Useful for developers who want faster boot and can reload_all manually when modules change' + }.freeze, { name: SMB_SESSION_TYPE, description: 'When enabled will allow for the creation/use of smb sessions', diff --git a/lib/msf/ui/console/driver.rb b/lib/msf/ui/console/driver.rb index 84e2951f67e65..90b85e7a2a9fb 100644 --- a/lib/msf/ui/console/driver.rb +++ b/lib/msf/ui/console/driver.rb @@ -72,14 +72,18 @@ def initialize(prompt = DefaultPrompt, prompt_char = DefaultPromptChar, opts = { elog(e) end - # Check if files have been modified and force immediate loading if so - has_modified_metasploit_files = !Msf::Modules::Metadata::Store.valid_checksum? - - if has_modified_metasploit_files - current_checksum = Msf::Modules::Metadata::Store.get_current_checksum - Msf::Modules::Metadata::Store.update_cache_checksum(current_checksum) - # Force immediate module loading when files have changed - opts['DeferModuleLoads'] = false + # Check if files have been modified and force immediate loading if so. + # Can be skipped via feature flag for faster dev boots (use reload_all to refresh). + has_modified_metasploit_files = false + unless Msf::FeatureManager.instance.enabled?(Msf::FeatureManager::SKIP_CHECKSUM_VALIDATION) + has_modified_metasploit_files = !Msf::Modules::Metadata::Store.valid_checksum? + + if has_modified_metasploit_files + current_checksum = Msf::Modules::Metadata::Store.get_current_checksum + Msf::Modules::Metadata::Store.update_cache_checksum(current_checksum) + # Force immediate module loading when files have changed + opts['DeferModuleLoads'] = false + end end if opts['DeferModuleLoads'].nil? diff --git a/spec/lib/msf/ui/console/driver_skip_checksum_spec.rb b/spec/lib/msf/ui/console/driver_skip_checksum_spec.rb new file mode 100644 index 0000000000000..413a15fd72ec9 --- /dev/null +++ b/spec/lib/msf/ui/console/driver_skip_checksum_spec.rb @@ -0,0 +1,20 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe 'Skip checksum validation feature flag' do + it 'is registered in the FeatureManager' do + expect(Msf::FeatureManager.instance.exists?('skip_checksum_validation')).to be true + end + + it 'is disabled by default' do + expect(Msf::FeatureManager.instance.enabled?('skip_checksum_validation')).to be false + end + + it 'can be enabled' do + Msf::FeatureManager.instance.set('skip_checksum_validation', true) + expect(Msf::FeatureManager.instance.enabled?('skip_checksum_validation')).to be true + ensure + Msf::FeatureManager.instance.set('skip_checksum_validation', false) + end +end