dd-trace 5.58.0 → 5.59.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (165) hide show
  1. package/LICENSE-3rdparty.csv +1 -0
  2. package/ci/cypress/after-run.js +2 -0
  3. package/ci/cypress/after-spec.js +2 -0
  4. package/ci/cypress/plugin.js +2 -0
  5. package/ci/cypress/polyfills.js +2 -0
  6. package/ci/cypress/support.js +2 -0
  7. package/ci/init.js +2 -0
  8. package/index.d.ts +7 -0
  9. package/init.js +0 -2
  10. package/initialize.mjs +2 -0
  11. package/package.json +36 -7
  12. package/packages/datadog-code-origin/index.js +14 -9
  13. package/packages/datadog-instrumentations/src/apollo.js +7 -10
  14. package/packages/datadog-instrumentations/src/avsc.js +2 -0
  15. package/packages/datadog-instrumentations/src/child_process.js +21 -42
  16. package/packages/datadog-instrumentations/src/cucumber.js +10 -8
  17. package/packages/datadog-instrumentations/src/cypress.js +2 -0
  18. package/packages/datadog-instrumentations/src/fastify.js +19 -1
  19. package/packages/datadog-instrumentations/src/helpers/hooks.js +1 -0
  20. package/packages/datadog-instrumentations/src/helpers/register.js +1 -1
  21. package/packages/datadog-instrumentations/src/hono.js +102 -0
  22. package/packages/datadog-instrumentations/src/langchain.js +21 -0
  23. package/packages/datadog-instrumentations/src/mocha/common.js +2 -0
  24. package/packages/datadog-instrumentations/src/mocha.js +2 -0
  25. package/packages/datadog-instrumentations/src/nyc.js +2 -0
  26. package/packages/datadog-instrumentations/src/orchestrion-config/index.js +32 -0
  27. package/packages/datadog-instrumentations/src/playwright.js +5 -1
  28. package/packages/datadog-instrumentations/src/protobufjs.js +2 -0
  29. package/packages/datadog-instrumentations/src/selenium.js +2 -0
  30. package/packages/datadog-instrumentations/src/vitest.js +2 -0
  31. package/packages/datadog-plugin-avsc/src/index.js +2 -0
  32. package/packages/datadog-plugin-avsc/src/schema_iterator.js +2 -0
  33. package/packages/datadog-plugin-aws-sdk/src/services/bedrockruntime/index.js +2 -0
  34. package/packages/datadog-plugin-child_process/src/index.js +30 -10
  35. package/packages/datadog-plugin-cypress/src/after-run.js +2 -0
  36. package/packages/datadog-plugin-cypress/src/after-spec.js +2 -0
  37. package/packages/datadog-plugin-cypress/src/cypress-plugin.js +8 -3
  38. package/packages/datadog-plugin-cypress/src/index.js +2 -0
  39. package/packages/datadog-plugin-cypress/src/plugin.js +2 -0
  40. package/packages/datadog-plugin-cypress/src/support.js +4 -2
  41. package/packages/datadog-plugin-google-cloud-vertexai/src/utils.js +2 -0
  42. package/packages/datadog-plugin-graphql/src/utils.js +2 -0
  43. package/packages/datadog-plugin-hono/src/index.js +28 -0
  44. package/packages/datadog-plugin-jest/src/index.js +2 -0
  45. package/packages/datadog-plugin-jest/src/util.js +2 -0
  46. package/packages/datadog-plugin-kafkajs/src/batch-consumer.js +2 -0
  47. package/packages/datadog-plugin-langchain/src/tracing.js +36 -4
  48. package/packages/datadog-plugin-nyc/src/index.js +2 -0
  49. package/packages/datadog-plugin-oracledb/src/connection-parser.js +2 -0
  50. package/packages/datadog-plugin-protobufjs/src/index.js +2 -0
  51. package/packages/datadog-plugin-protobufjs/src/schema_iterator.js +2 -0
  52. package/packages/datadog-plugin-selenium/src/index.js +2 -0
  53. package/packages/datadog-plugin-vitest/src/index.js +2 -0
  54. package/packages/dd-trace/src/appsec/iast/iast-context.js +5 -1
  55. package/packages/dd-trace/src/appsec/iast/index.js +2 -0
  56. package/packages/dd-trace/src/appsec/iast/overhead-controller.js +1 -1
  57. package/packages/dd-trace/src/appsec/iast/taint-tracking/rewriter-esm.mjs +0 -2
  58. package/packages/dd-trace/src/appsec/iast/taint-tracking/rewriter.js +2 -0
  59. package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/evidence-redaction/sensitive-regex.js +2 -0
  60. package/packages/dd-trace/src/appsec/iast/vulnerabilities.js +2 -0
  61. package/packages/dd-trace/src/appsec/iast/vulnerability-reporter.js +3 -3
  62. package/packages/dd-trace/src/appsec/rasp/fs-plugin.js +18 -11
  63. package/packages/dd-trace/src/appsec/rasp/utils.js +1 -1
  64. package/packages/dd-trace/src/appsec/recommended.json +88 -2
  65. package/packages/dd-trace/src/appsec/reporter.js +7 -7
  66. package/packages/dd-trace/src/appsec/stack_trace.js +11 -11
  67. package/packages/dd-trace/src/appsec/telemetry/common.js +1 -1
  68. package/packages/dd-trace/src/appsec/waf/waf_context_wrapper.js +2 -2
  69. package/packages/dd-trace/src/ci-visibility/dynamic-instrumentation/index.js +3 -3
  70. package/packages/dd-trace/src/ci-visibility/early-flake-detection/get-known-tests.js +2 -0
  71. package/packages/dd-trace/src/ci-visibility/exporters/git/git_metadata.js +3 -1
  72. package/packages/dd-trace/src/ci-visibility/intelligent-test-runner/get-skippable-suites.js +2 -0
  73. package/packages/dd-trace/src/ci-visibility/log-submission/log-submission-plugin.js +2 -0
  74. package/packages/dd-trace/src/ci-visibility/requests/get-library-configuration.js +2 -0
  75. package/packages/dd-trace/src/ci-visibility/telemetry.js +2 -0
  76. package/packages/dd-trace/src/ci-visibility/test-api-manual/test-api-manual-plugin.js +2 -0
  77. package/packages/dd-trace/src/ci-visibility/test-management/get-test-management-tests.js +7 -3
  78. package/packages/dd-trace/src/config.js +4 -0
  79. package/packages/dd-trace/src/config_stable.js +2 -0
  80. package/packages/dd-trace/src/datastreams/checkpointer.js +2 -0
  81. package/packages/dd-trace/src/datastreams/context.js +2 -0
  82. package/packages/dd-trace/src/datastreams/encoding.js +2 -0
  83. package/packages/dd-trace/src/datastreams/fnv.js +2 -0
  84. package/packages/dd-trace/src/datastreams/pathway.js +11 -9
  85. package/packages/dd-trace/src/datastreams/processor.js +8 -7
  86. package/packages/dd-trace/src/datastreams/schemas/schema.js +2 -0
  87. package/packages/dd-trace/src/datastreams/schemas/schema_builder.js +45 -36
  88. package/packages/dd-trace/src/datastreams/schemas/schema_sampler.js +2 -0
  89. package/packages/dd-trace/src/datastreams/writer.js +2 -0
  90. package/packages/dd-trace/src/debugger/devtools_client/index.js +12 -4
  91. package/packages/dd-trace/src/debugger/devtools_client/inspector_promises_polyfill.js +2 -0
  92. package/packages/dd-trace/src/debugger/devtools_client/remote_config.js +8 -5
  93. package/packages/dd-trace/src/debugger/devtools_client/snapshot/symbols.js +1 -1
  94. package/packages/dd-trace/src/debugger/index.js +36 -9
  95. package/packages/dd-trace/src/encode/tags-processors.js +2 -0
  96. package/packages/dd-trace/src/exporters/common/agent-info-exporter.js +2 -0
  97. package/packages/dd-trace/src/exporters/common/util.js +2 -0
  98. package/packages/dd-trace/src/exporters/span-stats/index.js +2 -0
  99. package/packages/dd-trace/src/exporters/span-stats/writer.js +2 -0
  100. package/packages/dd-trace/src/external-logger/src/index.js +2 -0
  101. package/packages/dd-trace/src/git_metadata_tagger.js +2 -0
  102. package/packages/dd-trace/src/git_properties.js +2 -0
  103. package/packages/dd-trace/src/guardrails/index.js +3 -4
  104. package/packages/dd-trace/src/guardrails/log.js +2 -2
  105. package/packages/dd-trace/src/guardrails/telemetry.js +16 -14
  106. package/packages/dd-trace/src/guardrails/util.js +0 -2
  107. package/packages/dd-trace/src/llmobs/plugins/bedrockruntime.js +2 -0
  108. package/packages/dd-trace/src/llmobs/plugins/langchain/handlers/index.js +5 -0
  109. package/packages/dd-trace/src/llmobs/plugins/langchain/handlers/tool.js +15 -0
  110. package/packages/dd-trace/src/llmobs/plugins/langchain/handlers/vectorstore.js +36 -0
  111. package/packages/dd-trace/src/llmobs/plugins/langchain/index.js +47 -4
  112. package/packages/dd-trace/src/llmobs/tagger.js +10 -1
  113. package/packages/dd-trace/src/noop/dogstatsd.js +2 -0
  114. package/packages/dd-trace/src/opentracing/propagation/text_map_dsm.js +2 -0
  115. package/packages/dd-trace/src/payload-tagging/config/index.js +2 -0
  116. package/packages/dd-trace/src/payload-tagging/index.js +2 -0
  117. package/packages/dd-trace/src/payload-tagging/tagging.js +2 -0
  118. package/packages/dd-trace/src/plugins/apollo.js +2 -0
  119. package/packages/dd-trace/src/plugins/ci_plugin.js +8 -3
  120. package/packages/dd-trace/src/plugins/index.js +1 -0
  121. package/packages/dd-trace/src/plugins/util/ci.js +2 -0
  122. package/packages/dd-trace/src/plugins/util/env.js +2 -0
  123. package/packages/dd-trace/src/plugins/util/git.js +40 -5
  124. package/packages/dd-trace/src/plugins/util/inferred_proxy.js +2 -0
  125. package/packages/dd-trace/src/plugins/util/llm.js +2 -0
  126. package/packages/dd-trace/src/plugins/util/serverless.js +2 -0
  127. package/packages/dd-trace/src/plugins/util/stacktrace.js +178 -50
  128. package/packages/dd-trace/src/plugins/util/tags.js +17 -1
  129. package/packages/dd-trace/src/plugins/util/test.js +9 -4
  130. package/packages/dd-trace/src/plugins/util/url.js +2 -0
  131. package/packages/dd-trace/src/plugins/util/user-provided-git.js +2 -0
  132. package/packages/dd-trace/src/profiling/exporters/event_serializer.js +4 -0
  133. package/packages/dd-trace/src/profiling/profiler.js +89 -70
  134. package/packages/dd-trace/src/profiling/profilers/event_plugins/dns.js +2 -0
  135. package/packages/dd-trace/src/profiling/profilers/event_plugins/dns_lookup.js +2 -0
  136. package/packages/dd-trace/src/profiling/profilers/event_plugins/dns_lookupservice.js +2 -0
  137. package/packages/dd-trace/src/profiling/profilers/event_plugins/dns_resolve.js +2 -0
  138. package/packages/dd-trace/src/profiling/profilers/event_plugins/dns_reverse.js +2 -0
  139. package/packages/dd-trace/src/profiling/profilers/event_plugins/event.js +2 -0
  140. package/packages/dd-trace/src/profiling/profilers/event_plugins/fs.js +2 -0
  141. package/packages/dd-trace/src/profiling/profilers/event_plugins/net.js +2 -0
  142. package/packages/dd-trace/src/profiling/profilers/events.js +2 -0
  143. package/packages/dd-trace/src/profiling/webspan-utils.js +2 -0
  144. package/packages/dd-trace/src/remote_config/capabilities.js +3 -1
  145. package/packages/dd-trace/src/remote_config/index.js +4 -0
  146. package/packages/dd-trace/src/service-naming/index.js +2 -0
  147. package/packages/dd-trace/src/service-naming/schemas/definition.js +2 -0
  148. package/packages/dd-trace/src/service-naming/schemas/util.js +2 -0
  149. package/packages/dd-trace/src/service-naming/schemas/v0/graphql.js +2 -0
  150. package/packages/dd-trace/src/service-naming/schemas/v0/index.js +2 -0
  151. package/packages/dd-trace/src/service-naming/schemas/v0/messaging.js +2 -0
  152. package/packages/dd-trace/src/service-naming/schemas/v0/serverless.js +2 -0
  153. package/packages/dd-trace/src/service-naming/schemas/v0/storage.js +2 -0
  154. package/packages/dd-trace/src/service-naming/schemas/v0/web.js +2 -0
  155. package/packages/dd-trace/src/service-naming/schemas/v1/graphql.js +2 -0
  156. package/packages/dd-trace/src/service-naming/schemas/v1/index.js +2 -0
  157. package/packages/dd-trace/src/service-naming/schemas/v1/messaging.js +2 -0
  158. package/packages/dd-trace/src/service-naming/schemas/v1/serverless.js +2 -0
  159. package/packages/dd-trace/src/service-naming/schemas/v1/storage.js +2 -0
  160. package/packages/dd-trace/src/service-naming/schemas/v1/web.js +2 -0
  161. package/packages/dd-trace/src/span_stats.js +2 -0
  162. package/packages/dd-trace/src/supported-configurations.json +2 -0
  163. package/packages/dd-trace/src/telemetry/send-data.js +2 -0
  164. package/register.js +4 -0
  165. package/version.js +0 -3
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": "2.2",
3
3
  "metadata": {
4
- "rules_version": "1.14.2"
4
+ "rules_version": "1.15.0"
5
5
  },
