Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: code scanning alert no. 174: Log Injection #352

Merged
merged 12 commits into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import com.lyra.common.domain.Service
import com.lyra.common.domain.bus.event.EventBroadcaster
import com.lyra.common.domain.bus.event.EventPublisher
import com.lyra.common.domain.error.BusinessRuleValidationException
import org.apache.commons.text.StringEscapeUtils
import org.slf4j.LoggerFactory

@Service
Expand All @@ -24,7 +25,10 @@ class UserRegistrator(
}

suspend fun registerNewUser(registerUserCommand: RegisterUserCommand): ApiDataResponse<UserResponse> {
log.info("Registering new user with email: {}", registerUserCommand.email)
log.info(
"Registering new user with email: {}",
StringEscapeUtils.escapeJava(registerUserCommand.email),
)
return try {
val user = registerUserCommand.toUser()
val createdUser = userCreator.create(user)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import com.lyra.app.users.infrastructure.http.request.RegisterUserRequest
import io.swagger.v3.oas.annotations.Operation
import io.swagger.v3.oas.annotations.responses.ApiResponse
import io.swagger.v3.oas.annotations.responses.ApiResponses
import org.apache.commons.text.StringEscapeUtils
import org.slf4j.LoggerFactory
import org.springframework.http.HttpStatus
import org.springframework.http.ResponseEntity
Expand All @@ -30,7 +31,7 @@ class UserRegisterController(private val userRegistrator: UserRegistrator) {
@PostMapping("/register")
suspend fun registerUser(@Validated @RequestBody registerUserRequest: RegisterUserRequest):
ResponseEntity<ApiDataResponse<UserResponse>> {
log.info("Registering new user with email: {}", registerUserRequest.email)
log.info("Registering new user with email: {}", StringEscapeUtils.escapeJava(registerUserRequest.email))
return try {
val response = userRegistrator.registerNewUser(registerUserRequest.toRegisterUserCommand())
mapRegistrationResult(response)
Expand Down
Loading