securenow 8.11.1 → 8.11.3

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.
package/legacy-semconv.js CHANGED
@@ -1,5 +1,7 @@
1
1
  'use strict';
2
2
 
3
+ const { isOtpCodeField } = require('./otp-redaction');
4
+
3
5
  /**
4
6
  * Legacy semantic-convention attributes for the OpenTelemetry 0.221+ /
5
7
  * contrib 0.74+ instrumentations, which emit ONLY the stable conventions.
@@ -24,7 +26,7 @@
24
26
  * - http.client_ip is NOT derived from the first X-Forwarded-For entry (that
25
27
  * value is spoofable). SecureNow's requestHook sets http.client_ip from the
26
28
  * trusted-proxy resolver (resolve-ip.js).
27
- * - Signature-style query parameters (same list upstream now redacts on
29
+ * - OTP/code and signature-style query parameters (same list upstream redacts on
28
30
  * url.query / url.full) are replaced with REDACTED in http.target / http.url.
29
31
  * Every other byte of the target is kept exactly as received, so detection
30
32
  * rules that match encoded payloads keep working.
@@ -62,7 +64,6 @@ function defined(attributes) {
62
64
  function redactSearch(search, paramsToRedact = DEFAULT_REDACTED_QUERY_PARAMS) {
63
65
  if (typeof search !== 'string' || search.length < 2 || search[0] !== '?') return search;
64
66
  const sensitive = new Set(paramsToRedact || []);
65
- if (sensitive.size === 0) return search;
66
67
  let changed = false;
67
68
  const parts = search.slice(1).split('&').map((part) => {
68
69
  const eq = part.indexOf('=');
@@ -71,7 +72,7 @@ function redactSearch(search, paramsToRedact = DEFAULT_REDACTED_QUERY_PARAMS) {
71
72
  try {
72
73
  key = decodeURIComponent(rawKey.replace(/\+/g, ' '));
73
74
  } catch (_) {}
74
- if (!sensitive.has(key)) return part;
75
+ if (!sensitive.has(key) && !isOtpCodeField(key)) return part;
75
76
  changed = true;
76
77
  return `${rawKey}=${REDACTED}`;
77
78
  });