6
6
  "rules": [
7
7
  {
@@ -2985,7 +2985,7 @@
2985
2985
  "address": "graphql.server.resolver"
2986
2986
  }
2987
2987
  ],
2988
- "regex": "\\b(?:(?:l(?:(?:utimes|chmod)(?:Sync)?|(?:stat|ink)Sync)|w(?:rite(?:(?:File|v)(?:Sync)?|Sync)|atchFile)|u(?:n(?:watchFile|linkSync)|times(?:Sync)?)|s(?:(?:ymlink|tat)Sync|pawn(?:File|Sync))|ex(?:ec(?:File(?:Sync)?|Sync)|istsSync)|a(?:ppendFile|ccess)(?:Sync)?|(?:Caveat|Inode)s|open(?:dir)?Sync|new\\s+Function|Availability|\\beval)\\s*\\(|m(?:ain(?:Module\\s*(?:\\W*\\s*(?:constructor|require)|\\[)|\\s*(?:\\W*\\s*(?:constructor|require)|\\[))|kd(?:temp(?:Sync)?|irSync)\\s*\\(|odule\\.exports\\s*=)|c(?:(?:(?:h(?:mod|own)|lose)Sync|reate(?:Write|Read)Stream|p(?:Sync)?)\\s*\\(|o(?:nstructor\\s*(?:\\W*\\s*_load|\\[)|pyFile(?:Sync)?\\s*\\())|f(?:(?:(?:s(?:(?:yncS)?|tatS)|datas(?:yncS)?)ync|ch(?:mod|own)(?:Sync)?)\\s*\\(|u(?:nction\\s*\\(\\s*\\)\\s*{|times(?:Sync)?\\s*\\())|r(?:e(?:(?:ad(?:(?:File|link|dir)?Sync|v(?:Sync)?)|nameSync)\\s*\\(|quire\\s*(?:\\W*\\s*main|\\[))|m(?:Sync)?\\s*\\()|process\\s*(?:\\W*\\s*(?:mainModule|binding)|\\[)|t(?:his\\.constructor|runcateSync\\s*\\()|_(?:\\$\\$ND_FUNC\\$\\$_|_js_function)|global\\s*(?:\\W*\\s*process|\\[)|String\\s*\\.\\s*fromCharCode|binding\\s*\\[)",
2988
+ "regex": "\\b(?:(?:l(?:(?:utimes|chmod)(?:Sync)?|(?:stat|ink)Sync)|w(?:rite(?:(?:File|v)(?:Sync)?|Sync)|atchFile)|u(?:n(?:watchFile|linkSync)|times(?:Sync)?)|s(?:(?:ymlink|tat)Sync|pawn(?:File|Sync))|ex(?:ec(?:File(?:Sync)?|Sync)|istsSync)|a(?:ppendFile|ccess)(?:Sync)?|(?:Caveat|Inode)s|open(?:dir)?Sync|new\\s+Function|Availability|\\beval)\\s*\\(|m(?:ain(?:Module\\s*(?:\\W*\\s*(?:constructor|require)|\\[)|\\s*(?:\\W*\\s*(?:constructor|require)|\\[))|kd(?:temp(?:Sync)?|irSync)\\s*\\(|odule\\.exports\\s*=)|c(?:(?:(?:h(?:mod|own)|lose)Sync|reate(?:Write|Read)Stream|p(?:Sync)?)\\s*\\(|o(?:nstructor\\s*(?:\\W*\\s*_load|\\[)|pyFile(?:Sync)?\\s*\\())|f(?:(?:(?:s(?:(?:yncS)?|tatS)|datas(?:yncS)?)ync|ch(?:mod|own)(?:Sync)?)\\s*\\(|u(?:nction\\s*\\(\\s*\\)\\s*{|times(?:Sync)?\\s*\\())|r(?:e(?:(?:ad(?:(?:File|link|dir)?Sync|v(?:Sync)?)|nameSync)\\s*\\(|quire\\s*(?:\\W*\\s*main\\b|\\[))|m(?:Sync)?\\s*\\()|process\\s*(?:\\W*\\s*(?:mainModule|binding)|\\[)|t(?:his\\.constructor|runcateSync\\s*\\()|_(?:\\$\\$ND_FUNC\\$\\$_|_js_function)|global\\s*(?:\\W*\\s*process|\\[)|String\\s*\\.\\s*fromCharCode|binding\\s*\\[)",
2989
2989
  "options": {
2990
2990
  "case_sensitive": true,
2991
2991
  "min_length": 3
@@ -5656,6 +5656,52 @@
5656
5656
  ],
