Skip to content

fix(sanitize): pseudonymize authserver LDAP values - #529

Merged
mergify[bot] merged 4 commits into
EvilBit-Labs:mainfrom
infowolfe:528_ldap_sanitize
Apr 3, 2026
Merged

fix(sanitize): pseudonymize authserver LDAP values#529
mergify[bot] merged 4 commits into
EvilBit-Labs:mainfrom
infowolfe:528_ldap_sanitize

Conversation

@infowolfe

Copy link
Copy Markdown
Contributor

Pull Request

Description

Fixes authserver LDAP sanitization so the listed system/authserver values are pseudonymized consistently in all sanitize modes, restores ldap_bindpw credential classification, and aligns tests/docs/CLI text with the actual behavior.

AI assistance: used Codex for implementation support. I reviewed and edited the final change and can explain the resulting code and tests.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update (changes to documentation only)
  • Refactoring (no functional changes, code improvements)
  • Performance improvement (improves performance without changing functionality)
  • Test addition/update (adding or updating tests)
  • Build/CI change (changes to build system or CI configuration)

Related Issues

Testing

Pre-submission Checklist

  • Code Quality: All code follows Go formatting standards (gofmt)
  • Linting: All linting issues resolved (golangci-lint)
  • Tests: Tests pass with >80% coverage (go test ./...)
  • Error Handling: Proper error handling with context implemented
  • Logging: Structured logging used where appropriate
  • Documentation: New functions and types documented following Go conventions
  • Dependencies: Dependencies properly managed (go mod tidy)
  • Security: No hardcoded secrets or credentials
  • Input Validation: Input validation implemented where needed

Test Commands Executed

just lint
just test
just check
just ci-check

Test Results

All commands passed locally.

Changes Made

