@ogcio/o11y-sdk-node 0.7.1 → 0.8.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.
@@ -1,17 +1,44 @@
1
1
  import { BasicRedactor } from "./basic-redactor.js";
2
2
  export class IpRedactor extends BasicRedactor {
3
- static IPV4_REGEX = /(?<!\d)(?:%[0-9A-Fa-f]{2})?(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}(?:%[0-9A-Fa-f]{2})?(?!\d)/gi;
4
- static IPV6_REGEX = /(?<![0-9a-f:])(?:%[0-9A-Fa-f]{2})?((?:[0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4}|(?:[0-9A-Fa-f]{1,4}:){1,7}:|:(?::[0-9A-Fa-f]{1,4}){1,7}|(?:[0-9A-Fa-f]{1,4}:){1,6}:[0-9A-Fa-f]{1,4}|(?:[0-9A-Fa-f]{1,4}:){1,5}(?::[0-9A-Fa-f]{1,4}){1,2}|(?:[0-9A-Fa-f]{1,4}:){1,4}(?::[0-9A-Fa-f]{1,4}){1,3}|(?:[0-9A-Fa-f]{1,4}:){1,3}(?::[0-9A-Fa-f]{1,4}){1,4}|(?:[0-9A-Fa-f]{1,4}:){1,2}(?::[0-9A-Fa-f]{1,4}){1,5}|[0-9A-Fa-f]{1,4}:(?::[0-9A-Fa-f]{1,4}){1,6}|:(?::[0-9A-Fa-f]{1,4}){1,7}:?|(?:[0-9A-Fa-f]{1,4}:){1,4}:(?:25[0-5]|2[0-4]\d|1\d\d|\d{1,2})(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|\d{1,2})){3})(?:%[0-9A-Fa-f]{2})?(?![0-9a-f:])/gi;
3
+ // iOS < 16.6 compatible: no lookbehind/lookahead
4
+ static IPV4_REGEX = /(?:%[0-9A-Fa-f]{2})?(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\.(25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){3})(?:%[0-9A-Fa-f]{2})?/gi;
5
7
  redact(value) {
6
8
  const counters = {};
7
- const redactedValue = value
8
- .replace(IpRedactor.IPV4_REGEX, () => {
9
- counters["IPv4"] = (counters["IPv4"] || 0) + 1;
10
- return "[REDACTED IPV4]";
11
- })
12
- .replace(IpRedactor.IPV6_REGEX, () => {
13
- counters["IPv6"] = (counters["IPv6"] || 0) + 1;
14
- return "[REDACTED IPV6]";
9
+ // First pass: redact IPv4 with boundary checking
10
+ const tempValue = value.replace(IpRedactor.IPV4_REGEX, (match, ...args) => {
11
+ const offset = args[args.length - 2];
12
+ const before = offset > 0 ? value[offset - 1] : "";
13
+ const after = offset + match.length < value.length
14
+ ? value[offset + match.length]
15
+ : "";
16
+ // Check if surrounded by non-digit characters
17
+ const isValidBefore = !before || !/\d/.test(before);
18
+ const isValidAfter = !after || !/\d/.test(after);
19
+ if (isValidBefore && isValidAfter) {
20
+ counters["IPv4"] = (counters["IPv4"] || 0) + 1;
21
+ return "[REDACTED IPV4]";
22
+ }
23
+ return match;
24
+ });
25
+ // Second pass: redact IPv6 with boundary checking
26
+ const redactedValue = tempValue.replace(IpRedactor.IPV6_REGEX, (match, ...args) => {
27
+ const offset = args[args.length - 2];
28
+ const before = offset > 0 ? tempValue[offset - 1] : "";
29
+ const after = offset + match.length < tempValue.length
30
+ ? tempValue[offset + match.length]
31
+ : "";
32
+ // For IPv6:
33
+ // Reject if there's a colon before (indicating :::)
34
+ // Reject if there's a hex digit or colon after
35
+ const isValidBefore = !before || !/[0-9a-f:]/i.test(before);
36
+ const isValidAfter = !after || !/[0-9a-f:]/i.test(after);
37
+ if (isValidBefore && isValidAfter) {
38
+ counters["IPv6"] = (counters["IPv6"] || 0) + 1;
39
+ return "[REDACTED IPV6]";
40
+ }
41
+ return match;
15
42
  });
16
43
  return {
17
44
  redactedValue: redactedValue,
@@ -1,11 +1,23 @@
1
1
  import { BasicRedactor } from "./basic-redactor.js";
2
2
  export class PpsnRedactor extends BasicRedactor {
3
- static PPSN_REGEX = /(?<!([0-9]|[a-z]))[0-9]{7}[a-z]{1,2}(?!([0-9]|[a-z]))/gi;
3
+ // iOS < 16.6 compatible: no lookbehind/lookahead
4
+ static PPSN_REGEX = /[0-9]{7}[a-z]{1,2}/gi;
4
5
  redact(value) {
5
6
  let redactedCounter = 0;
6
- const redactedValue = value.replace(PpsnRedactor.PPSN_REGEX, (_) => {
7
- redactedCounter++;
8
- return "[REDACTED PPSN]";
7
+ // Boundary checking to replace lookbehind/lookahead
8
+ const redactedValue = value.replace(PpsnRedactor.PPSN_REGEX, (match, offset) => {
9
+ const before = offset > 0 ? value[offset - 1] : "";
10
+ const after = offset + match.length < value.length
11
+ ? value[offset + match.length]
12
+ : "";
13
+ // Check if surrounded by non-alphanumeric characters
14
+ const isValidBefore = !before || !/[0-9a-z]/i.test(before);
15
+ const isValidAfter = !after || !/[0-9a-z]/i.test(after);
16
+ if (isValidBefore && isValidAfter) {
17
+ redactedCounter++;
18
+ return "[REDACTED PPSN]";
19
+ }
20
+ return match;
9
21
  });
10
22
  return {
11
23
  redactedValue: redactedValue,
@@ -1,5 +1,6 @@
1
1
  import type { NodeSDK } from "@opentelemetry/sdk-node";
2
2
  import buildNodeInstrumentation from "./lib/instrumentation.node.js";
3
+ export type { SpanKind, SpanStatus, SpanStatusCode, TraceFlags, } from "@opentelemetry/api";
3
4
  export type * from "./lib/index.js";
4
5
  export type { NodeSDK };
5
6
  export { buildNodeInstrumentation as instrumentNode };
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ogcio/o11y-sdk-node",
3
- "version": "0.7.1",
3
+ "version": "0.8.0",
4
4
  "description": "Opentelemetry standard instrumentation SDK for NodeJS based project",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
@@ -36,7 +36,7 @@
36
36
  "@grpc/grpc-js": "1.14.3",
37
37
  "@opentelemetry/api": "1.9.0",
38
38
  "@opentelemetry/api-logs": "0.208.0",
39
- "@opentelemetry/auto-instrumentations-node": "0.67.2",
39
+ "@opentelemetry/auto-instrumentations-node": "0.67.3",
40
40
  "@opentelemetry/core": "2.2.0",
41
41
  "@opentelemetry/exporter-logs-otlp-grpc": "0.208.0",
42
42
  "@opentelemetry/exporter-logs-otlp-http": "0.208.0",
@@ -53,11 +53,11 @@
53
53
  "@opentelemetry/sdk-trace-base": "2.2.0"
54
54
  },
55
55
  "devDependencies": {
56
- "@types/node": "25.0.2",
57
- "@vitest/coverage-v8": "4.0.15",
56
+ "@types/node": "25.0.3",
57
+ "@vitest/coverage-v8": "4.0.16",
58
58
  "tsx": "4.21.0",
59
59
  "typescript": "5.9.3",
60
- "vitest": "4.0.15"
60
+ "vitest": "4.0.16"
61
61
  },
62
62
  "engines": {
63
63
  "node": ">=20.6.0"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ogcio/o11y-sdk-node",
3
- "version": "0.7.1",
3
+ "version": "0.8.0",
4
4
  "description": "Opentelemetry standard instrumentation SDK for NodeJS based project",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
@@ -25,7 +25,7 @@
25
25
  "@grpc/grpc-js": "1.14.3",
26
26
  "@opentelemetry/api": "1.9.0",
27
27
  "@opentelemetry/api-logs": "0.208.0",
28
- "@opentelemetry/auto-instrumentations-node": "0.67.2",
28
+ "@opentelemetry/auto-instrumentations-node": "0.67.3",
29
29
  "@opentelemetry/core": "2.2.0",
30
30
  "@opentelemetry/exporter-logs-otlp-grpc": "0.208.0",
31
31
  "@opentelemetry/exporter-logs-otlp-http": "0.208.0",
@@ -42,11 +42,11 @@
42
42
  "@opentelemetry/sdk-trace-base": "2.2.0"
43
43
  },
44
44
  "devDependencies": {
45
- "@types/node": "25.0.2",
46
- "@vitest/coverage-v8": "4.0.15",
45
+ "@types/node": "25.0.3",
46
+ "@vitest/coverage-v8": "4.0.16",
47
47
  "tsx": "4.21.0",
48
48
  "typescript": "5.9.3",
49
- "vitest": "4.0.15"
49
+ "vitest": "4.0.16"
50
50
  },
51
51
  "engines": {
52
52
  "node": ">=20.6.0"