Skip to content

fix(iast): instrument cookie parseCookie for cookie >=1.1#9272

Merged
BridgeAR merged 2 commits into
masterfrom
fix/cookie-2x-support
Jul 11, 2026
Merged

fix(iast): instrument cookie parseCookie for cookie >=1.1#9272
BridgeAR merged 2 commits into
masterfrom
fix/cookie-2x-support

Conversation

@BridgeAR

@BridgeAR BridgeAR commented Jul 8, 2026

Copy link
Copy Markdown
Member

cookie 1.1 added a parseCookie alias next to parse, and cookie 2.0 dropped parse entirely in an ESM-only rewrite that exports only parseCookie. The hook only wrapped parse, so the datadog:cookie:parse:finish channel never fired for callers using parseCookie (all of cookie 2.x, and 1.x code that adopted the new name) and IAST stopped tainting those cookies.

Wrap every parse entry the installed version exposes; a single call hits one export, so wrapping both names when present does not double-publish.

The plugin ESM integration test gains a parseCookie fixture for the named-export 2.x shape, and both it and the IAST source test skip cookie 2.x on Node <22, which the package's engines field requires.

@BridgeAR
BridgeAR marked this pull request as ready for review July 8, 2026 21:17
@BridgeAR
BridgeAR requested review from a team as code owners July 8, 2026 21:17
@BridgeAR
BridgeAR requested review from wconti27 and removed request for a team July 8, 2026 21:17
@dd-octo-sts

dd-octo-sts Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Overall package size

Self size: 6.71 MB
Deduped: 7.37 MB
No deduping: 7.37 MB

Dependency sizes | name | version | self size | total size | |------|---------|-----------|------------| | import-in-the-middle | 3.3.1 | 122.62 kB | 437.94 kB | | opentracing | 0.14.7 | 194.81 kB | 194.81 kB | | dc-polyfill | 0.1.11 | 25.74 kB | 25.74 kB |

🤖 This report was automatically generated by heaviest-objects-in-the-universe

@datadog-prod-us1-6

datadog-prod-us1-6 Bot commented Jul 8, 2026

Copy link
Copy Markdown

Tests

🎉 All green!

🧪 All tests passed
❄️ No new flaky tests detected

🔄 Datadog auto-retried 1 job - 1 passed on retry View in Datadog

