Skip to content

Added WAF vendors headers in traces tags#3528

Merged
vpellan merged 7 commits into
masterfrom
vpellan/collect-waf-vendors-request-id-headers
Mar 25, 2024
Merged

Added WAF vendors headers in traces tags#3528
vpellan merged 7 commits into
masterfrom
vpellan/collect-waf-vendors-request-id-headers

Conversation

@vpellan

@vpellan vpellan commented Mar 15, 2024

Copy link
Copy Markdown
Contributor

What does this PR do?
Add WAF vendors headers in traces tags according to this RFC

Motivation:
This will enable the ASM Respond team to parse the value of these headers and check that they are in the correct format

Additional Notes:
I used a hash to access traces-formatted headers and rack-formatted headers at the same time, and this hash is created from a list of string, corresponding to the HTTP-formatted header. Maybe these operations can add overhead time, and manually creating the hash would be faster

How to test the change?

  1. Use Rspec (-e 'with WAF vendor headers')
  2. Use system-tests
    • Enable Test_ExternalWafRequestsIdentification in ruby manifest
    • run.sh tests/appsec/test_traces.py::Test_ExternalWafRequestsIdentification::test_external_wafs_header_collection
    • Check on datad0g staging that the trace contains WAF headers tags

For Datadog employees:

  • If this PR touches code that signs or publishes builds or packages, or handles
    credentials of any kind, I've requested a review from @DataDog/security-design-and-guidance.
  • This PR doesn't touch any of that.

JIRA

@vpellan vpellan added feature Involves a product feature appsec Application Security monitoring product tracing labels Mar 15, 2024
@vpellan vpellan self-assigned this Mar 15, 2024
@github-actions github-actions Bot added integrations Involves tracing integrations and removed tracing labels Mar 15, 2024
@vpellan
vpellan marked this pull request as ready for review March 15, 2024 13:12
@vpellan
vpellan requested a review from a team as a code owner March 15, 2024 13:12
@codecov-commenter

codecov-commenter commented Mar 18, 2024

Copy link
Copy Markdown

Codecov Report

Attention: Patch coverage is 97.14286% with 1 lines in your changes are missing coverage. Please review.

Project coverage is 98.23%. Comparing base (a9f0ef2) to head (5e96bc4).
Report is 88 commits behind head on master.

Files Patch % Lines
.../datadog/appsec/contrib/rack/request_middleware.rb 93.33% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3528      +/-   ##
==========================================
- Coverage   98.23%   98.23%   -0.01%     
==========================================
  Files        1275     1275              
  Lines       75279    75308      +29     
  Branches     3554     3556       +2     
==========================================
+ Hits        73954    73982      +28     
- Misses       1325     1326       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@lloeki lloeki left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, save for a minor suggestion

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a bit unwieldy but it works.

Comment thread lib/datadog/appsec/contrib/rack/request_middleware.rb Outdated
Comment thread lib/datadog/appsec/contrib/rack/request_middleware.rb Outdated

@ivoanjo ivoanjo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: Please hold off on merging this to master until we get the 1.21.1 release out. (Feel free to dismiss afterwards! Thanks for the patience!)

@vpellan
vpellan requested a review from ivoanjo March 22, 2024 14:28
@ivoanjo
ivoanjo dismissed their stale review March 22, 2024 14:29

1.21.1 now released!

@vpellan
vpellan force-pushed the vpellan/collect-waf-vendors-request-id-headers branch from 5e96bc4 to 679f92f Compare March 25, 2024 14:29
@vpellan
vpellan requested a review from lloeki March 25, 2024 14:43

@lloeki lloeki left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, just an extra comment left

Akamai-User-Risk
].map(&:downcase).freeze

# .map { |s| [s.downcase, Datadog::Tracing::Contrib::Rack::Header.to_rack_header(s)] }.to_h

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leftover comment, to be removed ;)

module AppSec
module Contrib
module Rack
# Create an array of lowercased headers

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor: I don't think this comment adds a lot, reminds me of this meme lol 😉 😉 😉 😉:

@vpellan
vpellan merged commit 0764132 into master Mar 25, 2024
@vpellan
vpellan deleted the vpellan/collect-waf-vendors-request-id-headers branch March 25, 2024 16:33
@github-actions github-actions Bot added this to the 1.22.0 milestone Mar 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

appsec Application Security monitoring product feature Involves a product feature integrations Involves tracing integrations

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants