This is an automated email from the ASF dual-hosted git repository. gnodet pushed a commit to branch fix-sonarcloud-critical-vulnerabilities-6x-s5443 in repository https://gitbox.apache.org/repos/asf/camel.git
commit 95dc6ceb4e03cca17fc3e7415b6d0aed3d7a1586 Author: Guillaume Nodet <[email protected]> AuthorDate: Thu Jul 23 16:54:20 2026 +0200 chore(sonarcloud): fix S5443 publicly writable directory usage in camel-console Replace direct Files.createTempFile() in JfrMemoryLeakDevConsole with a two-step approach: create a secure temp directory first via Files.createTempDirectory(), then create the JFR dump file inside it. Both are cleaned up in the finally block. Co-Authored-By: Claude Opus 4.6 <[email protected]> --- .../apache/camel/impl/console/JfrMemoryLeakDevConsole.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/core/camel-console/src/main/java/org/apache/camel/impl/console/JfrMemoryLeakDevConsole.java b/core/camel-console/src/main/java/org/apache/camel/impl/console/JfrMemoryLeakDevConsole.java index bc7ac400ef58..705b375790de 100644 --- a/core/camel-console/src/main/java/org/apache/camel/impl/console/JfrMemoryLeakDevConsole.java +++ b/core/camel-console/src/main/java/org/apache/camel/impl/console/JfrMemoryLeakDevConsole.java @@ -215,9 +215,11 @@ public class JfrMemoryLeakDevConsole extends AbstractDevConsole { return cachedResults != null ? cachedResults : errorJson("No active recording."); } + Path tempDir = null; Path tempFile = null; try { - tempFile = Files.createTempFile("camel-jfr-memory-leak-", ".jfr"); + tempDir = Files.createTempDirectory("camel-jfr-"); + tempFile = Files.createTempFile(tempDir, "camel-jfr-memory-leak-", ".jfr"); // trigger GC before stopping to flush objects into the recording System.gc(); try { @@ -259,6 +261,13 @@ public class JfrMemoryLeakDevConsole extends AbstractDevConsole { // ignore } } + if (tempDir != null) { + try { + Files.deleteIfExists(tempDir); + } catch (IOException e) { + // ignore + } + } } }
