Skip to content

refactor(logger): extend sanitize() type coverage and fix type safety issues#8232

Closed
Copilot wants to merge 2 commits intoWP-8110from
copilot/sub-pr-8231
Closed

refactor(logger): extend sanitize() type coverage and fix type safety issues#8232
Copilot wants to merge 2 commits intoWP-8110from
copilot/sub-pr-8231

Conversation

Copy link

Copilot AI commented Mar 3, 2026

The sanitize() function lacked proper handling for several JavaScript built-in types and had type safety issues that caused linting errors.

Changes

Type Safety

  • Fixed WeakSet typing from object to Record<string, unknown> to eliminate eslint ban-types error
  • Corrected regex pattern to use explicit case sensitivity [a-fA-F0-9] instead of case-insensitive flag
  • Moved Date handling before circular reference tracking (Dates convert to strings, don't need tracking)

Extended Type Support

  • Map: Sanitizes values and detects sensitive keys
  • Set: Sanitizes contained values including v2 tokens
  • RegExp: Converts to string representation
  • Buffer: Returns <Buffer> placeholder
  • TypedArray: Returns <TypedArray> placeholder for Uint8Array, Int32Array, etc.

Test Coverage

Added 12 test cases covering new types and edge cases (60 total tests passing).

Example

sanitize({
  config: new Map([['token', 'secret'], ['host', 'localhost']]),
  tags: new Set(['public', 'v2xaabbccdd112233445566778899aabbccddeeff']),
  pattern: /test/gi,
  data: new Uint8Array([1, 2, 3])
})

// Returns:
// {
//   config: Map { 'token' => '<REMOVED>', 'host' => 'localhost' },
//   tags: Set { 'public', '<REMOVED>' },
//   pattern: '/test/gi',
//   data: '<TypedArray>'
// }

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

…Buffer, TypedArray support and enhanced type safety

Co-authored-by: rishikeshdadam136 <253073217+rishikeshdadam136@users.noreply.github.com>
Copy link
Author

Copilot AI commented Mar 3, 2026

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • download.cypress.io
    • Triggering command: /opt/hostedtoolcache/node/24.13.1/x64/bin/node /opt/hostedtoolcache/node/24.13.1/x64/bin/node index.js --exec install (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI changed the title [WIP] Fix sanitize function to handle Date, BigInt, and string types refactor(logger): extend sanitize() type coverage and fix type safety issues Mar 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants