ddtrace 1.10.0 → 1.11.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +86 -2
- data/LICENSE-3rdparty.csv +1 -0
- data/README.md +8 -9
- data/ext/ddtrace_profiling_native_extension/collectors_cpu_and_wall_time_worker.c +76 -11
- data/ext/ddtrace_profiling_native_extension/collectors_thread_context.c +26 -3
- data/ext/ddtrace_profiling_native_extension/private_vm_api_access.c +3 -0
- data/lib/datadog/appsec/component.rb +41 -7
- data/lib/datadog/appsec/configuration/settings.rb +20 -4
- data/lib/datadog/appsec/configuration.rb +8 -0
- data/lib/datadog/appsec/contrib/auto_instrument.rb +2 -0
- data/lib/datadog/appsec/contrib/configuration/settings.rb +2 -0
- data/lib/datadog/appsec/contrib/integration.rb +2 -0
- data/lib/datadog/appsec/contrib/patcher.rb +2 -0
- data/lib/datadog/appsec/contrib/rack/configuration/settings.rb +2 -0
- data/lib/datadog/appsec/contrib/rack/gateway/request.rb +7 -25
- data/lib/datadog/appsec/contrib/rack/gateway/response.rb +1 -1
- data/lib/datadog/appsec/contrib/rack/patcher.rb +2 -0
- data/lib/datadog/appsec/contrib/rack/reactive/response.rb +6 -0
- data/lib/datadog/appsec/contrib/rack/request_middleware.rb +17 -3
- data/lib/datadog/appsec/contrib/rails/configuration/settings.rb +2 -0
- data/lib/datadog/appsec/contrib/rails/framework.rb +2 -0
- data/lib/datadog/appsec/contrib/rails/gateway/request.rb +1 -1
- data/lib/datadog/appsec/contrib/rails/request.rb +2 -0
- data/lib/datadog/appsec/contrib/rails/request_middleware.rb +2 -0
- data/lib/datadog/appsec/contrib/sinatra/configuration/settings.rb +2 -0
- data/lib/datadog/appsec/contrib/sinatra/framework.rb +2 -0
- data/lib/datadog/appsec/contrib/sinatra/gateway/route_params.rb +1 -1
- data/lib/datadog/appsec/contrib/sinatra/request_middleware.rb +2 -0
- data/lib/datadog/appsec/extensions.rb +2 -0
- data/lib/datadog/appsec/instrumentation/gateway/argument.rb +2 -4
- data/lib/datadog/appsec/processor/rule_loader.rb +63 -0
- data/lib/datadog/appsec/processor/rule_merger.rb +146 -0
- data/lib/datadog/appsec/processor.rb +15 -70
- data/lib/datadog/appsec/remote.rb +121 -0
- data/lib/datadog/appsec/utils/http.rb +2 -0
- data/lib/datadog/appsec/utils.rb +2 -0
- data/lib/datadog/appsec.rb +18 -4
- data/lib/datadog/ci/configuration/components.rb +2 -0
- data/lib/datadog/ci/configuration/settings.rb +2 -0
- data/lib/datadog/ci/contrib/cucumber/configuration/settings.rb +2 -0
- data/lib/datadog/ci/contrib/cucumber/formatter.rb +2 -0
- data/lib/datadog/ci/contrib/cucumber/instrumentation.rb +2 -0
- data/lib/datadog/ci/contrib/cucumber/patcher.rb +2 -0
- data/lib/datadog/ci/contrib/rspec/configuration/settings.rb +2 -0
- data/lib/datadog/ci/contrib/rspec/patcher.rb +2 -0
- data/lib/datadog/ci/ext/environment.rb +2 -20
- data/lib/datadog/ci/extensions.rb +2 -0
- data/lib/datadog/ci/flush.rb +2 -0
- data/lib/datadog/ci.rb +2 -0
- data/lib/datadog/core/buffer/cruby.rb +2 -0
- data/lib/datadog/core/buffer/random.rb +2 -0
- data/lib/datadog/core/buffer/thread_safe.rb +2 -0
- data/lib/datadog/core/chunker.rb +2 -0
- data/lib/datadog/core/configuration/agent_settings_resolver.rb +6 -6
- data/lib/datadog/core/configuration/components.rb +12 -15
- data/lib/datadog/core/configuration/dependency_resolver.rb +2 -0
- data/lib/datadog/core/configuration/option.rb +2 -0
- data/lib/datadog/core/configuration/option_definition.rb +2 -0
- data/lib/datadog/core/configuration/option_definition_set.rb +2 -0
- data/lib/datadog/core/configuration/option_set.rb +2 -0
- data/lib/datadog/core/configuration/settings.rb +68 -13
- data/lib/datadog/core/diagnostics/health.rb +2 -0
- data/lib/datadog/core/environment/class_count.rb +2 -0
- data/lib/datadog/core/environment/gc.rb +2 -0
- data/lib/datadog/core/environment/identity.rb +2 -0
- data/lib/datadog/core/environment/socket.rb +2 -0
- data/lib/datadog/core/environment/thread_count.rb +2 -0
- data/lib/datadog/core/environment/variable_helpers.rb +10 -2
- data/lib/datadog/core/environment/vm_cache.rb +2 -0
- data/lib/datadog/core/extensions.rb +2 -0
- data/lib/datadog/core/header_collection.rb +2 -0
- data/lib/datadog/core/metrics/helpers.rb +2 -0
- data/lib/datadog/core/metrics/metric.rb +2 -0
- data/lib/datadog/core/remote/client/capabilities.rb +57 -0
- data/lib/datadog/core/remote/client.rb +146 -0
- data/lib/datadog/core/remote/component.rb +150 -0
- data/lib/datadog/core/remote/configuration/content.rb +82 -0
- data/lib/datadog/core/remote/configuration/digest.rb +62 -0
- data/lib/datadog/core/remote/configuration/path.rb +90 -0
- data/lib/datadog/core/remote/configuration/repository.rb +278 -0
- data/lib/datadog/core/remote/configuration/target.rb +72 -0
- data/lib/datadog/core/remote/configuration.rb +18 -0
- data/lib/datadog/core/remote/dispatcher.rb +59 -0
- data/lib/datadog/core/remote/ext.rb +12 -0
- data/lib/datadog/core/remote/worker.rb +96 -0
- data/lib/datadog/core/remote.rb +24 -0
- data/lib/datadog/core/telemetry/collector.rb +8 -9
- data/lib/datadog/core/telemetry/heartbeat.rb +2 -0
- data/lib/datadog/core/telemetry/http/env.rb +2 -0
- data/lib/datadog/core/telemetry/http/transport.rb +2 -0
- data/lib/datadog/core/telemetry/v1/app_event.rb +2 -0
- data/lib/datadog/core/telemetry/v1/application.rb +7 -1
- data/lib/datadog/core/telemetry/v1/dependency.rb +7 -1
- data/lib/datadog/core/telemetry/v1/host.rb +9 -1
- data/lib/datadog/core/telemetry/v1/integration.rb +7 -1
- data/lib/datadog/core/telemetry/v1/product.rb +9 -1
- data/lib/datadog/core/telemetry/v1/telemetry_request.rb +7 -1
- data/lib/datadog/core/transport/config.rb +58 -0
- data/lib/datadog/core/transport/http/api/instance.rb +37 -0
- data/lib/datadog/core/transport/http/api/spec.rb +19 -0
- data/lib/datadog/core/transport/http/api.rb +57 -0
- data/lib/datadog/core/transport/http/builder.rb +217 -0
- data/lib/datadog/core/transport/http/client.rb +45 -0
- data/lib/datadog/core/transport/http/config.rb +268 -0
- data/lib/datadog/core/transport/http/negotiation.rb +144 -0
- data/lib/datadog/core/transport/http.rb +169 -0
- data/lib/datadog/core/transport/negotiation.rb +60 -0
- data/lib/datadog/core/utils/compression.rb +2 -0
- data/lib/datadog/core/utils/hash.rb +32 -0
- data/lib/datadog/core/utils/network.rb +140 -0
- data/lib/datadog/core/utils/object_set.rb +2 -0
- data/lib/datadog/core/utils/safe_dup.rb +20 -2
- data/lib/datadog/core/utils/sequence.rb +2 -0
- data/lib/datadog/core/utils/time.rb +2 -0
- data/lib/datadog/core/vendor/ipaddr.rb +78 -0
- data/lib/datadog/core/worker.rb +2 -0
- data/lib/datadog/core/workers/interval_loop.rb +2 -0
- data/lib/datadog/core/workers/queue.rb +2 -0
- data/lib/datadog/core/workers/runtime_metrics.rb +2 -0
- data/lib/datadog/kit/appsec/events.rb +1 -1
- data/lib/datadog/kit.rb +2 -0
- data/lib/datadog/opentracer/binary_propagator.rb +2 -0
- data/lib/datadog/opentracer/carrier.rb +2 -0
- data/lib/datadog/opentracer/global_tracer.rb +2 -0
- data/lib/datadog/opentracer/propagator.rb +2 -0
- data/lib/datadog/opentracer/scope.rb +2 -0
- data/lib/datadog/opentracer/scope_manager.rb +2 -0
- data/lib/datadog/opentracer/span_context.rb +2 -0
- data/lib/datadog/opentracer/span_context_factory.rb +2 -0
- data/lib/datadog/opentracer/thread_local_scope.rb +2 -0
- data/lib/datadog/opentracer.rb +2 -0
- data/lib/datadog/profiling/backtrace_location.rb +2 -0
- data/lib/datadog/profiling/buffer.rb +2 -0
- data/lib/datadog/profiling/collectors/cpu_and_wall_time_worker.rb +19 -3
- data/lib/datadog/profiling/collectors/dynamic_sampling_rate.rb +2 -0
- data/lib/datadog/profiling/collectors/idle_sampling_helper.rb +1 -1
- data/lib/datadog/profiling/collectors/stack.rb +2 -0
- data/lib/datadog/profiling/collectors/thread_context.rb +2 -2
- data/lib/datadog/profiling/component.rb +103 -29
- data/lib/datadog/profiling/event.rb +2 -0
- data/lib/datadog/profiling/events/stack.rb +2 -0
- data/lib/datadog/profiling/ext.rb +28 -26
- data/lib/datadog/profiling/flush.rb +2 -0
- data/lib/datadog/profiling/native_extension.rb +2 -0
- data/lib/datadog/profiling/pprof/message_set.rb +2 -0
- data/lib/datadog/profiling/pprof/payload.rb +2 -0
- data/lib/datadog/profiling/pprof/string_table.rb +2 -0
- data/lib/datadog/profiling/preload.rb +2 -0
- data/lib/datadog/profiling/scheduler.rb +3 -1
- data/lib/datadog/profiling/stack_recorder.rb +0 -18
- data/lib/datadog/profiling/tag_builder.rb +2 -0
- data/lib/datadog/profiling/tasks/setup.rb +0 -26
- data/lib/datadog/profiling.rb +2 -1
- data/lib/datadog/tracing/analytics.rb +2 -0
- data/lib/datadog/tracing/client_ip.rb +39 -140
- data/lib/datadog/tracing/configuration/ext.rb +7 -0
- data/lib/datadog/tracing/configuration/settings.rb +14 -0
- data/lib/datadog/tracing/context.rb +2 -0
- data/lib/datadog/tracing/contrib/action_cable/configuration/settings.rb +2 -0
- data/lib/datadog/tracing/contrib/action_cable/event.rb +2 -0
- data/lib/datadog/tracing/contrib/action_cable/events.rb +2 -0
- data/lib/datadog/tracing/contrib/action_cable/patcher.rb +2 -0
- data/lib/datadog/tracing/contrib/action_mailer/configuration/settings.rb +2 -0
- data/lib/datadog/tracing/contrib/action_mailer/event.rb +2 -0
- data/lib/datadog/tracing/contrib/action_mailer/events.rb +2 -0
- data/lib/datadog/tracing/contrib/action_mailer/patcher.rb +2 -0
- data/lib/datadog/tracing/contrib/action_pack/action_controller/instrumentation.rb +2 -24
- data/lib/datadog/tracing/contrib/action_pack/action_controller/patcher.rb +2 -0
- data/lib/datadog/tracing/contrib/action_pack/configuration/settings.rb +14 -1
- data/lib/datadog/tracing/contrib/action_pack/patcher.rb +2 -0
- data/lib/datadog/tracing/contrib/action_view/event.rb +2 -0
- data/lib/datadog/tracing/contrib/action_view/events.rb +2 -0
- data/lib/datadog/tracing/contrib/active_job/configuration/settings.rb +2 -0
- data/lib/datadog/tracing/contrib/active_job/event.rb +2 -0
- data/lib/datadog/tracing/contrib/active_job/events.rb +2 -0
- data/lib/datadog/tracing/contrib/active_job/log_injection.rb +2 -0
- data/lib/datadog/tracing/contrib/active_job/patcher.rb +2 -0
- data/lib/datadog/tracing/contrib/active_model_serializers/configuration/settings.rb +2 -0
- data/lib/datadog/tracing/contrib/active_model_serializers/event.rb +2 -0
- data/lib/datadog/tracing/contrib/active_model_serializers/events.rb +2 -0
- data/lib/datadog/tracing/contrib/active_model_serializers/patcher.rb +2 -0
- data/lib/datadog/tracing/contrib/active_record/configuration/settings.rb +2 -0
- data/lib/datadog/tracing/contrib/active_record/event.rb +2 -0
- data/lib/datadog/tracing/contrib/active_record/events.rb +2 -0
- data/lib/datadog/tracing/contrib/active_record/patcher.rb +2 -0
- data/lib/datadog/tracing/contrib/active_support/cache/instrumentation.rb +2 -0
- data/lib/datadog/tracing/contrib/active_support/cache/patcher.rb +2 -0
- data/lib/datadog/tracing/contrib/active_support/cache/redis.rb +2 -0
- data/lib/datadog/tracing/contrib/active_support/configuration/settings.rb +2 -0
- data/lib/datadog/tracing/contrib/active_support/notifications/event.rb +2 -0
- data/lib/datadog/tracing/contrib/active_support/notifications/subscriber.rb +2 -0
- data/lib/datadog/tracing/contrib/active_support/patcher.rb +2 -0
- data/lib/datadog/tracing/contrib/analytics.rb +2 -0
- data/lib/datadog/tracing/contrib/auto_instrument.rb +2 -0
- data/lib/datadog/tracing/contrib/aws/configuration/settings.rb +9 -1
- data/lib/datadog/tracing/contrib/aws/instrumentation.rb +8 -2
- data/lib/datadog/tracing/contrib/aws/patcher.rb +2 -0
- data/lib/datadog/tracing/contrib/concurrent_ruby/configuration/settings.rb +2 -0
- data/lib/datadog/tracing/contrib/concurrent_ruby/context_composite_executor_service.rb +2 -0
- data/lib/datadog/tracing/contrib/concurrent_ruby/future_patch.rb +2 -0
- data/lib/datadog/tracing/contrib/concurrent_ruby/patcher.rb +2 -0
- data/lib/datadog/tracing/contrib/configurable.rb +2 -0
- data/lib/datadog/tracing/contrib/configuration/resolver.rb +2 -0
- data/lib/datadog/tracing/contrib/configuration/resolvers/pattern_resolver.rb +2 -0
- data/lib/datadog/tracing/contrib/dalli/configuration/settings.rb +2 -0
- data/lib/datadog/tracing/contrib/dalli/patcher.rb +2 -0
- data/lib/datadog/tracing/contrib/delayed_job/configuration/settings.rb +2 -0
- data/lib/datadog/tracing/contrib/delayed_job/patcher.rb +2 -0
- data/lib/datadog/tracing/contrib/delayed_job/plugin.rb +2 -0
- data/lib/datadog/tracing/contrib/delayed_job/server_internal_tracer/worker.rb +2 -0
- data/lib/datadog/tracing/contrib/elasticsearch/configuration/settings.rb +2 -0
- data/lib/datadog/tracing/contrib/ethon/configuration/settings.rb +2 -0
- data/lib/datadog/tracing/contrib/ethon/multi_patch.rb +2 -0
- data/lib/datadog/tracing/contrib/ethon/patcher.rb +2 -0
- data/lib/datadog/tracing/contrib/excon/configuration/settings.rb +2 -0
- data/lib/datadog/tracing/contrib/excon/patcher.rb +2 -0
- data/lib/datadog/tracing/contrib/faraday/configuration/settings.rb +2 -0
- data/lib/datadog/tracing/contrib/faraday/connection.rb +2 -0
- data/lib/datadog/tracing/contrib/faraday/rack_builder.rb +2 -0
- data/lib/datadog/tracing/contrib/grape/configuration/settings.rb +2 -0
- data/lib/datadog/tracing/contrib/grape/patcher.rb +2 -0
- data/lib/datadog/tracing/contrib/graphql/configuration/settings.rb +2 -0
- data/lib/datadog/tracing/contrib/grpc/configuration/settings.rb +2 -0
- data/lib/datadog/tracing/contrib/grpc/intercept_with_datadog.rb +2 -0
- data/lib/datadog/tracing/contrib/grpc/patcher.rb +2 -0
- data/lib/datadog/tracing/contrib/hanami/action_tracer.rb +2 -0
- data/lib/datadog/tracing/contrib/hanami/configuration/settings.rb +2 -0
- data/lib/datadog/tracing/contrib/hanami/patcher.rb +2 -0
- data/lib/datadog/tracing/contrib/hanami/plugin.rb +2 -0
- data/lib/datadog/tracing/contrib/hanami/renderer_policy_tracing.rb +2 -0
- data/lib/datadog/tracing/contrib/hanami/router_tracing.rb +2 -0
- data/lib/datadog/tracing/contrib/http/circuit_breaker.rb +2 -0
- data/lib/datadog/tracing/contrib/http/configuration/settings.rb +2 -0
- data/lib/datadog/tracing/contrib/http/integration.rb +2 -0
- data/lib/datadog/tracing/contrib/http/patcher.rb +2 -0
- data/lib/datadog/tracing/contrib/http_annotation_helper.rb +2 -0
- data/lib/datadog/tracing/contrib/httpclient/configuration/settings.rb +2 -0
- data/lib/datadog/tracing/contrib/httprb/configuration/settings.rb +2 -0
- data/lib/datadog/tracing/contrib/integration.rb +2 -0
- data/lib/datadog/tracing/contrib/kafka/configuration/settings.rb +2 -0
- data/lib/datadog/tracing/contrib/kafka/consumer_event.rb +2 -0
- data/lib/datadog/tracing/contrib/kafka/consumer_group_event.rb +2 -0
- data/lib/datadog/tracing/contrib/kafka/event.rb +2 -0
- data/lib/datadog/tracing/contrib/kafka/events.rb +2 -0
- data/lib/datadog/tracing/contrib/kafka/patcher.rb +2 -0
- data/lib/datadog/tracing/contrib/lograge/configuration/settings.rb +2 -0
- data/lib/datadog/tracing/contrib/lograge/instrumentation.rb +2 -0
- data/lib/datadog/tracing/contrib/lograge/patcher.rb +2 -0
- data/lib/datadog/tracing/contrib/mongodb/configuration/settings.rb +2 -0
- data/lib/datadog/tracing/contrib/mongodb/instrumentation.rb +2 -0
- data/lib/datadog/tracing/contrib/mongodb/patcher.rb +2 -0
- data/lib/datadog/tracing/contrib/mysql2/configuration/settings.rb +2 -0
- data/lib/datadog/tracing/contrib/mysql2/instrumentation.rb +2 -0
- data/lib/datadog/tracing/contrib/mysql2/patcher.rb +2 -0
- data/lib/datadog/tracing/contrib/patchable.rb +2 -0
- data/lib/datadog/tracing/contrib/pg/configuration/settings.rb +2 -0
- data/lib/datadog/tracing/contrib/pg/instrumentation.rb +2 -0
- data/lib/datadog/tracing/contrib/pg/patcher.rb +2 -0
- data/lib/datadog/tracing/contrib/presto/configuration/settings.rb +2 -0
- data/lib/datadog/tracing/contrib/propagation/sql_comment/mode.rb +2 -0
- data/lib/datadog/tracing/contrib/qless/configuration/settings.rb +2 -0
- data/lib/datadog/tracing/contrib/qless/patcher.rb +2 -0
- data/lib/datadog/tracing/contrib/qless/tracer_cleaner.rb +2 -0
- data/lib/datadog/tracing/contrib/racecar/configuration/settings.rb +2 -0
- data/lib/datadog/tracing/contrib/racecar/event.rb +2 -0
- data/lib/datadog/tracing/contrib/racecar/events.rb +2 -0
- data/lib/datadog/tracing/contrib/racecar/patcher.rb +2 -0
- data/lib/datadog/tracing/contrib/rails/configuration/settings.rb +9 -2
- data/lib/datadog/tracing/contrib/rails/framework.rb +2 -0
- data/lib/datadog/tracing/contrib/rails/middlewares.rb +2 -0
- data/lib/datadog/tracing/contrib/rails/utils.rb +3 -1
- data/lib/datadog/tracing/contrib/rake/configuration/settings.rb +2 -0
- data/lib/datadog/tracing/contrib/rake/patcher.rb +2 -0
- data/lib/datadog/tracing/contrib/redis/configuration/settings.rb +2 -0
- data/lib/datadog/tracing/contrib/redis/tags.rb +2 -0
- data/lib/datadog/tracing/contrib/registerable.rb +2 -0
- data/lib/datadog/tracing/contrib/registry.rb +2 -0
- data/lib/datadog/tracing/contrib/resque/configuration/settings.rb +2 -0
- data/lib/datadog/tracing/contrib/resque/patcher.rb +2 -0
- data/lib/datadog/tracing/contrib/resque/resque_job.rb +2 -0
- data/lib/datadog/tracing/contrib/rest_client/configuration/settings.rb +2 -0
- data/lib/datadog/tracing/contrib/rest_client/patcher.rb +2 -0
- data/lib/datadog/tracing/contrib/rest_client/request_patch.rb +2 -0
- data/lib/datadog/tracing/contrib/roda/configuration/settings.rb +34 -0
- data/lib/datadog/tracing/contrib/roda/ext.rb +18 -0
- data/lib/datadog/tracing/contrib/roda/instrumentation.rb +76 -0
- data/lib/datadog/tracing/contrib/roda/integration.rb +45 -0
- data/lib/datadog/tracing/contrib/roda/patcher.rb +30 -0
- data/lib/datadog/tracing/contrib/semantic_logger/configuration/settings.rb +2 -0
- data/lib/datadog/tracing/contrib/semantic_logger/instrumentation.rb +3 -0
- data/lib/datadog/tracing/contrib/semantic_logger/patcher.rb +2 -0
- data/lib/datadog/tracing/contrib/sequel/configuration/settings.rb +2 -0
- data/lib/datadog/tracing/contrib/sequel/dataset.rb +2 -0
- data/lib/datadog/tracing/contrib/sequel/patcher.rb +2 -0
- data/lib/datadog/tracing/contrib/shoryuken/configuration/settings.rb +2 -0
- data/lib/datadog/tracing/contrib/shoryuken/patcher.rb +2 -0
- data/lib/datadog/tracing/contrib/shoryuken/tracer.rb +2 -0
- data/lib/datadog/tracing/contrib/sidekiq/client_tracer.rb +12 -3
- data/lib/datadog/tracing/contrib/sidekiq/configuration/settings.rb +3 -0
- data/lib/datadog/tracing/contrib/sidekiq/distributed/propagation.rb +38 -0
- data/lib/datadog/tracing/contrib/sidekiq/patcher.rb +2 -0
- data/lib/datadog/tracing/contrib/sidekiq/server_internal_tracer/heartbeat.rb +2 -0
- data/lib/datadog/tracing/contrib/sidekiq/server_internal_tracer/job_fetch.rb +2 -0
- data/lib/datadog/tracing/contrib/sidekiq/server_internal_tracer/redis_info.rb +2 -0
- data/lib/datadog/tracing/contrib/sidekiq/server_internal_tracer/scheduled_poller.rb +2 -0
- data/lib/datadog/tracing/contrib/sidekiq/server_tracer.rb +18 -2
- data/lib/datadog/tracing/contrib/sidekiq/{tracing.rb → utils.rb} +3 -1
- data/lib/datadog/tracing/contrib/sinatra/headers.rb +2 -0
- data/lib/datadog/tracing/contrib/sinatra/patcher.rb +2 -0
- data/lib/datadog/tracing/contrib/sinatra/tracer_middleware.rb +2 -0
- data/lib/datadog/tracing/contrib/span_attribute_schema.rb +28 -0
- data/lib/datadog/tracing/contrib/sucker_punch/configuration/settings.rb +2 -0
- data/lib/datadog/tracing/contrib/sucker_punch/exception_handler.rb +2 -0
- data/lib/datadog/tracing/contrib/sucker_punch/patcher.rb +2 -0
- data/lib/datadog/tracing/contrib/utils/quantization/http.rb +2 -2
- data/lib/datadog/tracing/contrib.rb +3 -0
- data/lib/datadog/tracing/correlation.rb +10 -10
- data/lib/datadog/tracing/diagnostics/health.rb +2 -0
- data/lib/datadog/tracing/distributed/trace_context.rb +22 -15
- data/lib/datadog/tracing/flush.rb +2 -0
- data/lib/datadog/tracing/metadata/analytics.rb +2 -0
- data/lib/datadog/tracing/metadata/errors.rb +2 -0
- data/lib/datadog/tracing/metadata/ext.rb +6 -0
- data/lib/datadog/tracing/metadata.rb +2 -0
- data/lib/datadog/tracing/pipeline/span_filter.rb +2 -0
- data/lib/datadog/tracing/pipeline/span_processor.rb +2 -0
- data/lib/datadog/tracing/propagation/http.rb +2 -0
- data/lib/datadog/tracing/runtime/metrics.rb +2 -0
- data/lib/datadog/tracing/sampling/all_sampler.rb +2 -0
- data/lib/datadog/tracing/sampling/matcher.rb +2 -0
- data/lib/datadog/tracing/sampling/priority_sampler.rb +2 -0
- data/lib/datadog/tracing/sampling/span/sampler.rb +2 -0
- data/lib/datadog/tracing/sync_writer.rb +2 -0
- data/lib/datadog/tracing/trace_digest.rb +2 -0
- data/lib/datadog/tracing/utils.rb +2 -0
- data/lib/datadog/tracing.rb +2 -0
- data/lib/ddtrace/auto_instrument.rb +2 -0
- data/lib/ddtrace/auto_instrument_base.rb +2 -0
- data/lib/ddtrace/transport/http/adapters/net.rb +12 -0
- data/lib/ddtrace/transport/http/adapters/registry.rb +2 -0
- data/lib/ddtrace/transport/http/api/endpoint.rb +2 -0
- data/lib/ddtrace/transport/http/api/fallbacks.rb +2 -0
- data/lib/ddtrace/transport/http/api/instance.rb +2 -0
- data/lib/ddtrace/transport/http/api/map.rb +2 -0
- data/lib/ddtrace/transport/http/api/spec.rb +2 -0
- data/lib/ddtrace/transport/http/env.rb +2 -0
- data/lib/ddtrace/transport/http/response.rb +2 -0
- data/lib/ddtrace/transport/http/traces.rb +1 -1
- data/lib/ddtrace/transport/io/response.rb +2 -0
- data/lib/ddtrace/transport/io/traces.rb +2 -0
- data/lib/ddtrace/transport/io.rb +2 -0
- data/lib/ddtrace/transport/parcel.rb +2 -0
- data/lib/ddtrace/transport/request.rb +3 -1
- data/lib/ddtrace/transport/statistics.rb +2 -0
- data/lib/ddtrace/transport/trace_formatter.rb +2 -0
- data/lib/ddtrace/transport/traces.rb +1 -1
- data/lib/ddtrace/version.rb +6 -4
- data/lib/ddtrace.rb +2 -0
- metadata +45 -9
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_relative 'configuration/settings'
|
2
4
|
|
3
5
|
module Datadog
|
@@ -82,6 +84,12 @@ module Datadog
|
|
82
84
|
def settings
|
83
85
|
@settings ||= Settings.new
|
84
86
|
end
|
87
|
+
|
88
|
+
private
|
89
|
+
|
90
|
+
def default_setting?(setting)
|
91
|
+
settings.send(:default?, setting)
|
92
|
+
end
|
85
93
|
end
|
86
94
|
end
|
87
95
|
end
|
@@ -1,8 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require_relative '../../../instrumentation/gateway/argument'
|
4
|
+
require_relative '../../../../core/header_collection'
|
4
5
|
require_relative '../../../../tracing/client_ip'
|
5
|
-
require_relative '../../../../tracing/contrib/rack/header_collection'
|
6
6
|
|
7
7
|
module Datadog
|
8
8
|
module AppSec
|
@@ -14,7 +14,7 @@ module Datadog
|
|
14
14
|
attr_reader :env
|
15
15
|
|
16
16
|
def initialize(env)
|
17
|
-
super
|
17
|
+
super()
|
18
18
|
@env = env
|
19
19
|
end
|
20
20
|
|
@@ -33,20 +33,9 @@ module Datadog
|
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
if defined?(::Rack) && ::Rack::Request.instance_methods.include?(:each_header)
|
40
|
-
def headers
|
41
|
-
request.each_header.each_with_object({}) do |(k, v), h|
|
42
|
-
h[k.gsub(/^HTTP_/, '').downcase.tr('_', '-')] = v if k =~ /^HTTP_/
|
43
|
-
end
|
44
|
-
end
|
45
|
-
else
|
46
|
-
def headers
|
47
|
-
request.env.each_with_object({}) do |(k, v), h|
|
48
|
-
h[k.gsub(/^HTTP_/, '').downcase.tr('_', '-')] = v if k =~ /^HTTP_/
|
49
|
-
end
|
36
|
+
def headers
|
37
|
+
request.env.each_with_object({}) do |(k, v), h|
|
38
|
+
h[k.gsub(/^HTTP_/, '').downcase.tr('_', '-')] = v if k =~ /^HTTP_/
|
50
39
|
end
|
51
40
|
end
|
52
41
|
|
@@ -85,16 +74,9 @@ module Datadog
|
|
85
74
|
|
86
75
|
def client_ip
|
87
76
|
remote_ip = remote_addr
|
88
|
-
|
89
|
-
|
90
|
-
result = Datadog::Tracing::ClientIp.raw_ip_from_request(headers, remote_ip)
|
77
|
+
header_collection = Datadog::Core::HeaderCollection.from_hash(headers)
|
91
78
|
|
92
|
-
|
93
|
-
ip = Datadog::Tracing::ClientIp.strip_decorations(result.raw_ip)
|
94
|
-
return unless Datadog::Tracing::ClientIp.valid_ip?(ip)
|
95
|
-
|
96
|
-
ip
|
97
|
-
end
|
79
|
+
Datadog::Tracing::ClientIp.extract_client_ip(header_collection, remote_ip)
|
98
80
|
end
|
99
81
|
end
|
100
82
|
end
|
@@ -12,7 +12,7 @@ module Datadog
|
|
12
12
|
attr_reader :body, :status, :headers, :active_context
|
13
13
|
|
14
14
|
def initialize(body, status, headers, active_context:)
|
15
|
-
super
|
15
|
+
super()
|
16
16
|
@body = body
|
17
17
|
@status = status
|
18
18
|
@headers = headers.each_with_object({}) { |(k, v), h| h[k.downcase] = v }
|
@@ -9,12 +9,14 @@ module Datadog
|
|
9
9
|
module Response
|
10
10
|
ADDRESSES = [
|
11
11
|
'response.status',
|
12
|
+
'response.headers',
|
12
13
|
].freeze
|
13
14
|
private_constant :ADDRESSES
|
14
15
|
|
15
16
|
def self.publish(op, gateway_response)
|
16
17
|
catch(:block) do
|
17
18
|
op.publish('response.status', gateway_response.status)
|
19
|
+
op.publish('response.headers', gateway_response.headers)
|
18
20
|
|
19
21
|
nil
|
20
22
|
end
|
@@ -25,9 +27,13 @@ module Datadog
|
|
25
27
|
Datadog.logger.debug { "reacted to #{ADDRESSES.inspect}: #{values.inspect}" }
|
26
28
|
|
27
29
|
response_status = values[0]
|
30
|
+
response_headers = values[1]
|
31
|
+
response_headers_no_cookies = response_headers.dup.tap { |h| h.delete('set-cookie') }
|
28
32
|
|
29
33
|
waf_args = {
|
30
34
|
'server.response.status' => response_status.to_s,
|
35
|
+
'server.response.headers' => response_headers,
|
36
|
+
'server.response.headers.no_cookies' => response_headers_no_cookies,
|
31
37
|
}
|
32
38
|
|
33
39
|
waf_timeout = Datadog::AppSec.settings.waf_timeout
|
@@ -23,17 +23,30 @@ module Datadog
|
|
23
23
|
@oneshot_tags_sent = false
|
24
24
|
end
|
25
25
|
|
26
|
+
# rubocop:disable Metrics/AbcSize,Metrics/PerceivedComplexity,Metrics/CyclomaticComplexity,Metrics/MethodLength
|
26
27
|
def call(env)
|
27
28
|
return @app.call(env) unless Datadog::AppSec.enabled?
|
28
29
|
|
30
|
+
Datadog::Core::Remote.active_remote.barrier(:once) unless Datadog::Core::Remote.active_remote.nil?
|
29
31
|
processor = Datadog::AppSec.processor
|
30
32
|
|
31
|
-
|
33
|
+
processor = nil
|
34
|
+
ready = false
|
35
|
+
context = nil
|
36
|
+
|
37
|
+
Datadog::AppSec.reconfigure_lock do
|
38
|
+
processor = Datadog::AppSec.processor
|
39
|
+
|
40
|
+
if !processor.nil? && processor.ready?
|
41
|
+
context = processor.activate_context
|
42
|
+
env['datadog.waf.context'] = context
|
43
|
+
ready = true
|
44
|
+
end
|
45
|
+
end
|
32
46
|
|
33
47
|
# TODO: handle exceptions, except for @app.call
|
34
48
|
|
35
|
-
|
36
|
-
env['datadog.waf.context'] = context
|
49
|
+
return @app.call(env) unless ready
|
37
50
|
|
38
51
|
gateway_request = Gateway::Request.new(env)
|
39
52
|
|
@@ -76,6 +89,7 @@ module Datadog
|
|
76
89
|
processor.deactivate_context
|
77
90
|
end
|
78
91
|
end
|
92
|
+
# rubocop:enable Metrics/AbcSize,Metrics/PerceivedComplexity,Metrics/CyclomaticComplexity,Metrics/MethodLength
|
79
93
|
|
80
94
|
private
|
81
95
|
|
@@ -5,16 +5,14 @@ module Datadog
|
|
5
5
|
module Instrumentation
|
6
6
|
class Gateway
|
7
7
|
# Base class for Gateway Arguments
|
8
|
-
class Argument
|
9
|
-
def initialize(*); end
|
10
|
-
end
|
8
|
+
class Argument; end # rubocop:disable Lint/EmptyClass
|
11
9
|
|
12
10
|
# Gateway User argument
|
13
11
|
class User < Argument
|
14
12
|
attr_reader :id
|
15
13
|
|
16
14
|
def initialize(id)
|
17
|
-
super
|
15
|
+
super()
|
18
16
|
@id = id
|
19
17
|
end
|
20
18
|
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../assets'
|
4
|
+
|
5
|
+
module Datadog
|
6
|
+
module AppSec
|
7
|
+
class Processor
|
8
|
+
# RuleLoader utility modules
|
9
|
+
# that load appsec rules and data from settings
|
10
|
+
module RuleLoader
|
11
|
+
class << self
|
12
|
+
def load_rules(ruleset:)
|
13
|
+
begin
|
14
|
+
case ruleset
|
15
|
+
when :recommended, :strict
|
16
|
+
JSON.parse(Datadog::AppSec::Assets.waf_rules(ruleset))
|
17
|
+
when :risky
|
18
|
+
Datadog.logger.warn(
|
19
|
+
'The :risky Application Security Management ruleset has been deprecated and no longer available.'\
|
20
|
+
'The `:recommended` ruleset will be used instead.'\
|
21
|
+
'Please remove the `appsec.ruleset = :risky` setting from your Datadog.configure block.'
|
22
|
+
)
|
23
|
+
JSON.parse(Datadog::AppSec::Assets.waf_rules(:recommended))
|
24
|
+
when String
|
25
|
+
JSON.parse(File.read(File.expand_path(ruleset)))
|
26
|
+
when File, StringIO
|
27
|
+
JSON.parse(ruleset.read || '').tap { ruleset.rewind }
|
28
|
+
when Hash
|
29
|
+
ruleset
|
30
|
+
else
|
31
|
+
raise ArgumentError, "unsupported value for ruleset setting: #{ruleset.inspect}"
|
32
|
+
end
|
33
|
+
rescue StandardError => e
|
34
|
+
Datadog.logger.error do
|
35
|
+
"libddwaf ruleset failed to load, ruleset: #{ruleset.inspect} error: #{e.inspect}"
|
36
|
+
end
|
37
|
+
|
38
|
+
nil
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def load_data(ip_denylist: [], user_id_denylist: [])
|
43
|
+
data = []
|
44
|
+
data << { 'rules_data' => [denylist_data('blocked_ips', ip_denylist)] } if ip_denylist.any?
|
45
|
+
data << { 'rules_data' => [denylist_data('blocked_users', user_id_denylist)] } if user_id_denylist.any?
|
46
|
+
|
47
|
+
data.any? ? data : nil
|
48
|
+
end
|
49
|
+
|
50
|
+
private
|
51
|
+
|
52
|
+
def denylist_data(id, denylist)
|
53
|
+
{
|
54
|
+
'id' => id,
|
55
|
+
'type' => 'data_with_expiration',
|
56
|
+
'data' => denylist.map { |v| { 'value' => v.to_s, 'expiration' => 2**63 } }
|
57
|
+
}
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,146 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Datadog
|
4
|
+
module AppSec
|
5
|
+
class Processor
|
6
|
+
# RuleMerger merge different sources of information
|
7
|
+
# into the rules payload
|
8
|
+
module RuleMerger
|
9
|
+
# RuleVersionMismatchError
|
10
|
+
class RuleVersionMismatchError < StandardError
|
11
|
+
def initialize(version1, version2)
|
12
|
+
msg = 'Merging rule files with different version could lead to unkown behaviour. '\
|
13
|
+
"We have receieve two rule files with versions: #{version1}, #{version2}. "\
|
14
|
+
'Please validate the configuration is correct and try again.'
|
15
|
+
super(msg)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
class << self
|
20
|
+
def merge(rules:, data: nil, overrides: nil, exclusions: nil)
|
21
|
+
combined_rules = combine_rules(rules)
|
22
|
+
|
23
|
+
rules_data = combine_data(data) if data
|
24
|
+
rules_overrides = combine_overrides(overrides) if overrides
|
25
|
+
rules_exclusions = combine_exclusions(exclusions) if exclusions
|
26
|
+
|
27
|
+
combined_rules['rules_data'] = rules_data if rules_data
|
28
|
+
combined_rules['rules_override'] = rules_overrides if rules_overrides
|
29
|
+
combined_rules['exclusions'] = rules_exclusions if rules_exclusions
|
30
|
+
|
31
|
+
combined_rules
|
32
|
+
end
|
33
|
+
|
34
|
+
private
|
35
|
+
|
36
|
+
def combine_rules(rules)
|
37
|
+
return rules[0].dup if rules.size == 1
|
38
|
+
|
39
|
+
final_rules = []
|
40
|
+
# @type var final_version: ::String
|
41
|
+
final_version = (_ = nil)
|
42
|
+
|
43
|
+
rules.each do |rule_file|
|
44
|
+
version = rule_file['version']
|
45
|
+
|
46
|
+
if version && !final_version
|
47
|
+
final_version = version
|
48
|
+
elsif final_version != version
|
49
|
+
raise RuleVersionMismatchError.new(final_version, version)
|
50
|
+
end
|
51
|
+
|
52
|
+
final_rules.concat(rule_file['rules'])
|
53
|
+
end
|
54
|
+
|
55
|
+
{
|
56
|
+
'version' => final_version,
|
57
|
+
'rules' => final_rules
|
58
|
+
}
|
59
|
+
end
|
60
|
+
|
61
|
+
def combine_data(data)
|
62
|
+
result = []
|
63
|
+
|
64
|
+
data.each do |data_entry|
|
65
|
+
data_entry['rules_data'].each do |value|
|
66
|
+
existing_data = result.find { |x| x['id'] == value['id'] }
|
67
|
+
|
68
|
+
if existing_data && existing_data['type'] == value['type']
|
69
|
+
# Duplicate entry base on type and id
|
70
|
+
# We need to merge the existing data with the new one
|
71
|
+
# and make sure to remove duplicates
|
72
|
+
merged_data = merge_data_base_on_expiration(existing_data['data'], value['data'])
|
73
|
+
existing_data['data'] = merged_data
|
74
|
+
else
|
75
|
+
result << value
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
return unless result.any?
|
81
|
+
|
82
|
+
result
|
83
|
+
end
|
84
|
+
|
85
|
+
def merge_data_base_on_expiration(data1, data2)
|
86
|
+
result = data1.each_with_object({}) do |value, acc|
|
87
|
+
acc[value['value']] = value['expiration']
|
88
|
+
end
|
89
|
+
|
90
|
+
data2.each do |data|
|
91
|
+
if result.key?(data['value'])
|
92
|
+
# The value is duplicated so we need to keep
|
93
|
+
# the one with the highest expiration value
|
94
|
+
# We replace it if the expiration is higher than the current one
|
95
|
+
# or if no experiration
|
96
|
+
current_expiration = result[data['value']]
|
97
|
+
new_expiration = data['expiration']
|
98
|
+
|
99
|
+
if new_expiration.nil? || current_expiration && new_expiration > current_expiration
|
100
|
+
result[data['value']] = new_expiration
|
101
|
+
end
|
102
|
+
else
|
103
|
+
result[data['value']] = data['expiration']
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
result.each_with_object([]) do |entry, acc|
|
108
|
+
value = { 'value' => entry[0] }
|
109
|
+
value['expiration'] = entry[1] if entry[1]
|
110
|
+
|
111
|
+
acc << value
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
def combine_overrides(overrides)
|
116
|
+
rules_override = []
|
117
|
+
|
118
|
+
overrides.each do |override|
|
119
|
+
override['rules_override'].each do |rule_override|
|
120
|
+
rules_override << rule_override
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
return if rules_override.empty?
|
125
|
+
|
126
|
+
rules_override
|
127
|
+
end
|
128
|
+
|
129
|
+
def combine_exclusions(exclusions)
|
130
|
+
rules_exclusions = []
|
131
|
+
|
132
|
+
exclusions.each do |exclusion|
|
133
|
+
exclusion['exclusions'].each do |rule_exclusion|
|
134
|
+
rules_exclusions << rule_exclusion
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
return if rules_exclusions.empty?
|
139
|
+
|
140
|
+
rules_exclusions
|
141
|
+
end
|
142
|
+
end
|
143
|
+
end
|
144
|
+
end
|
145
|
+
end
|
146
|
+
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Datadog
|
4
4
|
module AppSec
|
@@ -14,22 +14,28 @@ module Datadog
|
|
14
14
|
@time_ext_ns = 0.0
|
15
15
|
@timeouts = 0
|
16
16
|
@events = []
|
17
|
+
@run_mutex = Mutex.new
|
17
18
|
end
|
18
19
|
|
19
20
|
def run(input, timeout = WAF::LibDDWAF::DDWAF_RUN_TIMEOUT)
|
21
|
+
@run_mutex.lock
|
22
|
+
|
20
23
|
start_ns = Core::Utils::Time.get_time(:nanosecond)
|
21
24
|
|
25
|
+
# this WAF::Context#run call is not thread safe as it mutates the context
|
22
26
|
# TODO: remove multiple assignment
|
23
|
-
_code, res =
|
24
|
-
# @type var res: WAF::Result
|
27
|
+
_code, res = @context.run(input, timeout)
|
25
28
|
|
26
29
|
stop_ns = Core::Utils::Time.get_time(:nanosecond)
|
27
30
|
|
31
|
+
# these updates are not thread safe and should be protected
|
28
32
|
@time_ns += res.total_runtime
|
29
33
|
@time_ext_ns += (stop_ns - start_ns)
|
30
34
|
@timeouts += 1 if res.timeout
|
31
35
|
|
32
36
|
res
|
37
|
+
ensure
|
38
|
+
@run_mutex.unlock
|
33
39
|
end
|
34
40
|
|
35
41
|
def finalize
|
@@ -63,22 +69,18 @@ module Datadog
|
|
63
69
|
|
64
70
|
attr_reader :ruleset_info, :addresses
|
65
71
|
|
66
|
-
def initialize
|
72
|
+
def initialize(ruleset:)
|
67
73
|
@ruleset_info = nil
|
68
74
|
@addresses = []
|
69
75
|
settings = Datadog::AppSec.settings
|
70
76
|
|
71
|
-
unless load_libddwaf &&
|
77
|
+
unless load_libddwaf && create_waf_handle(settings, ruleset)
|
72
78
|
Datadog.logger.warn { 'AppSec is disabled, see logged errors above' }
|
73
|
-
|
74
|
-
return
|
75
79
|
end
|
76
|
-
|
77
|
-
apply_denylist_data(settings)
|
78
80
|
end
|
79
81
|
|
80
82
|
def ready?
|
81
|
-
!@
|
83
|
+
!@handle.nil?
|
82
84
|
end
|
83
85
|
|
84
86
|
def new_context
|
@@ -102,14 +104,6 @@ module Datadog
|
|
102
104
|
context.finalize
|
103
105
|
end
|
104
106
|
|
105
|
-
def update_rule_data(data)
|
106
|
-
@handle.update_rule_data(data)
|
107
|
-
end
|
108
|
-
|
109
|
-
def toggle_rules(map)
|
110
|
-
@handle.toggle_rules(map)
|
111
|
-
end
|
112
|
-
|
113
107
|
def finalize
|
114
108
|
@handle.finalize
|
115
109
|
end
|
@@ -120,61 +114,11 @@ module Datadog
|
|
120
114
|
|
121
115
|
private
|
122
116
|
|
123
|
-
def apply_denylist_data(settings)
|
124
|
-
ruledata_setting = []
|
125
|
-
ruledata_setting << denylist_data('blocked_ips', settings.ip_denylist)
|
126
|
-
ruledata_setting << denylist_data('blocked_users', settings.user_id_denylist)
|
127
|
-
|
128
|
-
update_rule_data(ruledata_setting)
|
129
|
-
end
|
130
|
-
|
131
|
-
def denylist_data(id, denylist)
|
132
|
-
{
|
133
|
-
'id' => id,
|
134
|
-
'type' => 'data_with_expiration',
|
135
|
-
'data' => denylist.map { |v| { 'value' => v.to_s, 'expiration' => 2**63 } }
|
136
|
-
}
|
137
|
-
end
|
138
|
-
|
139
117
|
def load_libddwaf
|
140
118
|
Processor.require_libddwaf && Processor.libddwaf_provides_waf?
|
141
119
|
end
|
142
120
|
|
143
|
-
def
|
144
|
-
ruleset_setting = settings.ruleset
|
145
|
-
|
146
|
-
begin
|
147
|
-
@ruleset = case ruleset_setting
|
148
|
-
when :recommended, :strict
|
149
|
-
JSON.parse(Datadog::AppSec::Assets.waf_rules(ruleset_setting))
|
150
|
-
when :risky
|
151
|
-
JSON.parse(Datadog::AppSec::Assets.waf_rules(:recommended))
|
152
|
-
Datadog.logger.warn(
|
153
|
-
'The :risky Application Security Management ruleset has been deprecated and no longer available.'\
|
154
|
-
'The `:recommended` ruleset will be used instead.'\
|
155
|
-
'Please remove the `appsec.ruleset = :risky` setting from your Datadog.configure block.'
|
156
|
-
)
|
157
|
-
when String
|
158
|
-
JSON.parse(File.read(ruleset_setting))
|
159
|
-
when File, StringIO
|
160
|
-
JSON.parse(ruleset_setting.read || '').tap { ruleset_setting.rewind }
|
161
|
-
when Hash
|
162
|
-
ruleset_setting
|
163
|
-
else
|
164
|
-
raise ArgumentError, "unsupported value for ruleset setting: #{ruleset_setting.inspect}"
|
165
|
-
end
|
166
|
-
|
167
|
-
true
|
168
|
-
rescue StandardError => e
|
169
|
-
Datadog.logger.error do
|
170
|
-
"libddwaf ruleset failed to load, ruleset: #{ruleset_setting.inspect} error: #{e.inspect}"
|
171
|
-
end
|
172
|
-
|
173
|
-
false
|
174
|
-
end
|
175
|
-
end
|
176
|
-
|
177
|
-
def create_waf_handle(settings)
|
121
|
+
def create_waf_handle(settings, ruleset)
|
178
122
|
# TODO: this may need to be reset if the main Datadog logging level changes after initialization
|
179
123
|
Datadog::AppSec::WAF.logger = Datadog.logger if Datadog.logger.debug? && settings.waf_debug
|
180
124
|
|
@@ -182,7 +126,8 @@ module Datadog
|
|
182
126
|
key_regex: settings.obfuscator_key_regex,
|
183
127
|
value_regex: settings.obfuscator_value_regex,
|
184
128
|
}
|
185
|
-
|
129
|
+
|
130
|
+
@handle = Datadog::AppSec::WAF::Handle.new(ruleset, obfuscator: obfuscator_config)
|
186
131
|
@ruleset_info = @handle.ruleset_info
|
187
132
|
@addresses = @handle.required_addresses
|
188
133
|
|