Module: Datadog::AppSec::DefaultHeaderTags Private

Defined in:
lib/datadog/appsec/default_header_tags.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Sets the always-on span tags built from a fixed allowlist of request and response headers.

NOTE: Unlike Event.record, which reports request headers only when a security event fires, these are tagged on every request/response

Constant Summary collapse

REQUEST_HEADERS_TAGS =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

NOTE: Contains additional WAF vendor headers

%w[
  accept
  content-type
  user-agent
  akamai-user-risk
  x-amzn-trace-id
  x-cloud-trace-context
  x-appgw-trace-id
  x-sigsci-requestid
  x-sigsci-tags
  cf-ray
  cloudfront-viewer-ja3-fingerprint
].freeze
RESPONSE_HEADERS_TAGS =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

%w[
  content-type
  content-length
  content-encoding
  content-language
].freeze

Class Method Summary collapse

Class Method Details

.tag_request(span, headers) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



37
38
39
40
41
42
# File 'lib/datadog/appsec/default_header_tags.rb', line 37

def tag_request(span, headers)
  REQUEST_HEADERS_TAGS.each do |name|
    value = headers.get(name)
    span.set_tag("http.request.headers.#{name}", value) if value
  end
end

.tag_response(span, headers) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



44
45
46
47
48
49
# File 'lib/datadog/appsec/default_header_tags.rb', line 44

def tag_response(span, headers)
  RESPONSE_HEADERS_TAGS.each do |name|
    value = headers.get(name)
    span.set_tag("http.response.headers.#{name}", value.to_s) if value
  end
end