Skip to content

refactor(security): centralize config obfuscation rules in ObfuscationUtil (#36923) - #36924

Open
wezell wants to merge 3 commits into
mainfrom
issue-36923-centralize-obfuscation
Open

refactor(security): centralize config obfuscation rules in ObfuscationUtil (#36923)#36924
wezell wants to merge 3 commits into
mainfrom
issue-36923-centralize-obfuscation

Conversation

@wezell

@wezell wezell commented Aug 6, 2026

Copy link
Copy Markdown
Member

Proposed Changes

Extracts the sensitive-config masking rules into a single authoritative home, com.dotcms.util.ObfuscationUtil:

  • DEFAULT_OBFUSCATE_PATTERN (passw|pass|passwd|secret|key|token), the always-on BASE_PATTERN, and the config-driven CUSTOM_PATTERN (OBFUSCATE_SYSTEM_ENVIRONMENTAL_VARIABLES)
  • shouldObfuscate(), matchesCustomPattern(), obfuscateIfNeeded(), obfuscate()

Consumers updated:

  • JVMInfoResource — uses the utility; its previously-public statics (obfuscateBasePattern, obfuscatePattern, obfuscateIfNeeded) remain as thin @Deprecated delegates since plugins may reference them
  • SystemTableImpl.set() — security logging no longer depends on a REST class
  • ConfigurationResource.isOnBlackList() — uses matchesCustomPattern() (identical semantics to its previous direct pattern read)

No behavior change anywhere — same patterns, same a*********z masking format.

Stacked on #36920 (config-overrides obfuscation fix — same file); merge that first and this diff shrinks to the refactor only.

Checklist

  • Tests (ConfigurationResourceTest updated comment; behavior unchanged, existing coverage applies)
  • Translations (n/a)
  • Security Implications Contemplated (refactor of security masking; no rule changes)

🤖 Generated with Claude Code

This PR fixes: #36923

wezell and others added 2 commits August 6, 2026 12:55
…#36919)

getDBOverrides() copied SystemTable.all() into the /api/v1/jvm response
unmasked, while the system-properties and environment sections already run
values through obfuscateIfNeeded(). Apply the same pattern-based masking
(passw|pass|passwd|secret|key|token + OBFUSCATE_SYSTEM_ENVIRONMENTAL_VARIABLES)
to config overrides shown in the maintenance portlet.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…nUtil (#36923)

The masking pattern lived as statics on JVMInfoResource (a JAX-RS resource)
and was reached into by SystemTableImpl (business layer) and
ConfigurationResource. Move the default pattern, the
OBFUSCATE_SYSTEM_ENVIRONMENTAL_VARIABLES custom pattern, and the masking
helpers into com.dotcms.util.ObfuscationUtil. JVMInfoResource keeps its
public members as @deprecated delegates for plugin back-compat; in-repo
callers now use the utility. No behavior change.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@claude

claude Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Claude finished @wezell's task in 1m 8s —— View job


Review: centralize config obfuscation in ObfuscationUtil

  • Read the diff (git diff origin/main...HEAD)
  • Reviewed ObfuscationUtil, JVMInfoResource, SystemTableImpl, ConfigurationResource, and the test change
  • Checked for behavior changes, null-safety, and dotCMS conventions

This is a clean extraction. The new ObfuscationUtil preserves the exact patterns (passw|pass|passwd|secret|key|token), the OBFUSCATE_SYSTEM_ENVIRONMENTAL_VARIABLES override, and the a*********z masking format. Consumers delegate correctly, and the deprecated statics in JVMInfoResource keep plugin compatibility.

Verified points:

  • ConfigurationResource.isOnBlackList() — the old code null-checked JVMInfoResource.obfuscatePattern; matchesCustomPattern() drops the check, but Pattern.compile(...) never returns null, so semantics are identical. ✅
  • SystemTableImpl no longer imports a REST class for security logging — good layering improvement. ✅
  • Static-init ordering: obfuscateBasePattern = ObfuscationUtil.BASE_PATTERN triggers ObfuscationUtil class load, which reads Config — the test's mock-before-construct comment (updated correctly) still applies. ✅

New Issues

  • 🟡 Medium: dotCMS/src/main/java/com/dotcms/util/ObfuscationUtil.java:62obfuscateIfNeeded does an unchecked (String) valueObject cast. All current callers pass String values (systemTable.all() is Map<String,String>, props.getProperty, env.get), so it's safe today. But the parameter is typed Object, inviting a non-String caller that would throw ClassCastException instead of masking. This matches the pre-existing behavior moved out of JVMInfoResource, so it's not a regression — worth hardening to String.valueOf(valueObject) while it's being centralized. Fix this →

Notes (non-blocking)

Nothing here blocks merge. The refactor is sound and improves layering.

· branch issue-36923-centralize-obfuscation

@github-actions github-actions Bot added the Area : Backend PR changes Java/Maven backend code label Aug 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area : Backend PR changes Java/Maven backend code

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

Centralize sensitive-config obfuscation pattern into a shared utility

1 participant