Sha256: 92278f4b08d22aaaf2107ed8f2143d17353ce12038f85a2382546f113f4e44f4
Contents?: true
Size: 1.58 KB
Versions: 4
Compression:
Stored size: 1.58 KB
Contents
# Copyright (c) 2022 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details. # frozen_string_literal: true require 'contrast/agent/worker_thread' require 'contrast/agent/reporting/report' require 'contrast/components/logger' require 'contrast/agent/reporting/reporting_events/agent_startup' module Contrast module Agent # The ReporterHeartbeat will make sure that the process remains marked alive by TeamServer and that we periodically # reach out to get the latest settings for this application. class ReporterHeartbeat < WorkerThread include Contrast::Components::Logger::InstanceMethods # TeamServer will mark an application offline after 5 minutes. Sending this every one should be more than enough # to satisfy our goals. REFRESH_INTERVAL_SEC = 60 # check if we can report to TS # # @return[Boolean] true if bypass is enabled, or false if bypass disabled def enabled? @_enabled = Contrast::CONTRAST_SERVICE.use_agent_communication? if @_enabled.nil? @_enabled end def connection @_connection ||= client.initialize_connection end def start_thread! return if running? @_thread = Contrast::Agent::Thread.new do logger.info('Starting heartbeat thread.') loop do Contrast::Agent.reporter&.send_event(poll_message) sleep(REFRESH_INTERVAL_SEC) end end end def poll_message @_poll_message ||= Contrast::Agent::Reporting::Poll.new end end end end
Version data entries
4 entries across 4 versions & 1 rubygems