Skip to content

Commit 277e753

Browse files
Potential fix for code scanning alert no. 9: Information exposure through an error message
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
1 parent 2a96e8f commit 277e753

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/main/java/net/dirtydeeds/discordsoundboard/controllers/SoundController.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,16 @@
3636
import java.util.concurrent.ScheduledExecutorService;
3737
import java.util.concurrent.TimeUnit;
3838
import java.util.stream.Collectors;
39-
39+
import org.slf4j.Logger;
40+
import org.slf4j.LoggerFactory;
4041
/**
4142
* REST Controller.
4243
*
4344
* @author dfurrer.
4445
*/
4546
@Hidden
47+
48+
private static final Logger log = LoggerFactory.getLogger(SoundController.class);
4649
@RestController
4750
@RequestMapping("/api/soundFiles")
4851
@SuppressWarnings("unused")
@@ -254,14 +257,15 @@ public ResponseEntity<String> uploadFile(
254257
file.transferTo(new File(filePath));
255258

256259
soundService.save(new SoundFile(originalFilename, filePath, "", 0, ZonedDateTime.now(), false, null, 0));
260+
log.error("Failed to upload file", e);
257261

258262
broadcastUpdate();
259263

260264
return ResponseEntity.ok("File uploaded successfully: " + originalFilename);
261265

262266
} catch (Exception e) {
263267
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
264-
.body("Failed to upload file: " + e.getMessage());
268+
.body("Failed to upload file due to a server error.");
265269
}
266270
}
267271

0 commit comments

Comments
 (0)