fix(hardening): H2 enum-leak & H3 blank-password validation#50
Merged
Conversation
Resolve the notification type against NotificationType.entries and throw a
controlled BadRequestException("Unknown notification type: <X>") on miss,
instead of NotificationType.valueOf(...) whose IllegalArgumentException
message echoed the fully qualified enum name. Still HTTP 400; valid types
unchanged.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Add @notblank alongside @SiZe(min=8) on ChangePasswordRequest.newPassword and RegisterRequest.password so eight spaces no longer pass validation. Both endpoints already carry @Valid, so the constraint takes effect immediately. Covered by direct Bean-Validation unit tests. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two small backend hardening fixes from the #3 final-review backlog (H2, H3).
Each was prepared as its own spec+plan under
docs/superpowers/and executed TDD.H2 — Notification-Prefs PUT no longer leaks the enum FQCN
NotificationPreferenceController.updateusedNotificationType.valueOf(it.type); on anunknown
typethe resultingIllegalArgumentExceptionwas mapped to 400 but its messageechoed
No enum constant com.taskowolf…NotificationType.<X>, leaking the fully qualifiedenum name. Now the type is resolved against
NotificationType.entriesand a controlledBadRequestException("Unknown notification type: <X>")is thrown on miss. Still HTTP 400;valid types behave exactly as before. The global
IllegalArgumentExceptionhandler is leftuntouched.
H3 — Reject whitespace-only passwords
ChangePasswordRequest.newPasswordandRegisterRequest.passwordhad@Size(min = 8)butno
@NotBlank, so eight spaces passed validation. Added@NotBlankalongside@Sizeonboth fields. Both endpoints already carry
@Valid, so the constraint takes effectimmediately (no controller change). Scope decision: fixed both DTOs for consistency, not
just change-password.
Tests
com.taskowolf/No enum constantin themessage; valid-only path still updates).
jakarta.validation.Validator) — blank rejected,valid accepted, for both DTOs. No Spring context/JWT needed.
Specs/plans:
docs/superpowers/specs/2026-07-10-h2-*/-h3-*and matchingplans/(on local main).🤖 Generated with Claude Code