Module: Threatstack::Control
- Includes:
- Constants
- Defined in:
- lib/control.rb
Constant Summary collapse
- @@agent_initialized =
false
- @@agent_init_mutex =
Mutex.new
Constants included from Constants
Threatstack::Constants::AGENT_ID, Threatstack::Constants::AGENT_INSTANCE_ID, Threatstack::Constants::AGENT_NAME, Threatstack::Constants::AGENT_VERSION, Threatstack::Constants::APPSEC_BASE_URL, Threatstack::Constants::APPSEC_EVENTS_URL, Threatstack::Constants::ATTACK, Threatstack::Constants::AWS_METADATA_URL, Threatstack::Constants::BLOCK_PATH_TRAVERSAL, Threatstack::Constants::BLOCK_SQLI, Threatstack::Constants::BLOCK_XSS, Threatstack::Constants::CGI_VARIABLES, Threatstack::Constants::DEPENDENCIES, Threatstack::Constants::DETECTED_NOT_BLOCKED, Threatstack::Constants::DETECT_ATTACKS_ONLY, Threatstack::Constants::DETECT_PATH_TRAVERSAL, Threatstack::Constants::DISABLED, Threatstack::Constants::DROP_FIELDS, Threatstack::Constants::ENVIRONMENT, Threatstack::Constants::EVENTS_PER_REQ, Threatstack::Constants::FILTER_BY_PATH, Threatstack::Constants::INSTRUMENTATION, Threatstack::Constants::IPV4, Threatstack::Constants::IPV6, Threatstack::Constants::JOB_INTERVAL, Threatstack::Constants::LOG_COLORS, Threatstack::Constants::LOG_LEVEL, Threatstack::Constants::MANUAL_INIT, Threatstack::Constants::MAX_QUEUED_EVENTS, Threatstack::Constants::PATH_TRAVERSAL, Threatstack::Constants::REDACTED, Threatstack::Constants::REQUEST_BLOCKED, Threatstack::Constants::ROOT_DIR, Threatstack::Constants::RUBY, Threatstack::Constants::SQLI, Threatstack::Constants::TRUTHY, Threatstack::Constants::XSS
Class Method Summary collapse
Methods included from Constants
Class Method Details
._setup_agent ⇒ Object
73 74 75 76 |
# File 'lib/control.rb', line 73 def self._setup_agent # initialize agent unless DISABLED or set to MANUAL_INIT self.init unless DISABLED || MANUAL_INIT end |
.init ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/control.rb', line 22 def self.init @@agent_init_mutex.synchronize do return if @@agent_initialized @@agent_initialized = true end logger = Threatstack::Utils::TSLogger.create 'MainAgent' logger.info 'Initializing Threatstack Ruby agent' ############################## Instrumentation ############################## ## patch Rails ActionController logger.info 'Instrumenting Rails...' Threatstack::Instrumentation::Frameworks::TSRails.patch_action_controller logger.info 'Done instrumenting Rails' if(!DETECT_ATTACKS_ONLY) ## patch Kernel methods logger.info 'Instrumenting Kernel methods...' Threatstack::Instrumentation::Frameworks::TSKernel.wrap_methods logger.info 'Done instrumenting Kernel methods' end ## patch Kernel methods # logger.info 'Instrumenting Random methods...' # Threatstack::Instrumentation::Frameworks::TSRandom.wrap_methods # logger.info 'Done instrumenting Random methods' ############################## Event Submitter ############################## # Start EventSubmitter asynchronously logger.info 'Starting Event Submitter...' Threatstack::Jobs::EventSubmitter.instance.start logger.info 'Started Event Submitter' if(!DETECT_ATTACKS_ONLY) ############################## Delayed Tasks ############################## # Gather environment and dependency info asynchronously Threatstack::Jobs::DelayedJob.new(logger, 5) do dep_event = Threatstack::Events::DependencyEvent.new # submit dependency event Threatstack::Jobs::EventSubmitter.instance.queue_event dep_event # submit environment event Threatstack::Jobs::EventSubmitter.instance.queue_event Threatstack::Events::EnvironmentEvent.new end # Report Rails config once it's loaded Threatstack::Jobs::DelayedJob.new('DelayedConfig', 20) do Threatstack::Instrumentation::Frameworks::TSRails.report_application_config end end logger.info 'Initialization done for agent' end |