CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!
CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!
Path: blob/master/lib/msf/base/simple/framework/module_paths.rb
Views: 1904
# -*- coding: binary -*-1require 'rails'2module Msf3module Simple4module Framework5module ModulePaths67attr_accessor :configured_module_paths8attr_accessor :module_paths_inited910# Initialize the module paths11#12# @return [void]13def init_module_paths(opts = {})14if @module_paths_inited15raise 'Module paths already initialized. To add more module paths call `modules.add_module_path`'16end1718@configured_module_paths = []19extract_engine_module_paths(Rails.application).each do |path|20@configured_module_paths << path21end2223if Msf::Config.user_module_directory24@configured_module_paths << Msf::Config.user_module_directory25end2627::Rails::Engine.subclasses.map(&:instance).each do |engine|28extract_engine_module_paths(engine).each do |path|29@configured_module_paths << path30end31end3233# If additional module paths have been defined globally, then load them.34# They should be separated by semi-colons.35self.datastore['MsfModulePaths'].to_s.split(";").each do |path|36@configured_module_paths << path37end3839# If the caller had additional paths to search, load them.40# They should be separated by semi-colons.41opts.delete(:module_paths).to_s.split(";").each do |path|42@configured_module_paths << path43end4445# Remove any duplicate paths46@configured_module_paths.uniq!47# return early if we're deferring module loading48return if opts.delete(:defer_module_loads)4950# Update the module cache from the database51self.modules.refresh_cache_from_database(@configured_module_paths)5253# Load each of the module paths54@configured_module_paths.each do |path|55self.modules.add_module_path(path, opts, recalculate: false)56end5758@module_paths_inited = true59end6061private6263# Extract directories `engine.paths['modules']` from `engine`.64#65# @param engine [Rails::Engine] a rails engine or application66# @return [Array<String>] The list of module paths to load67def extract_engine_module_paths(engine)68engine.paths['modules'] ? engine.paths['modules'].existent_directories : []69end7071end72end73end74end757677