5657
5657
  "transformers": []
5658
5658
  },
5659
+ {
5660
+ "id": "dog-932-110",
5661
+ "name": "Python: Subprocess-based command injection",
5662
+ "tags": {
5663
+ "type": "command_injection",
5664
+ "category": "attack_attempt",
5665
+ "confidence": "0",
5666
+ "module": "waf"
5667
+ },
5668
+ "conditions": [
5669
+ {
5670
+ "parameters": {
5671
+ "inputs": [
5672
+ {
5673
+ "address": "server.request.query"
5674
+ },
5675
+ {
5676
+ "address": "server.request.body"
5677
+ },
5678
+ {
5679
+ "address": "server.request.path_params"
5680
+ },
5681
+ {
5682
+ "address": "server.request.headers.no_cookies"
5683
+ },
5684
+ {
5685
+ "address": "grpc.server.request.message"
5686
+ },
5687
+ {
5688
+ "address": "graphql.server.all_resolvers"
5689
+ },
5690
+ {
5691
+ "address": "graphql.server.resolver"
5692
+ }
5693
+ ],
5694
+ "regex": "(?s)\\bsubprocess\\b.*\\b(?:check_output|run|Popen|call|check_call)\\b",
5695
+ "options": {
5696
+ "case_sensitive": true,
5697
+ "min_length": 14
5698
+ }
5699
+ },
5700
+ "operator": "match_regex"
5701
+ }
5702
+ ],
5703
+ "transformers": []
5704
+ },
5659
5705
  {
5660
5706
  "id": "dog-934-001",
5661
5707
  "name": "XXE - XML file loads external entity",
@@ -9074,6 +9120,28 @@
9074
9120
  "evaluate": true,
9075
9121
  "output": true
9076
9122
  },
