Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rapid7
GitHub Repository: rapid7/metasploit-framework
Path: blob/master/config/application.rb
21463 views
1
require 'fiddle'
2
Fiddle.const_set(:VERSION, '0.0.0') unless Fiddle.const_defined?(:VERSION)
3
4
require 'rails'
5
require File.expand_path('../boot', __FILE__)
6
7
require 'action_view'
8
# Monkey patch https://github.com/rails/rails/blob/v7.2.2.1/actionview/lib/action_view/helpers/tag_helper.rb#L51
9
# Might be fixed by 8.x https://github.com/rails/rails/blob/v8.0.2/actionview/lib/action_view/helpers/tag_helper.rb#L51C1-L52C1
10
raise unless ActionView::VERSION::STRING == '7.2.2.1' # A developer will need to ensure this is still required when bumping rails
11
module ActionView::Helpers::TagHelper
12
class TagBuilder
13
def self.define_element(name, code_generator:, method_name: name.to_s.underscore)
14
code_generator.define_cached_method(method_name, namespace: :tag_builder) do |batch|
15
# Fixing a bug introduced by Metasploit's global Kernel patch: https://github.com/rapid7/metasploit-framework/blob/ae1db09f32cd04c007dbf445cf16dc22c9fc2e53/lib/rex.rb#L74-L79
16
# which fails when using the below 'instance_methods.include?(method_name.to_sym)' check
17
batch.push(<<~RUBY) # unless instance_methods.include?(method_name.to_sym)
18
def #{method_name}(content = nil, escape: true, **options, &block)
19
tag_string("#{name}", content, options, escape: escape, &block)
20
end
21
RUBY
22
end
23
end
24
end
25
end
26
27
all_environments = [
28
:development,
29
:production,
30
:test
31
]
32
33
Bundler.require(
34
*Rails.groups(
35
coverage: [:test],
36
db: all_environments,
37
pcap: all_environments
38
)
39
)
40
41
#
42
# Railties
43
#
44
45
# For compatibility with jquery-rails (and other engines that need action_view) in pro
46
require 'action_controller/railtie'
47
require 'action_view/railtie'
48
49
#
50
# Project
51
#
52
53
require 'metasploit/framework/common_engine'
54
require 'metasploit/framework/database'
55
module Metasploit
56
module Framework
57
class Application < Rails::Application
58
include Metasploit::Framework::CommonEngine
59
60
config.paths['log'] = "#{Msf::Config.log_directory}/#{Rails.env}.log"
61
config.paths['config/database'] = [Metasploit::Framework::Database.configurations_pathname.try(:to_path)]
62
config.autoloader = :zeitwerk
63
64
config.load_defaults 7.2
65
66
config.eager_load = false
67
end
68
end
69
end
70
71
# Silence warnings about this defaulting to true
72
I18n.enforce_available_locales = true
73
require 'msfenv'
74
75