-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
aab761c
commit f0519ed
Showing
1 changed file
with
26 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# demo-1 | ||
|
||
Sample Project to show that Spring Framework FieldError logs sensitive data. | ||
|
||
## Usage | ||
|
||
1. Start the project as spring boot application | ||
1. Run the following command to send some data that fails validation | ||
|
||
``` | ||
curl --request POST \ | ||
--url http://localhost:8080/payment-cards \ | ||
--header 'Content-Type: application/json' \ | ||
--data '{ | ||
"id": "4", | ||
"accountNumber": "4444333322221112", | ||
"expirationDate": "2022-12", | ||
"accountHolder": "Jimmy-2 Doe", | ||
}' | ||
``` | ||
1. Check log file of spring boot application. It will contain the following log event: | ||
``` | ||
2022-08-11 19:35:56.283 WARN 1 --- [nio-8080-exec-2] .w.s.m.s.DefaultHandlerExceptionResolver : Resolved [org.springframework.web.bind.MethodArgumentNotValidException: Validation failed for argument [0] in public com.example.demo.domain.PaymentCard com.example.demo.api.CardController.saveCard(com.example.demo.domain.PaymentCard): [Field error in object 'paymentCard' on field 'accountNumber': rejected value [4444333322221112]; codes [CreditCardNumber.paymentCard.accountNumber,CreditCardNumber.accountNumber,CreditCardNumber.java.lang.String,CreditCardNumber]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [paymentCard.accountNumber,accountNumber]; arguments []; default message [accountNumber],false]; default message [invalid credit card number]] ] | ||
``` |