🎯 Code Coverage (details)
Patch Coverage: 100.00%
Overall Coverage: 96.53% (+0.00%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: d8383d9 | Docs | Datadog PR Page | Give us feedback!

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 17548f60b2

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread packages/datadog-instrumentations/src/cookie.js Outdated
@pr-commenter

pr-commenter Bot commented Jul 8, 2026

Copy link
Copy Markdown

Benchmarks

Benchmark execution time: 2026-07-10 17:11:17

Comparing candidate commit d8383d9 in PR branch fix/cookie-2x-support with baseline commit b968578 in branch master.

📊 Benchmarking dashboard

Found 0 performance improvements and 0 performance regressions! Performance is the same for 2320 metrics, 38 unstable metrics.

Explanation

This is an A/B test comparing a candidate commit's performance against that of a baseline commit. Performance changes are noted in the tables below as:

  • 🟩 = significantly better candidate vs. baseline
  • 🟥 = significantly worse candidate vs. baseline

We compute a confidence interval (CI) over the relative difference of means between metrics from the candidate and baseline commits, considering the baseline as the reference.

If the CI is entirely outside the configured SIGNIFICANT_IMPACT_THRESHOLD (or the deprecated UNCONFIDENCE_THRESHOLD), the change is considered significant.

Feel free to reach out to #apm-benchmarking-platform on Slack if you have any questions.

More details about the CI and significant changes

You can imagine this CI as a range of values that is likely to contain the true difference of means between the candidate and baseline commits.

CIs of the difference of means are often centered around 0%, because often changes are not that big:

---------------------------------(------|---^--------)-------------------------------->
                              -0.6%    0%  0.3%     +1.2%
                                 |          |        |
         lower bound of the CI --'          |        |
sample mean (center of the CI) -------------'        |
         upper bound of the CI ----------------------'

As described above, a change is considered significant if the CI is entirely outside the configured SIGNIFICANT_IMPACT_THRESHOLD (or the deprecated UNCONFIDENCE_THRESHOLD).

For instance, for an execution time metric, this confidence interval indicates a significantly worse performance:

----------------------------------------|---------|---(---------^---------)---------->
                                       0%        1%  1.3%      2.2%      3.1%
                                                  |   |         |         |
       significant impact threshold --------------'   |         |         |
                      lower bound of CI --------------'         |         |
       sample mean (center of the CI) --------------------------'         |
                      upper bound of CI ----------------------------------'

Unstable benchmarks

These benchmarks have a confidence interval too wide to call a change; treat them as noise rather than signal.

scenario:appsec-appsec-enabled-24

  • unstable execution_time [-209246.196µs; +208158.363µs] or [-7.854%; +7.813%]

scenario:appsec-appsec-enabled-26

  • unstable execution_time [-234.914ms; +161.033ms] or [-9.299%; +6.375%]

scenario:appsec-appsec-enabled-with-attacks-24

  • unstable execution_time [-157.608ms; +160.914ms] or [-5.087%; +5.193%]

scenario:appsec-appsec-enabled-with-attacks-26

  • unstable execution_time [-182926.020µs; +183841.920µs] or [-6.308%; +6.339%]

scenario:appsec-control-24

  • unstable execution_time [-112.081ms; +115.119ms] or [-9.068%; +9.313%]

scenario:appsec-control-26

  • unstable execution_time [-126.591ms; +117.582ms] or [-10.225%; +9.497%]

scenario:appsec-iast-no-vulnerability-control-20

  • unstable execution_time [-15.030ms; +10.979ms] or [-5.841%; +4.267%]

scenario:appsec-iast-no-vulnerability-iast-enabled-always-active-20

  • unstable execution_time [-16.940ms; +9.803ms] or [-6.485%; +3.753%]

scenario:appsec-iast-with-vulnerability-iast-enabled-always-active-20

  • unstable execution_time [-29.740ms; +26.752ms] or [-5.337%; +4.801%]

scenario:appsec-iast-with-vulnerability-iast-enabled-default-config-20

  • unstable execution_time [-26.860ms; +36.469ms] or [-4.863%; +6.603%]

scenario:debugger-line-probe-with-snapshot-minimal-24

  • unstable cpu_user_time [-2.487s; +0.333s] or [-27.957%; +3.744%]
  • unstable execution_time [-2.487s; +0.336s] or [-25.874%; +3.495%]
  • unstable instructions [-21.4G instructions; +2.8G instructions] or [-29.281%; +3.777%]
  • unstable throughput [-100.072op/s; +690.318op/s] or [-2.886%; +19.911%]

scenario:debugger-line-probe-with-snapshot-minimal-26

  • unstable cpu_user_time [-1793.346ms; +589.938ms] or [-19.102%; +6.284%]
  • unstable execution_time [-1801.098ms; +602.978ms] or [-17.802%; +5.960%]
  • unstable instructions [-16.0G instructions; +5.3G instructions] or [-20.416%; +6.796%]
  • unstable throughput [-135.352op/s; +392.057op/s] or [-4.175%; +12.092%]

scenario:debugger-line-probe-without-snapshot-24

  • unstable cpu_user_time [-2508.299ms; +2235.615ms] or [-27.902%; +24.868%]
  • unstable execution_time [-2656.121ms; +2404.458ms] or [-27.360%; +24.767%]
  • unstable instructions [-21.4G instructions; +18.9G instructions] or [-29.035%; +25.708%]
  • unstable max_rss_usage [-9927.768KB; +9490.168KB] or [-6.238%; +5.963%]
  • unstable throughput [-657.567op/s; +727.690op/s] or [-19.108%; +21.146%]

scenario:debugger-line-probe-without-snapshot-26

  • unstable cpu_user_time [-2907.142ms; +2865.564ms] or [-29.160%; +28.743%]
  • unstable execution_time [-2904.216ms; +2900.811ms] or [-27.156%; +27.124%]
  • unstable instructions [-26121.3M instructions; +25823.7M instructions] or [-31.330%; +30.973%]
  • unstable max_rss_usage [-9173.981KB; +9689.981KB] or [-5.704%; +6.025%]
  • unstable throughput [-634.444op/s; +641.029op/s] or [-20.318%; +20.529%]

scenario:dogstatsd-with-tags-20

  • unstable cpu_user_time [-415.947ms; +262.233ms] or [-8.706%; +5.488%]
  • unstable execution_time [-418.060ms; +256.942ms] or [-8.605%; +5.289%]
  • unstable throughput [-90495.322op/s; +143279.447op/s] or [-5.233%; +8.286%]

scenario:plugin-claude-agent-sdk-compact-stream-scan-26

  • unstable cpu_usage_percentage [-5.449%; +5.513%]

scenario:plugin-graphql-long-with-depth-on-max-20

  • unstable cpu_user_time [-740.753ms; +698.713ms] or [-5.775%; +5.448%]
  • unstable execution_time [-744.075ms; +710.006ms] or [-5.677%; +5.417%]
  • unstable throughput [-3.267op/s; +3.442op/s] or [-5.319%; +5.605%]

scenario:plugin-mongodb-core-deep-aggregate-26

  • unstable execution_time [-141.244ms; +183.372ms] or [-5.189%; +6.737%]

scenario:plugin-pg-service-24

  • unstable execution_time [-141.956ms; +38.216ms] or [-8.385%; +2.257%]

scenario:test-optimization-large-suite-20

  • unstable max_rss_usage [-5.479MB; +3.303MB] or [-6.914%; +4.169%]

@codecov

codecov Bot commented Jul 8, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.57%. Comparing base (b968578) to head (d8383d9).

Additional details and impacted files
@@           Coverage Diff            @@
##           master    #9272    +/-   ##
========================================
  Coverage   96.56%   96.57%            
========================================
  Files         918      918            
  Lines      121564   121577    +13     
  Branches    20883    21200   +317     
========================================
+ Hits       117394   117407    +13     
  Misses       4170     4170            
Flag Coverage Δ
aiguard 53.56% <88.88%> (-0.05%) ⬇️
aiguard-integration 57.01% <93.75%> (+0.01%) ⬆️
apm-bucket-0 53.79% <88.88%> (-0.05%) ⬇️
apm-bucket-1 58.08% <88.88%> (-0.04%) ⬇️
apm-bucket-2 56.11% <88.88%> (-0.04%) ⬇️
apm-capabilities-tracing 60.32% <88.88%> (+<0.01%) ⬆️
apm-integrations-aerospike 52.94% <88.88%> (-0.05%) ⬇️
apm-integrations-confluentinc-kafka-javascript 57.06% <88.88%> (+0.02%) ⬆️
apm-integrations-couchbase 53.27% <88.88%> (-0.05%) ⬇️
apm-integrations-http 57.96% <88.88%> (-0.04%) ⬇️
apm-integrations-kafkajs 57.71% <88.88%> (-0.05%) ⬇️
apm-integrations-next 54.24% <88.88%> (-0.04%) ⬇️
apm-integrations-prisma 54.17% <88.88%> (-0.04%) ⬇️
apm-integrations-tedious 53.04% <88.88%> (-0.04%) ⬇️
appsec 68.97% <88.88%> (-0.02%) ⬇️
appsec-express_fastify_graphql 65.60% <93.75%> (-0.03%) ⬇️
appsec-integration 45.59% <93.75%> (+<0.01%) ⬆️
appsec-kafka_ldapjs_lodash 59.09% <88.88%> (-0.04%) ⬇️
appsec-mongodb-core_mongoose_mysql 62.25% <93.75%> (-0.03%) ⬇️
appsec-next 52.85% <88.88%> (-0.04%) ⬇️
appsec-node-serialize_passport_postgres 61.88% <93.75%> (-0.03%) ⬇️
appsec-sourcing_stripe_template 60.34% <100.00%> (+0.07%) ⬆️
debugger 65.71% <100.00%> (-0.02%) ⬇️
instrumentations-bucket-0 48.75% <88.88%> (-0.04%) ⬇️
instrumentations-bucket-1 54.96% <93.75%> (-0.04%) ⬇️
instrumentations-bucket-10 56.63% <93.75%> (-0.03%) ⬇️
instrumentations-bucket-11 48.74% <88.88%> (-0.05%) ⬇️
instrumentations-bucket-12 48.84% <88.88%> (-0.04%) ⬇️
instrumentations-bucket-13 48.68% <88.88%> (-0.05%) ⬇️
instrumentations-bucket-2 49.74% <93.75%> (-0.04%) ⬇️
instrumentations-bucket-3 53.83% <93.75%> (-0.04%) ⬇️
instrumentations-bucket-4 49.16% <88.88%> (-0.05%) ⬇️
instrumentations-bucket-5 53.01% <93.75%> (-0.03%) ⬇️
instrumentations-bucket-6 55.60% <88.88%> (-0.04%) ⬇️
instrumentations-bucket-7 53.61% <93.75%> (-0.04%) ⬇️
instrumentations-bucket-8 54.64% <93.75%> (-0.04%) ⬇️
instrumentations-bucket-9 56.10% <93.75%> (-0.03%) ⬇️
instrumentations-instrumentation-couchbase 48.18% <88.88%> (-0.05%) ⬇️
instrumentations-integration-esbuild 33.96% <56.25%> (+<0.01%) ⬆️
llmobs-ai_anthropic_bedrock 57.73% <88.88%> (-0.04%) ⬇️
llmobs-bucket-1 56.99% <88.88%> (-0.04%) ⬇️
llmobs-openai 57.56% <88.88%> (-0.04%) ⬇️
llmobs-sdk 59.95% <88.88%> (-0.04%) ⬇️
llmobs-vertex-ai 54.21% <88.88%> (-0.04%) ⬇️
master-coverage 96.57% <100.00%> (?)
openfeature 54.62% <93.75%> (+<0.01%) ⬆️
openfeature-unit 49.83% <88.88%> (-0.05%) ⬇️
platform-core_esbuild_instrumentations-misc 38.46% <93.75%> (-0.02%) ⬇️
platform-integration 62.24% <93.75%> (+<0.01%) ⬆️
platform-shimmer_unit-guardrails_webpack 37.29% <62.50%> (-0.03%) ⬇️
plugins-bucket-0 53.18% <88.88%> (-0.04%) ⬇️
plugins-bucket-1 55.09% <93.75%> (+0.01%) ⬆️
plugins-bucket-11 55.60% <88.88%> (-0.04%) ⬇️
plugins-bucket-18 57.08% <93.75%> (-0.03%) ⬇️
plugins-bucket-19 55.38% <88.88%> (-0.02%) ⬇️
plugins-bucket-20 57.44% <88.88%> (-0.04%) ⬇️
plugins-bucket-4 53.85% <93.75%> (-0.04%) ⬇️
plugins-bullmq_cassandra_cookie 57.39% <56.25%> (-0.05%) ⬇️
plugins-cookie-parser_crypto_dd-trace-api 52.32% <88.88%> (-0.05%) ⬇️
plugins-fetch_fs_generic-pool 54.54% <88.88%> (+0.03%) ⬆️
plugins-google-cloud-pubsub_grpc_handlebars 59.87% <88.88%> (-0.04%) ⬇️
plugins-hapi_hono_ioredis 55.86% <88.88%> (-0.04%) ⬇️
plugins-jest_knex_langgraph 51.67% <88.88%> (-0.04%) ⬇️
plugins-ldapjs_light-my-request_limitd-client 53.42% <93.75%> (-0.04%) ⬇️
plugins-lodash_mariadb_memcached 54.21% <88.88%> (-0.05%) ⬇️
plugins-moleculer_mongodb_mongodb-core 57.29% <88.88%> (-0.04%) ⬇️
plugins-mongoose_multer_mysql 54.71% <88.88%> (-0.04%) ⬇️
plugins-mysql2_nats_node-serialize 56.21% <88.88%> (-0.04%) ⬇️
plugins-opensearch_passport-http_pino 55.05% <88.88%> (-0.04%) ⬇️
plugins-postgres_process_pug 54.29% <88.88%> (-0.05%) ⬇️
plugins-redis_router_sequelize 57.03% <88.88%> (-0.04%) ⬇️
plugins-test-and-upstream-rhea_undici_url 57.01% <88.88%> (-0.04%) ⬇️
plugins-valkey_vm_winston 53.84% <88.88%> (-0.04%) ⬇️
plugins-ws 54.80% <88.88%> (-0.04%) ⬇️
profiling 58.20% <88.88%> (-0.04%) ⬇️
serverless-aws-sdk-aws-sdk 50.67% <88.88%> (-0.04%) ⬇️
serverless-aws-sdk-bedrockruntime 50.69% <88.88%> (-0.04%) ⬇️
serverless-aws-sdk-client 51.97% <88.88%> (-0.04%) ⬇️
serverless-aws-sdk-dynamodb 51.75% <88.88%> (-0.04%) ⬇️
serverless-aws-sdk-eventbridge 46.25% <93.75%> (-0.03%) ⬇️
serverless-aws-sdk-kinesis 54.71% <88.88%> (-0.04%) ⬇️
serverless-aws-sdk-lambda 52.79% <88.88%> (-0.04%) ⬇️
serverless-aws-sdk-s3 51.53% <88.88%> (-0.04%) ⬇️
serverless-aws-sdk-serverless-peer-service 54.73% <88.88%> (-0.04%) ⬇️
serverless-aws-sdk-sns 55.48% <88.88%> (-0.04%) ⬇️
serverless-aws-sdk-sqs 55.91% <88.88%> (-0.04%) ⬇️
serverless-aws-sdk-stepfunctions 51.25% <88.88%> (-0.04%) ⬇️
serverless-aws-sdk-util 48.48% <88.88%> (-0.05%) ⬇️
serverless-bucket-0 55.23% <93.75%> (+0.01%) ⬆️
serverless-bucket-1 56.01% <93.75%> (-0.04%) ⬇️
test-optimization-cucumber 72.94% <100.00%> (+0.03%) ⬆️
test-optimization-cypress 66.33% <93.75%> (+0.02%) ⬆️
test-optimization-jest 73.89% <100.00%> (-0.04%) ⬇️
test-optimization-mocha 74.30% <100.00%> (+0.04%) ⬆️
test-optimization-playwright-playwright-atr 61.57% <93.75%> (+<0.01%) ⬆️
test-optimization-playwright-playwright-efd 61.76% <93.75%> (+<0.01%) ⬆️
test-optimization-playwright-playwright-final-status 61.72% <93.75%> (+<0.01%) ⬆️
test-optimization-playwright-playwright-impacted-tests 61.44% <93.75%> (+0.17%) ⬆️
test-optimization-playwright-playwright-reporting 61.34% <93.75%> (+<0.01%) ⬆️
test-optimization-playwright-playwright-test-management 62.25% <93.75%> (-0.11%) ⬇️
test-optimization-playwright-playwright-test-span 61.49% <93.75%> (-0.05%) ⬇️
test-optimization-selenium 60.67% <93.75%> (-0.16%) ⬇️
test-optimization-testopt 59.15% <88.88%> (+0.08%) ⬆️
test-optimization-vitest 71.57% <100.00%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@BridgeAR
BridgeAR marked this pull request as draft July 8, 2026 22:52
@BridgeAR
BridgeAR force-pushed the fix/cookie-2x-support branch from 17548f6 to d06efb6 Compare July 8, 2026 23:22
BridgeAR added 2 commits July 10, 2026 18:59
cookie 1.1 added a parseCookie alias next to parse, and cookie 2.0 dropped
parse entirely in an ESM-only rewrite that exports only parseCookie. The hook
only wrapped parse, so the datadog:cookie:parse:finish channel never fired for
callers using parseCookie (all of cookie 2.x, and 1.x code that adopted the new
name) and IAST stopped tainting those cookies.

Wrap every parse entry the installed version exposes; a single call hits one
export, so wrapping both names when present does not double-publish.
Node.js >=22 exposes cookie 2.x to require() as a module namespace whose writable export descriptor still rejects redefinition. Without a mutable replacement, the instrumentation aborts and IAST leaves parsed cookie values untainted.
@BridgeAR
BridgeAR force-pushed the fix/cookie-2x-support branch from d06efb6 to d8383d9 Compare July 10, 2026 17:00
@BridgeAR
BridgeAR marked this pull request as ready for review July 10, 2026 17:10
@BridgeAR
BridgeAR requested a review from a team as a code owner July 10, 2026 17:10

@CarlesDD CarlesDD left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@BridgeAR
BridgeAR merged commit 322e8bd into master Jul 11, 2026
773 of 774 checks passed
@BridgeAR
BridgeAR deleted the fix/cookie-2x-support branch July 11, 2026 21:09
This was referenced Jul 13, 2026
This was referenced Jul 14, 2026
juan-fernandez pushed a commit that referenced this pull request Jul 14, 2026
cookie 1.1 added a parseCookie alias next to parse, and cookie 2.0 dropped
parse entirely in an ESM-only rewrite that exports only parseCookie. The hook
only wrapped parse, so the datadog:cookie:parse:finish channel never fired for
callers using parseCookie (all of cookie 2.x, and 1.x code that adopted the new
name) and IAST stopped tainting those cookies.

Wrap every parse entry the installed version exposes; a single call hits one
export, so wrapping both names when present does not double-publish.
juan-fernandez pushed a commit that referenced this pull request Jul 14, 2026
cookie 1.1 added a parseCookie alias next to parse, and cookie 2.0 dropped
parse entirely in an ESM-only rewrite that exports only parseCookie. The hook
only wrapped parse, so the datadog:cookie:parse:finish channel never fired for
callers using parseCookie (all of cookie 2.x, and 1.x code that adopted the new
name) and IAST stopped tainting those cookies.

Wrap every parse entry the installed version exposes; a single call hits one
export, so wrapping both names when present does not double-publish.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants