Skip to content

Commit

Permalink
FDP-2766: Kept PSK out of the debug logging
Browse files Browse the repository at this point in the history
Signed-off-by: Sander Verbruggen <[email protected]>
  • Loading branch information
sanderv committed Nov 8, 2024
1 parent 84a2298 commit 738dbd4
Showing 1 changed file with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package org.gxf.crestdeviceservice.controller

import com.fasterxml.jackson.databind.JsonNode
import io.github.oshai.kotlinlogging.KotlinLogging
import org.gxf.crestdeviceservice.command.entity.Command
import org.gxf.crestdeviceservice.service.DeviceMessageService
import org.springframework.http.ResponseEntity
import org.springframework.lang.NonNull
Expand All @@ -29,7 +30,7 @@ class MessageController(private val deviceMessageService: DeviceMessageService)

return try {
val downlink = deviceMessageService.processDeviceMessage(body, identity)
logger.debug { "Sending downlink '$downlink' to device $identity" }
logDownlink(downlink, identity)
ResponseEntity.ok(downlink)
} catch (e: Exception) {
logger.error(e) {
Expand All @@ -40,4 +41,15 @@ class MessageController(private val deviceMessageService: DeviceMessageService)
logger.debug { "Processed message" }
}
}

private fun logDownlink(downlink: String, identity: String) {
logger.debug {
if (downlink.contains(Command.CommandType.PSK.name)) {
// This covers both PSK and PSK:SET, don't log the actual PSK
"Sending downlink with PSK to device $identity"
} else {
"Sending downlink '$downlink' to device $identity"
}
}
}
}

0 comments on commit 738dbd4

Please sign in to comment.