Sha256: de143dfb282817b93aaf3ba20d2de26a1549c260338b861b8dd1857709a7f144
Contents?: true
Size: 1.93 KB
Versions: 3
Compression:
Stored size: 1.93 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/application_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::ApplicationReportingEvent 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 file_name 'library-observation' 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
3 entries across 3 versions & 1 rubygems