Sha256: 9ddf2f781b7087364c9b5b19688fba58d20a5ede3b0bd3e13ec48bc6471c93e3
Contents?: true
Size: 1.96 KB
Versions: 2
Compression:
Stored size: 1.96 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/reporting/reporting_events/reporting_event' module Contrast module Agent module Reporting # This class will initialize empty ServerActivity body to be send to TS. # The server activity endpoint records actions taken on the serveror process as a whole. # It currently only reports the number of times a defensive action was taken and is most # likely not populated by most agents. The main purpose of sending this message is for its # response, which contains any updated server feature settings from TeamServer. # The new Server Settings endpoint should let us remove this. class ServerActivity < Contrast::Agent::Reporting::ReportingEvent class << self # @param _server_activity_dtm [Contrast::Api::Dtm::ServerActivity] # @return [Contrast::Agent::Reporting::ServerActivity] def convert _server_activity_dtm new end end def initialize @event_method = :PUT @event_endpoint = "#{ Contrast::API.api_url }/api/ng/activity/servers" super end # Convert the instance variables on the class, and other information, into the identifiers required for # TeamServer to process the JSON form of this message. # # @return [Hash] # @raise [ArgumentError] def to_controlled_hash { lastUpdate: timestamp } end private # The timestamp field is a bit of a misnomer. It's really the time, in ms, since the settings for this # server have been updated. # # @return [Integer] def timestamp Contrast::Utils::Timer.now_ms - (Contrast::Agent.reporter&.client&.response_handler&.last_server_update_ms || 0) end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
contrast-agent-5.1.0 | lib/contrast/agent/reporting/reporting_events/server_activity.rb |
contrast-agent-5.0.0 | lib/contrast/agent/reporting/reporting_events/server_activity.rb |