Files Modified

  • internal/sanitizer/rules.go
  • internal/sanitizer/patterns.go
  • internal/sanitizer/mapper.go
  • internal/sanitizer/*_test.go
  • cmd/sanitize.go
  • cmd/sanitize_test.go
  • docs/user-guide/commands/sanitize.md

Key Changes

  • Added authserver-specific pseudonymization for the requested LDAP fields
  • Kept name and host scoped to system/authserver
  • Restored ldap_bindpw password classification while preserving authserver mapping precedence
  • Added rule, mapper, XML, and CLI test coverage
  • Aligned CLI/docs with the implemented all-modes behavior

Review Checklist

For Reviewers

  • Code Quality: Code follows project conventions and Go standards
  • Architecture: Changes align with project architecture patterns
  • Security: No security vulnerabilities introduced
  • Performance: No performance regressions
  • Documentation: Documentation updated if needed
  • Testing: Adequate test coverage provided
  • Breaking Changes: Breaking changes properly documented

For Contributors

  • Self Review: Code has been self-reviewed
  • Commit Messages: Follow conventional commit format
  • Branch Naming: Branch follows naming convention (feat/, fix/, docs/, etc.)
  • Scope: Changes are focused and not too broad
  • Dependencies: No unnecessary dependencies added

Documentation

Documentation Updates

  • README.md
  • CONTRIBUTING.md
  • docs/development/standards.md
  • docs/development/architecture.md
  • Project specification files

API Changes

None.

Breaking Changes

None.

Migration Guide

Not applicable.

Security Considerations

This change strengthens sanitization by pseudonymizing sensitive system/authserver LDAP values and preventing credential leakage for ldap_bindpw.

Performance Impact

No meaningful performance impact expected.

Acceptance Criteria

  • Authserver LDAP values are pseudonymized consistently in sanitize output
  • ldap_bindpw is treated as a credential and does not leak
  • Tests and docs reflect the implemented behavior

Additional Notes

Mapping output remains human-readable under mappings.authserver.<field>.

Labels

  • bug-fix
  • documentation
  • security

By submitting this pull request, I confirm that:

  • I have read and followed the Contributing Guide
  • I have read and followed the Development Standards
  • My code follows the project's coding standards
  • I have added tests that prove my fix is effective or that my feature works
  • I have updated the documentation accordingly
  • My changes generate no new warnings
  • I have checked my code and corrected any misspellings

AI assistance: used Codex for implementation support. I reviewed and edited the final change and can explain the resulting code and tests.

Signed-off-by: Parker <infowolfe@gmail.com>
@infowolfe
infowolfe requested a review from unclesp1d3r as a code owner April 2, 2026 19:20
@dosubot dosubot Bot added the size:XL This PR changes 500-999 lines, ignoring generated files. label Apr 2, 2026
@coderabbitai

coderabbitai Bot commented Apr 2, 2026

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Summary by CodeRabbit

  • New Features

    • Sanitize now redacts/pseudonymizes authentication-server LDAP fields (name, host, port, base DN, bind DN, bind password, extended query, sync groups) and includes authserver entries in mapping reports.
  • Documentation

    • User guide and command help updated to reflect expanded minimal-mode redaction and example authserver mapping structure.
  • Tests

    • Integration/unit tests expanded to cover LDAP/authserver redaction, bind-password detection, and deterministic pseudonym mappings.

Walkthrough

Adds LDAP authserver redaction and pseudonymization: new mapper support for per-field authserver mappings, a builtin authserver rule, extended password detection, CLI/docs updates, and expanded tests. No changes to non-authserver sanitization behavior or runtime control flow.

Changes

Cohort / File(s) Summary
CLI & Docs
cmd/sanitize.go, docs/user-guide/commands/sanitize.md
Help text and user guide updated to declare --mode=minimal also redacts/pseudonymizes system/authserver (LDAP) fields.
Command Tests
cmd/sanitize_test.go
Integration test extended with <authserver> LDAP input and assertions ensuring LDAP secrets/fields are redacted or pseudonymized in outputs.
Mapper Implementation
internal/sanitizer/mapper.go
Added MapAuthServerValue(field, original) with per-field counters/mappings, report support (AuthServerMappings), reset logic, and authserver replacement helpers/constants.
Mapper Tests
internal/sanitizer/mapper_test.go
Tests for deterministic/idempotent authserver mapping, unknown-field sentinel behavior, report generation, and JSON output inclusion.
Pattern Matching
internal/sanitizer/patterns.go, internal/sanitizer/patterns_test.go
Added bindpw to password keyword list so ldap_bindpw is treated as password-like; test updated accordingly.
Redaction Rules
internal/sanitizer/rules.go, internal/sanitizer/rules_test.go
New builtin authserver_config rule targeting system.authserver.* and ldap_* fields; added authServerFieldFromPath helper and tests covering authserver redaction across modes.
Sanitizer Tests
internal/sanitizer/sanitizer_test.go
New XML sanitization test verifying authserver sub-elements are removed verbatim and replaced/mapped/escaped as expected across modes.

Sequence Diagram(s)

(Skipped — changes are rule/map additions and tests without a new multi-component sequential runtime flow that warrants a diagram.)

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Suggested labels

type:bug, go, testing, documentation, priority:normal

Poem

🔐 In XML groves where secrets creep,
LDAP whispers no more keep,
Names and binds are softly spun,
authserver mapped — the work is done. ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 20.69% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The PR title 'fix(sanitize): pseudonymize authserver LDAP values' follows conventional commit format with a valid type (fix), scope (sanitize), and clear, descriptive subject.
Description check ✅ Passed The PR description is comprehensive, covering all major sections: type of change, related issues, testing pre-submission checklist, files modified, key changes, review checklist, documentation updates, security considerations, and acceptance criteria.
Linked Issues check ✅ Passed The PR implements all coding objectives from issue #528: ldap_* values are pseudonymized, ldap_bindpw is classified as a credential and sanitized in all modes, tests verify no leakage, and behavior is consistent across modes.
Out of Scope Changes check ✅ Passed All code changes are directly scoped to issue #528: authserver LDAP sanitization in rules, patterns, mapper logic, and corresponding test coverage; documentation and CLI updates align with implemented behavior.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@mergify

mergify Bot commented Apr 2, 2026

Copy link
Copy Markdown
Contributor

Merge Protections

Your pull request matches the following merge protections and will not be merged until they are valid.

🟢 Enforce conventional commit

Wonderful, this rule succeeded.

Require conventional commit format per https://www.conventionalcommits.org/en/v1.0.0/. Skipped for dependabot and dosubot.

  • title ~= ^(fix|feat|docs|style|refactor|perf|test|build|ci|chore|revert)(?:\(.+\))?!?:

🟢 Full CI must pass

Wonderful, this rule succeeded.

All CI checks must pass. Activates for non-bot authors, or dependabot when files exist outside .github/workflows/.

  • check-success = Build
  • check-success = Coverage
  • check-success = Integration Tests
  • check-success = Lint
  • check-success = Test (macos-latest)
  • check-success = Test (ubuntu-latest)
  • check-success = Test (windows-latest)

🟢 Do not merge outdated PRs

Wonderful, this rule succeeded.

Make sure PRs are within 10 commits of the base branch before merging

  • #commits-behind <= 10

@dosubot dosubot Bot added bug Something isn't working documentation Improvements or additions to documentation go Pull requests that update go code security Security-related features and issues testing Test infrastructure and test-related issues labels Apr 2, 2026
@coderabbitai coderabbitai Bot added type:bug Bug or defect that needs fixing priority:normal Normal priority issue labels Apr 2, 2026
coderabbitai[bot]
coderabbitai Bot previously approved these changes Apr 2, 2026
@unclesp1d3r unclesp1d3r self-assigned this Apr 2, 2026
@codecov

codecov Bot commented Apr 2, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.89474% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
internal/sanitizer/mapper.go 96.96% 1 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

@unclesp1d3r unclesp1d3r left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @infowolfe — thanks for this contribution, really nice work overall. The multi-layer test coverage is solid, the scoping logic for name/host is well thought out, and I appreciate the AI disclosure in the PR description. Two things I'd like addressed before merging:


  1. Fail-open guard in the Redactor (security maintenance hazard)

rules.go:268-274 — when authServerFieldFromPath returns "", the Redactor returns the original value unredacted:

if authServerField == "" {
    return value  // ← sensitive value passes through
}

Meanwhile, authServerReplacement (mapper.go:354) already has a safe fallback for unknown fields:

default:
    return fmt.Sprintf("[AUTHSERVER-%s-%03d]", field, seq)

…but it's unreachable because the empty-string guard catches first.

This means if someone later adds a field to FieldPatterns but forgets the corresponding case in authServerFieldFromPath, the value leaks silently with no
log or warning.

Ask: Could you have authServerFieldFromPath return the raw terminal segment for its default case (instead of "") and drop the empty-string guard in the
Redactor? That way, the existing authServerReplacement default handles it in a fail-closed manner. A unit test for the "" / default path would be great too.


  1. Stale mode descriptions

This PR makes authserver pseudonymization active in all modes, but three descriptions still say minimal is "passwords, keys" / "credentials only":

  • internal/sanitizer/rules.go:17 — // ModeMinimal redacts only the most sensitive data (passwords, keys).
  • cmd/sanitize.go:32 — same comment
  • cmd/sanitize.go:154 — CLI help: # Minimal redaction (credentials only)

Ask: Update these to reflect that minimal now also covers authserver values. Something like credentials and system/authserver values works.


Smaller suggestions (not blocking):

  • Doc comment on authServerFieldFromPath (rules.go:554) — this function has subtle scoping logic (ldap_* matches unconditionally, name/host requires authserver ancestor). A brief doc comment would save future contributors from breaking it.
  • Mapping file sensitivity note (docs/user-guide/commands/sanitize.md) — the mapping file now contains bind passwords as cleartext keys. A one-liner warning that the mapping file should be treated as sensitive as the original config would be helpful.
  • Aggressive mode docs gap (sanitize.md:58-70) — the aggressive section doesn't mention authserver pseudonymization. Since it explicitly lists what it covers, the omission could confuse users.

Thanks again, this is a meaningful security improvement. Happy to help if any of the above is unclear. Also, I'm happy to take care of the smaller items, if you'd like. I just provided those as feedback for community/learning purposes. They're minor.

@unclesp1d3r

Copy link
Copy Markdown
Member

@infowolfe My only feedback items are minor, and I want to get your fix into the release I'm preparing, so I'll just make the minor changes and merge it. Great wor,k and thank you so much for your contribution!

unclesp1d3r
unclesp1d3r previously approved these changes Apr 3, 2026

@unclesp1d3r unclesp1d3r left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved with minor edits for fail-open guard and stale mode description comments.

…iptions

Address PR review feedback: remove fail-open guard in authserver Redactor
so unknown fields flow through MapAuthServerValue's default handler instead
of leaking unredacted. Update ModeMinimal descriptions to reflect authserver
coverage.

Signed-off-by: UncleSp1d3r <unclesp1d3r@evilbitlabs.io>
@unclesp1d3r
unclesp1d3r dismissed stale reviews from coderabbitai[bot] and themself via 191b9df April 3, 2026 00:06
unclesp1d3r
unclesp1d3r previously approved these changes Apr 3, 2026
@coderabbitai coderabbitai Bot removed documentation Improvements or additions to documentation go Pull requests that update go code type:bug Bug or defect that needs fixing priority:normal Normal priority issue testing Test infrastructure and test-related issues labels Apr 3, 2026
…mapping

Signed-off-by: UncleSp1d3r <unclesp1d3r@evilbitlabs.io>
@unclesp1d3r

Copy link
Copy Markdown
Member

@Mergifyio queue

@mergify

mergify Bot commented Apr 3, 2026

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • 🟠 Waiting for queue conditions
  • ⏳ Enter queue
  • ⏳ Run checks
  • ⏳ Merge
Required conditions to enter a queue
  • -closed [📌 queue requirement]
  • -conflict [📌 queue requirement]
  • -draft [📌 queue requirement]
  • any of [📌 queue -> configuration change requirements]:
    • -mergify-configuration-changed
    • check-success = Configuration changed
  • any of [📌 queue requirement]:
    • check-success = Mergify Merge Protections
    • check-neutral = Mergify Merge Protections
    • check-skipped = Mergify Merge Protections
  • any of [🔀 queue conditions]:
    • all of [📌 queue conditions of queue rule default]:
      • all of [🛡 Merge Protections rule Do not merge outdated PRs]:
        • #commits-behind <= 10
      • all of [🛡 Merge Protections rule Enforce conventional commit]:
        • title ~= ^(fix|feat|docs|style|refactor|perf|test|build|ci|chore|revert)(?:\(.+\))?!?:
      • all of [🛡 Merge Protections rule Full CI must pass]:
        • check-success = Build
        • check-success = Coverage
        • check-success = Integration Tests
        • check-success = Lint
        • check-success = Test (macos-latest)
        • check-success = Test (ubuntu-latest)
        • check-success = Test (windows-latest)
      • any of [🛡 GitHub repository ruleset rule Main]:
        • check-success = Mergify Merge Protections
        • check-neutral = Mergify Merge Protections
        • check-skipped = Mergify Merge Protections
    • all of [📌 queue conditions of queue rule dependabot-workflows]:
      • -files ~= ^(?!\.github/workflows/)
      • author = dependabot[bot]
      • base = main
      • label != do-not-merge
      • all of [🛡 Merge Protections rule Do not merge outdated PRs]:
        • #commits-behind <= 10
      • all of [🛡 Merge Protections rule Enforce conventional commit]:
        • title ~= ^(fix|feat|docs|style|refactor|perf|test|build|ci|chore|revert)(?:\(.+\))?!?:
      • all of [🛡 Merge Protections rule Full CI must pass]:
        • check-success = Build
        • check-success = Coverage
        • check-success = Integration Tests
        • check-success = Lint
        • check-success = Test (macos-latest)
        • check-success = Test (ubuntu-latest)
        • check-success = Test (windows-latest)
      • any of [🛡 GitHub repository ruleset rule Main]:
        • check-success = Mergify Merge Protections
        • check-neutral = Mergify Merge Protections
        • check-skipped = Mergify Merge Protections
    • all of [📌 queue conditions of queue rule dependabot]:
      • author = dependabot[bot]
      • base = main
      • label != do-not-merge
      • all of [🛡 Merge Protections rule Do not merge outdated PRs]:
        • #commits-behind <= 10
      • all of [🛡 Merge Protections rule Enforce conventional commit]:
        • title ~= ^(fix|feat|docs|style|refactor|perf|test|build|ci|chore|revert)(?:\(.+\))?!?:
      • all of [🛡 Merge Protections rule Full CI must pass]:
        • check-success = Build
        • check-success = Coverage
        • check-success = Integration Tests
        • check-success = Lint
        • check-success = Test (macos-latest)
        • check-success = Test (ubuntu-latest)
        • check-success = Test (windows-latest)
      • any of [🛡 GitHub repository ruleset rule Main]:
        • check-success = Mergify Merge Protections
        • check-neutral = Mergify Merge Protections
        • check-skipped = Mergify Merge Protections
    • all of [📌 queue conditions of queue rule dosubot]:
      • author = dosubot[bot]
      • base = main
      • label != do-not-merge
      • all of [🛡 Merge Protections rule Do not merge outdated PRs]:
        • #commits-behind <= 10
      • all of [🛡 Merge Protections rule Enforce conventional commit]:
        • title ~= ^(fix|feat|docs|style|refactor|perf|test|build|ci|chore|revert)(?:\(.+\))?!?:
      • all of [🛡 Merge Protections rule Full CI must pass]:
        • check-success = Build
        • check-success = Coverage
        • check-success = Integration Tests
        • check-success = Lint
        • check-success = Test (macos-latest)
        • check-success = Test (ubuntu-latest)
        • check-success = Test (windows-latest)
      • any of [🛡 GitHub repository ruleset rule Main]:
        • check-success = Mergify Merge Protections
        • check-neutral = Mergify Merge Protections
        • check-skipped = Mergify Merge Protections

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Warning

CodeRabbit couldn't request changes on this pull request because it doesn't have sufficient GitHub permissions.

Please grant CodeRabbit Pull requests: Read and write permission and re-run the review.

👉 Steps to fix this

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@cmd/sanitize.go`:
- Around line 49-50: The help text for the "mode" flag on sanitizeCmd is
inconsistent: the initial description says "minimal (credentials + authserver
values)" but elsewhere the same mode is labeled "Credential-only"; update the
mode flag help/usage strings so both references match by changing the
"Credential-only" label to include authserver values (or alternatively, remove
"Credential-only" and use "minimal (credentials + authserver values)") wherever
the mode descriptions are set; check sanitizeCmd, the mode flag's help string
and any annotation set by setFlagAnnotation(sanitizeCmd.Flags(), "mode", ...)
and ensure all occurrences for the "minimal" enum are consistent.

In `@internal/sanitizer/rules.go`:
- Around line 250-270: The authserver_config rule currently includes
"ldap_bindpw" in its FieldPatterns so ShouldRedactField() matches it first
(CategorySystem) and prevents credential-scoped rules from seeing it; remove
"ldap_bindpw" from the FieldPatterns array in the authserver_config rule and add
a separate credential-scoped rule that matches "ldap_bindpw" (e.g., Name like
"ldap_bindpw_credential"), sets Category to the credentials/credential category,
uses the same Modes as other rules, and a Redactor that maps the value using
your credential-mapping helper (so credential classification and stats pick it
up) instead of Mapper.MapAuthServerValue/authServerFieldFromPath.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 56570a5f-1417-4a00-8e1e-2b456e109e64

📥 Commits

Reviewing files that changed from the base of the PR and between cc594c6 and 191b9df.

📒 Files selected for processing (2)
  • cmd/sanitize.go
  • internal/sanitizer/rules.go

Comment thread cmd/sanitize.go
Comment on lines +49 to 50
"Sanitization mode: aggressive (public sharing), moderate (internal sharing), minimal (credentials + authserver values)")
setFlagAnnotation(sanitizeCmd.Flags(), "mode", []string{"sanitize"})

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Minimal mode help text is now self-contradictory.

Line 49 correctly says minimal mode includes authserver values, but Line 129 still labels it as “Credential-only” redaction. opnDossier sanitize --help will show two different definitions for the same mode.

Suggested wording
-    minimal      - Credential-only redaction for trusted environments
+    minimal      - Minimal redaction for trusted environments
                    Redacts: passwords, secrets, API keys, PSKs, private keys, SSH keys,
                    authserver values

As per coding guidelines, "CLI command files: Focus on user experience, clear error messages, and proper flag handling" and "Confirm help text is clear and follows CLI conventions."

Also applies to: 126-131

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@cmd/sanitize.go` around lines 49 - 50, The help text for the "mode" flag on
sanitizeCmd is inconsistent: the initial description says "minimal (credentials
+ authserver values)" but elsewhere the same mode is labeled "Credential-only";
update the mode flag help/usage strings so both references match by changing the
"Credential-only" label to include authserver values (or alternatively, remove
"Credential-only" and use "minimal (credentials + authserver values)") wherever
the mode descriptions are set; check sanitizeCmd, the mode flag's help string
and any annotation set by setFlagAnnotation(sanitizeCmd.Flags(), "mode", ...)
and ensure all occurrences for the "minimal" enum are consistent.

Comment on lines +250 to +270
{
Name: "authserver_config",
Description: "Pseudonymizes sensitive system/authserver LDAP values",
Category: CategorySystem,
Modes: allModes,
FieldPatterns: []string{
"system.authserver.name",
"system.authserver.host",
"ldap_port",
"ldap_basedn",
"ldap_authcn",
"ldap_extended_query",
"ldap_attr_user",
"ldap_binddn",
"ldap_bindpw",
"ldap_sync_memberof_groups",
"ldap_sync_default_groups",
},
Redactor: func(m *Mapper, fieldName, value string) string {
return m.MapAuthServerValue(authServerFieldFromPath(fieldName), value)
},

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Split ldap_bindpw into a credential-scoped rule.

Because ShouldRedactField() stops at the first match, Line 264 means ldap_bindpw is always handled by authserver_config as CategorySystem; the later credential rules never see it. That keeps the replacement safe, but it still regresses credential classification for bind passwords and can skew any credential-specific stats or audit/report output.

Proposed split
+		{
+			Name:        "authserver_bindpw",
+			Description: "Pseudonymizes LDAP bind passwords as credentials",
+			Category:    CategoryCredentials,
+			Modes:       allModes,
+			FieldPatterns: []string{
+				"ldap_bindpw",
+			},
+			Redactor: func(m *Mapper, _, value string) string {
+				return m.MapAuthServerValue(authServerFieldLDAPBindPW, value)
+			},
+		},
 		{
 			Name:        "authserver_config",
 			Description: "Pseudonymizes sensitive system/authserver LDAP values",
 			Category:    CategorySystem,
 			Modes:       allModes,
 			FieldPatterns: []string{
 				"system.authserver.name",
 				"system.authserver.host",
 				"ldap_port",
 				"ldap_basedn",
 				"ldap_authcn",
 				"ldap_extended_query",
 				"ldap_attr_user",
 				"ldap_binddn",
-				"ldap_bindpw",
 				"ldap_sync_memberof_groups",
 				"ldap_sync_default_groups",
 			},
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@internal/sanitizer/rules.go` around lines 250 - 270, The authserver_config
rule currently includes "ldap_bindpw" in its FieldPatterns so
ShouldRedactField() matches it first (CategorySystem) and prevents
credential-scoped rules from seeing it; remove "ldap_bindpw" from the
FieldPatterns array in the authserver_config rule and add a separate
credential-scoped rule that matches "ldap_bindpw" (e.g., Name like
"ldap_bindpw_credential"), sets Category to the credentials/credential category,
uses the same Modes as other rules, and a Redactor that maps the value using
your credential-mapping helper (so credential classification and stats pick it
up) instead of Mapper.MapAuthServerValue/authServerFieldFromPath.

@mergify

mergify Bot commented Apr 3, 2026

Copy link
Copy Markdown
Contributor

Merge Queue Status

This pull request spent 5 minutes 18 seconds in the queue, including 5 minutes 5 seconds running CI.

Required conditions to merge
  • check-success = Build
  • check-success = Coverage
  • check-success = Integration Tests
  • check-success = Lint
  • check-success = Test (macos-latest)
  • check-success = Test (ubuntu-latest)
  • check-success = Test (windows-latest)
  • all of [🛡 Merge Protections rule Do not merge outdated PRs]:
  • all of [🛡 Merge Protections rule Enforce conventional commit]:
  • all of [🛡 Merge Protections rule Full CI must pass]:
    • check-success = Build
    • check-success = Coverage
    • check-success = Integration Tests
    • check-success = Lint
    • check-success = Test (macos-latest)
    • check-success = Test (ubuntu-latest)
    • check-success = Test (windows-latest)
  • any of [🛡 GitHub repository ruleset rule Main]:
    • check-neutral = Mergify Merge Protections
    • check-skipped = Mergify Merge Protections
    • check-success = Mergify Merge Protections

@mergify mergify Bot added the queued label Apr 3, 2026
mergify Bot added a commit that referenced this pull request Apr 3, 2026
@coderabbitai coderabbitai Bot added documentation Improvements or additions to documentation go Pull requests that update go code type:bug Bug or defect that needs fixing priority:normal Normal priority issue testing Test infrastructure and test-related issues labels Apr 3, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

♻️ Duplicate comments (1)
internal/sanitizer/rules.go (1)

250-265: ⚠️ Potential issue | 🟠 Major

Split ldap_bindpw into a credential-scoped rule to preserve classification

At Line 264, ldap_bindpw is still matched by authserver_config (CategorySystem). Because first match wins in ShouldRedactField, bind passwords won’t be classified as credentials, which regresses credential-specific audit/report classification.

Proposed fix
 	return []Rule{
+		{
+			Name:        "authserver_bindpw",
+			Description: "Pseudonymizes LDAP bind passwords as credentials",
+			Category:    CategoryCredentials,
+			Modes:       allModes,
+			FieldPatterns: []string{
+				"ldap_bindpw",
+			},
+			Redactor: func(m *Mapper, _, value string) string {
+				return m.MapAuthServerValue(authServerFieldLDAPBindPW, value)
+			},
+		},
 		{
 			Name:        "authserver_config",
 			Description: "Pseudonymizes sensitive system/authserver LDAP values",
 			Category:    CategorySystem,
 			Modes:       allModes,
 			FieldPatterns: []string{
 				"system.authserver.name",
 				"system.authserver.host",
 				"ldap_port",
 				"ldap_basedn",
 				"ldap_authcn",
 				"ldap_extended_query",
 				"ldap_attr_user",
 				"ldap_binddn",
-				"ldap_bindpw",
 				"ldap_sync_memberof_groups",
 				"ldap_sync_default_groups",
 			},
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@internal/sanitizer/rules.go` around lines 250 - 265, The authserver_config
rule currently includes "ldap_bindpw" so it matches first and prevents
credential classification in ShouldRedactField; remove "ldap_bindpw" from the
FieldPatterns of the authserver_config rule and add a separate rule (e.g., a new
rule named something like "ldap_bind_password" or a credentials-scoped rule)
with Category set to credentials and FieldPatterns containing "ldap_bindpw" so
that the credential-specific classification/audit logic applies; ensure the new
rule uses the same Modes/ordering expectations as other credential rules so it
is evaluated before general system rules.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In `@internal/sanitizer/rules.go`:
- Around line 250-265: The authserver_config rule currently includes
"ldap_bindpw" so it matches first and prevents credential classification in
ShouldRedactField; remove "ldap_bindpw" from the FieldPatterns of the
authserver_config rule and add a separate rule (e.g., a new rule named something
like "ldap_bind_password" or a credentials-scoped rule) with Category set to
credentials and FieldPatterns containing "ldap_bindpw" so that the
credential-specific classification/audit logic applies; ensure the new rule uses
the same Modes/ordering expectations as other credential rules so it is
evaluated before general system rules.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: d543ae77-8721-42de-beee-cb0f4efa7fae

📥 Commits

Reviewing files that changed from the base of the PR and between 191b9df and 0ecd3f4.

📒 Files selected for processing (2)
  • internal/sanitizer/mapper_test.go
  • internal/sanitizer/rules.go

@mergify
mergify Bot merged commit f9514d7 into EvilBit-Labs:main Apr 3, 2026
20 checks passed
@mergify mergify Bot removed the queued label Apr 3, 2026
@infowolfe

Copy link
Copy Markdown
Contributor Author

@infowolfe My only feedback items are minor, and I want to get your fix into the release I'm preparing, so I'll just make the minor changes and merge it. Great wor,k and thank you so much for your contribution!

Thanks a lot, sorry, I was falling down a hole of trying to get ceph authentication working so wasn't checking email. It probably would make sense to apply similar redaction/obfuscation to other areas of <authserver> as well, but this PR fixed my pain point.

Much appreciated

@infowolfe
infowolfe deleted the 528_ldap_sanitize branch April 3, 2026 13:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working documentation Improvements or additions to documentation go Pull requests that update go code priority:normal Normal priority issue security Security-related features and issues size:XL This PR changes 500-999 lines, ignoring generated files. testing Test infrastructure and test-related issues type:bug Bug or defect that needs fixing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

sensitive data leak. ldap_* is not sanitized

2 participants