Skip to content

Conversation

@galligan
Copy link
Contributor

Exports DEFAULT_PATTERNS constant with regex patterns for common
secrets: Bearer tokens, API keys, GitHub PATs (ghp/gho/ghs/ghr),
and private keys. Used with createRedactor for safe logging.

Closes #49

Co-Authored-By: Claude Opus 4.5 noreply@anthropic.com

Copy link
Contributor Author

galligan commented Jan 23, 2026

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

@greptile-apps
Copy link

greptile-apps bot commented Jan 23, 2026

Greptile Summary

  • Adds DEFAULT_PATTERNS export with regex patterns for common secrets (Bearer tokens, API keys, GitHub PATs, PEM private keys) to enhance automatic log redaction
  • Introduces child() method to LoggerInstance interface for more ergonomic creation of contextual loggers
  • Extends redaction to cover log messages in addition to existing metadata redaction, improving security coverage

Important Files Changed

Filename Overview
packages/logging/src/index.ts Major enhancement adding DEFAULT_PATTERNS export, child() method to logger interface, and message redaction capabilities
packages/logging/src/__tests__/redaction-patterns.test.ts New comprehensive test suite validating DEFAULT_PATTERNS redaction across all secret types and edge cases

Confidence score: 4/5

  • This PR is safe to merge with good security improvements and comprehensive test coverage
  • Score reflects well-tested functionality but complexity in redaction logic and interface changes that could affect existing consumers
  • Pay close attention to the logger interface changes in packages/logging/src/index.ts to ensure backward compatibility

Sequence Diagram

sequenceDiagram
    participant User
    participant LoggerInstance
    participant processMetadata
    participant applyPatterns
    participant DEFAULT_PATTERNS
    participant Sink
    participant Formatter
    
    User->>LoggerInstance: "info(message, metadata)"
    LoggerInstance->>LoggerInstance: "shouldLog(level, minLevel)"
    LoggerInstance->>processMetadata: "processMetadata(metadata, redactionConfig)"
    processMetadata->>processMetadata: "redactValue(value, keys, patterns, replacement)"
    processMetadata->>applyPatterns: "applyPatterns(value, patterns, replacement)"
    applyPatterns->>DEFAULT_PATTERNS: "pattern.replace(value, replacement)"
    DEFAULT_PATTERNS-->>applyPatterns: "redacted value"
    applyPatterns-->>processMetadata: "redacted value"
    processMetadata-->>LoggerInstance: "processed metadata"
    LoggerInstance->>applyPatterns: "applyPatterns(message, patterns, replacement)"
    applyPatterns->>DEFAULT_PATTERNS: "pattern.replace(message, replacement)"
    DEFAULT_PATTERNS-->>applyPatterns: "redacted message"
    applyPatterns-->>LoggerInstance: "redacted message"
    LoggerInstance->>LoggerInstance: "create LogRecord"
    LoggerInstance->>Sink: "write(record, formatted)"
    Sink->>Formatter: "format(record)"
    Formatter-->>Sink: "formatted string"
    Sink->>Sink: "output to destination"
Loading

@galligan galligan changed the base branch from p3-10/ui/format-relative to graphite-base/73 January 23, 2026 21:25
@galligan galligan force-pushed the p3-11/logging/default-patterns branch from c187efe to 3df0449 Compare January 23, 2026 21:27
@galligan galligan changed the base branch from graphite-base/73 to p3-10/ui/format-relative January 23, 2026 21:27
@galligan galligan changed the base branch from p3-10/ui/format-relative to graphite-base/73 January 23, 2026 23:08
@galligan galligan force-pushed the p3-11/logging/default-patterns branch from 3df0449 to 8166f4f Compare January 23, 2026 23:09
@galligan galligan changed the base branch from graphite-base/73 to p3-10/ui/format-relative January 23, 2026 23:09
@galligan
Copy link
Contributor Author

Restacked after downstack update (formatRelative test stabilization); no additional changes in this PR.

Adds child() method to LoggerInstance that:
- Merges parent context with child bindings (child takes precedence)
- Returns new logger instance with combined context
- Preserves level, redaction, sinks from parent
- Supports nested children (composable)

Fixes P1 review feedback from PR #69

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@galligan galligan changed the base branch from p3-10/ui/format-relative to graphite-base/73 January 24, 2026 02:43
@galligan galligan force-pushed the p3-11/logging/default-patterns branch from 8166f4f to bf9ec8e Compare January 24, 2026 02:44
@galligan galligan changed the base branch from graphite-base/73 to p3-10/ui/format-relative January 24, 2026 02:44
@galligan
Copy link
Contributor Author

Resubmitted after restack. This PR includes Logger.child in logging, which resolves the contracts compatibility note from PR #69.

@galligan galligan changed the base branch from p3-10/ui/format-relative to graphite-base/73 January 24, 2026 03:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants