# Copyright (c) 2023 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details. # frozen_string_literal: true require 'contrast/agent/reporting/reporting_events/discovered_route' module Contrast module Framework # The API for all subclasses to implement to correctly support a given framework module BaseSupport # The top level module name used by the framework # @raise [NoMethodError] raises error if subclass does not implement this method def detection_class raise(NoMethodError('Subclasses of BaseSupport should implement this method')) end # @raise [NoMethodError] raises error if subclass does not implement this method def version raise(NoMethodError('Subclasses of BaseSupport should implement this method')) end # @raise [NoMethodError] raises error if subclass does not implement this method def application_name raise(NoMethodError, 'Subclasses of BaseSupport should implement this method') end # @raise [NoMethodError] raises error if subclass does not implement this method def server_type raise(NoMethodError, 'Subclasses of BaseSupport should implement this method') end # Find all the predefined routes for this application # # @return [Array] # @raise [NoMethodError] raises error if subclass does not implement this method def collect_routes raise(NoMethodError, 'Subclasses of BaseSupport should implement this method') end # @raise [NoMethodError] raises error if subclass does not implement this method def current_route_coverage raise(NoMethodError, 'Subclasses of BaseSupport should implement this method') end # @raise [NoMethodError] raises error if subclass does not implement this method def retrieve_request _env raise(NoMethodError, 'Subclasses of BaseSupport should implement this method') end # Some Frameworks require specific patching for their classes to handle # functionality like configuration scanning. To accommodate this, this # method provides a place to register those patches for invocation on # Agent load. # # By default, and hopefully in all cases, we won't need these patches, # so we're allowing nil here rather than raising an exception. def before_load_patches!; end # Some Frameworks require specific patching for their classes to handle # functionality like routing. To accommodate this, this method provides # a place to register those patches for invocation in our # AfterLoadPatcher flow. # # By default, and hopefully in all cases, we won't need these patches, # so we're allowing nil here rather than raising an exception. # # @return [Set,nil] # those patches required for a Framework which can only be installed # once a specific module has been loaded. def after_load_patches; end # We only support websockets in rails right now, so we won't detect streaming in # any other framework def streaming? _env false end end end end