Skip to content

Comments

feat: field redaction#57

Merged
cmilesdev merged 3 commits intomainfrom
cmilesdev/feat-field-redaction
Dec 24, 2025
Merged

feat: field redaction#57
cmilesdev merged 3 commits intomainfrom
cmilesdev/feat-field-redaction

Conversation

@cmilesdev
Copy link
Member

@cmilesdev cmilesdev commented Dec 20, 2025

Changes

  • Added configurable field include/exclude filters and redaction options with match modes (exact/contains/prefix/suffix).
  • Implemented default sensitive-field redaction list via WithRedactSensitive.
  • Applied filtering/redaction in struct rendering and added comprehensive tests for matching and redaction behaviors.

New Options

  • WithExcludeFields to omit selected fields.
  • WithFieldMatchMode to control include/exclude matching (exact/contains/prefix/suffix).
  • WithRedactFields to replace matching fields with .
  • WithRedactSensitive to enable a built‑in sensitive‑field list with substring matching.
  • WithRedactMatchMode to control redaction matching (exact/contains/prefix/suffix).

This feature is opt‑in by default.

Reasons:

  • It would be a breaking/behavior‑changing default for existing users who expect full dumps.
  • Default redaction inevitably misses some sensitive fields and may wrongly redact benign fields; users should consciously choose it.
  • People use dumps for debugging/forensics; silent redaction can make issues harder to track.

Related issue / request #48

Example

func main() {
	// WithRedactSensitive enables default redaction for common sensitive fields.

	// Example: redact common sensitive fields
	// Default: disabled
	type User struct {
		Password string
		Token    string
	}
	d := godump.NewDumper(
		godump.WithRedactSensitive(),
	)
	d.Dump(User{Password: "secret", Token: "abc"})
	// #godump.User {
	//   +Password => <redacted> #string
	//   +Token    => <redacted> #string
	// }
}

@cmilesdev cmilesdev mentioned this pull request Dec 20, 2025
@codecov
Copy link

codecov bot commented Dec 20, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@Akkadius Akkadius force-pushed the cmilesdev/feat-field-redaction branch from 85d71b8 to 97d15ad Compare December 24, 2025 00:13
@cmilesdev cmilesdev merged commit 0f7a3fa into main Dec 24, 2025
7 checks passed
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