Sha256: 197fd977569e25e0f92f678c6e60d8b39e091e8c6175ada9f3adc13894a77561
Contents?: true
Size: 1.84 KB
Versions: 5
Compression:
Stored size: 1.84 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' require 'contrast/agent/reporting/reporting_events/library_usage_observation' module Contrast module Agent module Reporting # List of libraries that have been observed to have something loaded or executed. # # @attr_reader observations - Array[Contrast::Agent::Reporting::LibraryUsageObservation] # - Hash of LibraryUsageObservations class ObservedLibraryUsage < Contrast::Agent::Reporting::ReportingEvent attr_reader :observations class << self # Convert a Hash of LibraryUsageUpdate DTMs for SpeedRacer to an Event for TeamServer. # # @param usages_dtm_hash Hash[Contrast::Api::Dtm::LibraryUsageUpdate] # @return [Contrast::Agent::Reporting::ObservedLibraryUsage] def convert usages_dtm_hash report = new report.attach_data(usages_dtm_hash) report end end def initialize @event_endpoint = Contrast::Agent::Reporting::Endpoints.library_usage @observations = [] super end def to_controlled_hash validate { observations: @observations.map(&:to_controlled_hash) } end def attach_data usages_dtm_hash usages_dtm_hash.each do |_key, value| next unless value.class_names.any? @observations << Contrast::Agent::Reporting::LibraryUsageObservation.convert(value) end end def validate raise(ArgumentError, "#{ self } did not have observations. Unable to continue.") if observations.empty? end end end end end
Version data entries
5 entries across 5 versions & 1 rubygems