9123
+ {
9124
+ "id": "decode-auth-jwt",
9125
+ "generator": "jwt_decode",
9126
+ "min_version": "1.25.0",
9127
+ "parameters": {
9128
+ "mappings": [
9129
+ {
9130
+ "inputs": [
9131
+ {
9132
+ "address": "server.request.headers.no_cookies",
9133
+ "key_path": [
9134
+ "authorization"
9135
+ ]
9136
+ }
9137
+ ],
9138
+ "output": "server.request.jwt"
9139
+ }
9140
+ ]
9141
+ },
9142
+ "evaluate": true,
9143
+ "output": false
9144
+ },
9077
9145
  {
9078
9146
  "id": "http-network-fingerprint",
9079
9147
  "generator": "http_network_fingerprint",
@@ -9918,6 +9986,24 @@
9918
9986
  "category": "payment"
9919
9987
  }
9920
9988
  },
9989
+ {
9990
+ "id": "c542c147-3883-43d6-a067-178e4a7bd65d",
9991
+ "name": "Password",
9992
+ "key": {
9993
+ "operator": "match_regex",
9994
+ "parameters": {
9995
+ "regex": "\\bpass(?:[_-]?word|wd)?\\b|\\bpwd\\b",
9996
+ "options": {
9997
+ "case_sensitive": false,
9998
+ "min_length": 3
9999
+ }
10000
+ }
10001
+ },
10002
+ "tags": {
10003
+ "type": "password",
10004
+ "category": "credentials"
10005
+ }
10006
+ },
9921
10007
  {
9922
10008
  "id": "18b608bd7a764bff5b2344c0",
9923
10009
  "name": "Phone number",
@@ -430,12 +430,12 @@ function isRaspAttack (events) {
430
430
  return events.some(e => e.rule?.tags?.module === 'rasp')
431
431
  }
432
432
 
433
- function isFingerprintDerivative (derivative) {
434
- return derivative.startsWith('_dd.appsec.fp')
433
+ function isFingerprintAttribute (attribute) {
434
+ return attribute.startsWith('_dd.appsec.fp')
435
435
  }
436
436
 
437
- function reportDerivatives (derivatives) {
438
- if (!derivatives) return
437
+ function reportAttributes (attributes) {
438
+ if (!attributes) return
439
439
 
440
440
  const req = storage('legacy').getStore()?.req
441
441
  const rootSpan = web.root(req)
@@ -443,8 +443,8 @@ function reportDerivatives (derivatives) {
443
443
  if (!rootSpan) return
444
444
 
445
445
  const tags = {}
446
- for (let [tag, value] of Object.entries(derivatives)) {
447
- if (!isFingerprintDerivative(tag)) {
446
+ for (let [tag, value] of Object.entries(attributes)) {
447
+ if (!isFingerprintAttribute(tag)) {
448
448
  const gzippedValue = zlib.gzipSync(JSON.stringify(value))
449
449
  value = gzippedValue.toString('base64')
450
450
  }
@@ -543,7 +543,7 @@ module.exports = {
543
543
  reportAttack,
544
544
  reportWafUpdate: incrementWafUpdatesMetric,
545
545
  reportRaspRuleSkipped: updateRaspRuleSkippedMetricTags,
546
- reportDerivatives,
546
+ reportAttributes,
547
547
  finishRequest,
548
548
  mapHeaderAndTags,
549
549
  truncateRequestBody
@@ -9,36 +9,36 @@ const STACK_TRACE_NAMESPACES = {
9
9
  IAST: 'vulnerability'
10
10
  }
11
11
 
12
- function getCallSiteList (maxDepth = 100) {
12
+ function prepareStackTrace (_, callsites) {
13
+ return callsites
14
+ }
15
+
16
+ function getCallSiteList (maxDepth = 100, constructorOpt) {
13
17
  const previousPrepareStackTrace = Error.prepareStackTrace
14
18
  const previousStackTraceLimit = Error.stackTraceLimit
15
- let callsiteList
16
19
  // Since some frames will be discarded because they come from tracer codebase, a buffer is added
17
20
  // to the limit in order to get as close as `maxDepth` number of frames.
18
21
  Error.stackTraceLimit = maxDepth + LIBRARY_FRAMES_BUFFER
19
22
 
20
23
  try {
21
- Error.prepareStackTrace = function (_, callsites) {
22
- callsiteList = callsites
23
- }
24
- const e = new Error('message')
25
- e.stack
24
+ Error.prepareStackTrace = prepareStackTrace
25
+ const obj = {}
26
+ Error.captureStackTrace(obj, constructorOpt)
27
+ return obj.stack
26
28
  } finally {
27
29
  Error.prepareStackTrace = previousPrepareStackTrace
28
30
  Error.stackTraceLimit = previousStackTraceLimit
29
31
  }
30
-
31
- return callsiteList
32
32
  }
33
33
 
34
34
  function filterOutFramesFromLibrary (callSiteList) {
35
35
  return callSiteList.filter(callSite => !callSite.getFileName()?.startsWith(ddBasePath))
36
36
  }
37
37
 
38
- function getCallsiteFrames (maxDepth = 32, callSiteListGetter = getCallSiteList) {
38
+ function getCallsiteFrames (maxDepth = 32, constructorOpt = getCallsiteFrames, callSiteListGetter = getCallSiteList) {
39
39
  if (maxDepth < 1) maxDepth = Infinity
40
40
 
41
- const callSiteList = callSiteListGetter(maxDepth)
41
+ const callSiteList = callSiteListGetter(maxDepth, constructorOpt)
42
42
  const filteredFrames = filterOutFramesFromLibrary(callSiteList)
43
43
 
44
44
  const half = filteredFrames.length > maxDepth ? Math.round(maxDepth / 2) : Infinity
@@ -1,4 +1,4 @@
1
- 'use strinct'
1
+ 'use strict'
2
2
 
3
3
  const DD_TELEMETRY_REQUEST_METRICS = Symbol('_dd.appsec.telemetry.request.metrics')
4
4
 
@@ -135,7 +135,7 @@ class WAFContextWrapper {
135
135
  this.setUserIdCache(userId, result)
136
136
  }
137
137
 
138
- metrics.duration = result.totalRuntime / 1e3
138
+ metrics.duration = result.duration / 1e3
139
139
  metrics.blockTriggered = blockTriggered
140
140
  metrics.ruleTriggered = ruleTriggered
141
141
  metrics.wafTimeout = result.timeout
@@ -144,7 +144,7 @@ class WAFContextWrapper {
144
144
  Reporter.reportAttack(result.events)
145
145
  }
146
146
 
147
- Reporter.reportDerivatives(result.derivatives)
147
+ Reporter.reportAttributes(result.attributes)
148
148
 
149
149
  return result
150
150
  } catch (err) {
@@ -62,7 +62,7 @@ class TestVisDynamicInstrumentation {
62
62
 
63
63
  log.debug('Starting Test Visibility - Dynamic Instrumentation client...')
64
64
 
65
- const rcChannel = new MessageChannel() // mock channel
65
+ const probeChannel = new MessageChannel() // mock channel
66
66
  const configChannel = new MessageChannel() // mock channel
67
67
 
68
68
  this.worker = new Worker(
@@ -84,14 +84,14 @@ class TestVisDynamicInstrumentation {
84
84
  workerData: {
85
85
  config: this._config.serialize(),
86
86
  parentThreadId,
87
- rcPort: rcChannel.port1,
87
+ probePort: probeChannel.port1,
88
88
  configPort: configChannel.port1,
89
89
  breakpointSetChannel: this.breakpointSetChannel.port1,
90
90
  breakpointHitChannel: this.breakpointHitChannel.port1,
91
91
  breakpointRemoveChannel: this.breakpointRemoveChannel.port1
92
92
  },
93
93
  transferList: [
94
- rcChannel.port1,
94
+ probeChannel.port1,
95
95
  configChannel.port1,
96
96
  this.breakpointSetChannel.port1,
97
97
  this.breakpointHitChannel.port1,
@@ -1,3 +1,5 @@
1
+ 'use strict'
2
+
1
3
  const request = require('../../exporters/common/request')
2
4
  const id = require('../../id')
3
5
  const log = require('../../log')
@@ -1,3 +1,5 @@
1
+ 'use strict'
2
+
1
3
  const fs = require('fs')
2
4
  const path = require('path')
3
5
 
@@ -287,7 +289,7 @@ function sendGitMetadata (url, { isEvpProxy, evpProxyPrefix }, configRepositoryU
287
289
  // Otherwise we unshallow and get commits to upload again
288
290
  log.debug('It is shallow clone, unshallowing...')
289
291
  if (!isFalse(getEnvironmentVariable('DD_CIVISIBILITY_GIT_UNSHALLOW_ENABLED'))) {
290
- unshallowRepository()
292
+ unshallowRepository(false)
291
293
  }
292
294
 
293
295
  // The latest commits change after unshallowing
@@ -1,3 +1,5 @@
1
+ 'use strict'
2
+
1
3
  const request = require('../../exporters/common/request')
2
4
  const log = require('../../log')
3
5
  const { getEnvironmentVariable } = require('../../config-helper')
@@ -1,3 +1,5 @@
1
+ 'use strict'
2
+
1
3
  const Plugin = require('../../plugins/plugin')
2
4
  const log = require('../../log')
3
5
  const { getEnvironmentVariable } = require('../../config-helper')
@@ -1,3 +1,5 @@
1
+ 'use strict'
2
+
1
3
  const request = require('../../exporters/common/request')
2
4
  const id = require('../../id')
3
5
  const log = require('../../log')
@@ -1,3 +1,5 @@
1
+ 'use strict'
2
+
1
3
  const telemetryMetrics = require('../telemetry/metrics')
2
4
 
3
5
  const ciVisibilityMetrics = telemetryMetrics.manager.namespace('civisibility')
@@ -1,3 +1,5 @@
1
+ 'use strict'
2
+
1
3
  const CiPlugin = require('../../plugins/ci_plugin')
2
4
  const {
3
5
  TEST_STATUS,
@@ -1,3 +1,5 @@
1
+ 'use strict'
2
+
1
3
  const request = require('../../exporters/common/request')
2
4
  const id = require('../../id')
3
5
  const { getEnvironmentVariable } = require('../../config-helper')
@@ -9,7 +11,9 @@ function getTestManagementTests ({
9
11
  isGzipCompatible,
10
12
  repositoryUrl,
11
13
  commitMessage,
12
- sha
14
+ sha,
15
+ commitHeadSha,
16
+ commitHeadMessage
13
17
  }, done) {
14
18
  const options = {
15
19
  path: '/api/v2/test/libraries/test-management/tests',
@@ -43,8 +47,8 @@ function getTestManagementTests ({
43
47
  type: 'ci_app_libraries_tests_request',
44
48
  attributes: {
45
49
  repository_url: repositoryUrl,
46
- commit_message: commitMessage,
47
- sha
50
+ commit_message: commitHeadMessage || commitMessage,
51
+ sha: commitHeadSha || sha
48
52
  }
49
53
  }
50
54
  })
@@ -516,6 +516,7 @@ class Config {
516
516
  defaults['dogstatsd.port'] = '8125'
517
517
  defaults.dsmEnabled = false
518
518
  defaults['dynamicInstrumentation.enabled'] = false
519
+ defaults['dynamicInstrumentation.probeFile'] = undefined
519
520
  defaults['dynamicInstrumentation.redactedIdentifiers'] = []
520
521
  defaults['dynamicInstrumentation.redactionExcludedIdentifiers'] = []
521
522
  defaults['dynamicInstrumentation.uploadIntervalSeconds'] = 1
@@ -707,6 +708,7 @@ class Config {
707
708
  DD_DOGSTATSD_HOST,
708
709
  DD_DOGSTATSD_PORT,
709
710
  DD_DYNAMIC_INSTRUMENTATION_ENABLED,
711
+ DD_DYNAMIC_INSTRUMENTATION_PROBE_FILE,
710
712
  DD_DYNAMIC_INSTRUMENTATION_REDACTED_IDENTIFIERS,
711
713
  DD_DYNAMIC_INSTRUMENTATION_REDACTION_EXCLUDED_IDENTIFIERS,
712
714
  DD_DYNAMIC_INSTRUMENTATION_UPLOAD_INTERVAL_SECONDS,
@@ -883,6 +885,7 @@ class Config {
883
885
  this._setString(env, 'dogstatsd.port', DD_DOGSTATSD_PORT)
884
886
  this._setBoolean(env, 'dsmEnabled', DD_DATA_STREAMS_ENABLED)
885
887
  this._setBoolean(env, 'dynamicInstrumentation.enabled', DD_DYNAMIC_INSTRUMENTATION_ENABLED)
888
+ this._setString(env, 'dynamicInstrumentation.probeFile', DD_DYNAMIC_INSTRUMENTATION_PROBE_FILE)
886
889
  this._setArray(env, 'dynamicInstrumentation.redactedIdentifiers', DD_DYNAMIC_INSTRUMENTATION_REDACTED_IDENTIFIERS)
887
890
  this._setArray(
888
891
  env,
@@ -1108,6 +1111,7 @@ class Config {
1108
1111
  }
1109
1112
  this._setBoolean(opts, 'dsmEnabled', options.dsmEnabled)
1110
1113
  this._setBoolean(opts, 'dynamicInstrumentation.enabled', options.dynamicInstrumentation?.enabled)
1114
+ this._setString(opts, 'dynamicInstrumentation.probeFile', options.dynamicInstrumentation?.probeFile)
1111
1115
  this._setArray(
1112
1116
  opts,
1113
1117
  'dynamicInstrumentation.redactedIdentifiers',
@@ -1,3 +1,5 @@
1
+ 'use strict'
2
+
1
3
  const os = require('os')
2
4
  const fs = require('fs')
3
5
  const { getEnvironmentVariable } = require('../../dd-trace/src/config-helper')
@@ -1,3 +1,5 @@
1
+ 'use strict'
2
+
1
3
  const DataStreamsContext = require('./context')
2
4
 
3
5
  class DataStreamsCheckpointer {
@@ -1,3 +1,5 @@
1
+ 'use strict'
2
+
1
3
  const { storage } = require('../../../datadog-core')
2
4
  const log = require('../log')
3
5
 
@@ -1,3 +1,5 @@
1
+ 'use strict'
2
+
1
3
  // encodes positive and negative numbers, using zig zag encoding to reduce the size of the variable length encoding.
2
4
  // uses high and low part to ensure those parts are under the limit for byte operations in javascript (32 bits)
3
5
  // maximum number possible to encode is MAX_SAFE_INTEGER/2 (using zig zag shifts the bits by 1 to the left)
@@ -1,3 +1,5 @@
1
+ 'use strict'
2
+
1
3
  const FNV_64_PRIME = BigInt('0x100000001B3')
2
4
  const FNV1_64_INIT = BigInt('0xCBF29CE484222325')
3
5
 
@@ -1,14 +1,15 @@
1
+ 'use strict'
2
+
1
3
  // encoding used here is sha256
2
4
  // other languages use FNV1
3
5
  // this inconsistency is ok because hashes do not need to be consistent across services
4
6
  const crypto = require('crypto')
5
7
  const { encodeVarint, decodeVarint } = require('./encoding')
6
- const LRUCache = require('lru-cache')
8
+ const { LRUCache } = require('lru-cache')
7
9
  const log = require('../log')
8
10
  const pick = require('../../../datadog-core/src/utils/src/pick')
9
11
 
10
- const options = { max: 500 }
11
- const cache = new LRUCache(options)
12
+ const cache = new LRUCache({ max: 500 })
12
13
 
13
14
  const CONTEXT_PROPAGATION_KEY = 'dd-pathway-ctx'
14
15
  const CONTEXT_PROPAGATION_KEY_BASE64 = 'dd-pathway-ctx-base64'
@@ -24,15 +25,16 @@ function computeHash (service, env, edgeTags, parentHash) {
24
25
  edgeTags.sort()
25
26
  const hashableEdgeTags = edgeTags.filter(item => item !== 'manual_checkpoint:true')
26
27
 
27
- const key = `${service}${env}` + hashableEdgeTags.join('') + parentHash.toString()
28
- if (cache.get(key)) {
29
- return cache.get(key)
28
+ const key = `${service}${env}${hashableEdgeTags.join('')}${parentHash}`
29
+ let value = cache.get(key)
30
+ if (value) {
31
+ return value
30
32
  }
31
33
  const currentHash = shaHash(`${service}${env}` + hashableEdgeTags.join(''))
32
34
  const buf = Buffer.concat([currentHash, parentHash], 16)
33
- const val = shaHash(buf.toString())
34
- cache.set(key, val)
35
- return val
35
+ value = shaHash(buf.toString())
36
+ cache.set(key, value)
37
+ return value
36
38
  }
37
39
 
38
40
  function encodePathwayContext (dataStreamsContext) {
@@ -1,3 +1,5 @@
1
+ 'use strict'
2
+
1
3
  const os = require('os')
2
4
  const pkg = require('../../../../package.json')
3
5
 
@@ -78,15 +80,14 @@ class StatsBucket {
78
80
  return this._backlogs
79
81
  }
80
82
 
81
- forCheckpoint (checkpoint) {
82
- const key = checkpoint.hash
83
- if (!this._checkpoints.has(key)) {
84
- this._checkpoints.set(
85
- key, new StatsPoint(checkpoint.hash, checkpoint.parentHash, checkpoint.edgeTags)
86
- )
83
+ forCheckpoint ({ hash, parentHash, edgeTags }) {
84
+ let checkpoint = this._checkpoints.get(hash)
85
+ if (!checkpoint) {
86
+ checkpoint = new StatsPoint(hash, parentHash, edgeTags)
87
+ this._checkpoints.set(hash, checkpoint)
87
88
  }
88
89
 
89
- return this._checkpoints.get(key)
90
+ return checkpoint
90
91
  }
91
92
 
92
93
  /**
@@ -1,3 +1,5 @@
1
+ 'use strict'
2
+
1
3
  class Schema {
2
4
  constructor (definition, id) {
3
5
  this.definition = definition
@@ -1,4 +1,6 @@
1
- const LRUCache = require('lru-cache')
1
+ 'use strict'
2
+
3
+ const { LRUCache } = require('lru-cache')
2
4
  const { fnv64 } = require('../fnv')
3
5
  const { Schema } = require('./schema')
4
6
 
@@ -13,22 +15,24 @@ class SchemaBuilder {
13
15
  this.properties = 0
14
16
  }
15
17
 
18
+ // TODO: This is only used in tests. Let's refactor the code and stop exposing the cache.
16
19
  static getCache () {
17
20
  return CACHE
18
21
  }
19
22
 
20
23
  static getSchemaDefinition (schema) {
21
- const noNones = convertToJsonCompatible(schema)
22
- const definition = jsonStringify(noNones)
24
+ const definition = toJSON(schema)
23
25
  const id = fnv64(Buffer.from(definition, 'utf8')).toString()
24
26
  return new Schema(definition, id)
25
27
  }
26
28
 
27
29
  static getSchema (schemaName, iterator, builder) {
28
- if (!CACHE.has(schemaName)) {
29
- CACHE.set(schemaName, (builder ?? new SchemaBuilder(iterator)).build())
30
+ let entry = CACHE.get(schemaName)
31
+ if (!entry) {
32
+ entry = (builder ?? new SchemaBuilder(iterator)).build()
33
+ CACHE.set(schemaName, entry)
30
34
  }
31
- return CACHE.get(schemaName)
35
+ return entry
32
36
  }
33
37
 
34
38
  build () {
@@ -92,42 +96,47 @@ class OpenApiComponents {
92
96
  }
93
97
  }
94
98
 
95
- function convertToJsonCompatible (obj) {
96
- if (Array.isArray(obj)) {
97
- return obj.filter(item => item !== null).map(item => convertToJsonCompatible(item))
98
- } else if (obj && typeof obj === 'object') {
99
- const jsonObj = {}
100
- for (const [key, value] of Object.entries(obj)) {
101
- if (value !== null) {
102
- jsonObj[key] = convertToJsonCompatible(value)
99
+ // This adds a single whitespace between entries without adding newlines.
100
+ // This differs from JSON.stringify and is used to align with the output
101
+ // in other platforms.
102
+ // TODO: Add tests to verify this behavior. A couple of cases are not
103
+ // covered by the existing tests.
104
+ function toJSON (value) {
105
+ // eslint-disable-next-line eslint-rules/eslint-safe-typeof-object
106
+ if (typeof value === 'object') {
107
+ if (value === null) {
108
+ return 'null'
109
+ }
110
+ if (Array.isArray(value)) {
111
+ let result = '['
112
+ for (let i = 0; i < value.length; i++) {
113
+ if (value[i] !== null) {
114
+ if (i !== 0) {
115
+ result += ', '
116
+ }
117
+ result += value[i] === undefined ? 'null' : toJSON(value[i])
118
+ }
103
119
  }
120
+ return `${result}]`
104
121
  }
105
- return jsonObj
106
- }
107
- return obj
108
- }
109
-
110
- function convertKey (key) {
111
- if (key === 'enumValues') {
112
- return 'enum'
122
+ let result = '{'
123
+ for (const [key, objectValue] of Object.entries(value)) {
124
+ if (objectValue != null && typeof key === 'string') {
125
+ const converted = toJSON(objectValue)
126
+ if (converted !== undefined) {
127
+ if (result !== '{') {
128
+ result += ', '
129
+ }
130
+ result += `"${key}": ${converted}`
131
+ }
132
+ }
133
+ }
134
+ return `${result}}`
113
135
  }
114
- return key
115
- }
116
-
117
- function jsonStringify (obj, indent = 2) {
118
- // made to stringify json exactly similar to python / java in order for hashing to be the same
119
- const jsonString = JSON.stringify(obj, (_, value) => value, indent)
120
- return jsonString.replaceAll(/^ +/gm, ' ') // Replace leading spaces with single space
121
- .replaceAll('\n', '') // Remove newlines
122
- .replaceAll('{ ', '{') // Remove space after '{'
123
- .replaceAll(' }', '}') // Remove space before '}'
124
- .replaceAll('[ ', '[') // Remove space after '['
125
- .replaceAll(' ]', ']') // Remove space before ']'
136
+ return JSON.stringify(value)
126
137
  }
127
138
 
128
139
  module.exports = {
129
140
  SchemaBuilder,
130
141
  OpenApiSchema,
131
- convertToJsonCompatible,
132
- convertKey
133
142
  }
@@ -1,3 +1,5 @@
1
+ 'use strict'
2
+
1
3
  const SAMPLE_INTERVAL_MILLIS = 30 * 1000
2
4
 
3
5
  class SchemaSampler {
@@ -1,3 +1,5 @@
1
+ 'use strict'
2
+
1
3
  const pkg = require('../../../../package.json')
2
4
  const log = require('../log')
3
5
  const request = require('../exporters/common/request')
@@ -40,11 +40,19 @@ const SUPPORT_ARRAY_BUFFER_RESIZE = NODE_MAJOR >= 20
40
40
  const oneSecondNs = 1_000_000_000n
41
41
  let globalSnapshotSamplingRateWindowStart = 0n
42
42
  let snapshotsSampledWithinTheLastSecond = 0
43
- // TODO: Is a limit of 256 snapshots ever going to be a problem?
44
- const snapshotProbeIndexBuffer = new ArrayBuffer(1, { maxByteLength: 256 })
45
- // TODO: Is a limit of 256 probes ever going to be a problem?
43
+
46
44
  // TODO: Change to const once we drop support for Node.js 18
47
- let snapshotProbeIndex = new Uint8Array(snapshotProbeIndexBuffer)
45
+ let snapshotProbeIndexBuffer, snapshotProbeIndex
46
+
47
+ if (SUPPORT_ARRAY_BUFFER_RESIZE) {
48
+ // TODO: Is a limit of 256 snapshots ever going to be a problem?
49
+ // eslint-disable-next-line n/no-unsupported-features/es-syntax
50
+ snapshotProbeIndexBuffer = new ArrayBuffer(1, { maxByteLength: 256 })
51
+ // TODO: Is a limit of 256 probes ever going to be a problem?
52
+ snapshotProbeIndex = new Uint8Array(snapshotProbeIndexBuffer)
53
+ } else {
54
+ snapshotProbeIndex = new Uint8Array(1)
55
+ }
48
56
 
49
57
  // WARNING: The code above the line `await session.post('Debugger.resume')` is highly optimized. Please edit with care!
50
58
  session.on('Debugger.paused', async ({ params }) => {
@@ -1,5 +1,7 @@
1
1
  'use strict'
2
2
 
3
+ /* eslint n/no-unsupported-features/node-builtins: ['error', { ignores: ['inspector/promises'] }] */
4
+
3
5
  const { builtinModules } = require('node:module')
4
6
 
5
7
  if (builtinModules.includes('inspector/promises')) {