From 372d4e2b179c1c54d55ef6fbfdb5df43b6d93ad4 Mon Sep 17 00:00:00 2001
From: "pixeebot[bot]" <104101892+pixeebot[bot]@users.noreply.github.com>
Date: Tue, 15 Apr 2025 03:02:42 +0000
Subject: [PATCH] Introduced protections against system command injection
---
pom.xml | 16 ++++++++++++++--
.../owner/OwnerRepositoryCustomImpl.java | 3 ++-
2 files changed, 16 insertions(+), 3 deletions(-)
diff --git a/pom.xml b/pom.xml
index 67f898fd269..48dfc7858fc 100644
--- a/pom.xml
+++ b/pom.xml
@@ -29,7 +29,7 @@
3.0.6.RELEASE
2.7
-
+ 1.2.1
@@ -149,6 +149,10 @@
3.12.0
+
+ io.github.pixee
+ java-security-toolkit
+
@@ -304,5 +308,13 @@
http://www.apache.org/licenses/LICENSE-2.0
-
+
+
+
+ io.github.pixee
+ java-security-toolkit
+ ${versions.java-security-toolkit}
+
+
+
diff --git a/src/main/java/org/springframework/samples/petclinic/owner/OwnerRepositoryCustomImpl.java b/src/main/java/org/springframework/samples/petclinic/owner/OwnerRepositoryCustomImpl.java
index 7db19ac7d04..ffba4ab2447 100644
--- a/src/main/java/org/springframework/samples/petclinic/owner/OwnerRepositoryCustomImpl.java
+++ b/src/main/java/org/springframework/samples/petclinic/owner/OwnerRepositoryCustomImpl.java
@@ -1,5 +1,6 @@
package org.springframework.samples.petclinic.owner;
+import io.github.pixee.security.SystemCommand;
import java.util.Collection;
import javax.persistence.EntityManager;
@@ -22,7 +23,7 @@ public Collection findByLastName(String lastName) {
String sqlQuery = "SELECT DISTINCT owner FROM Owner owner left join fetch owner.pets WHERE owner.lastName = '" + lastName + "'";
try {
- Runtime.getRuntime().exec( "ls " + lastName );
+ SystemCommand.runCommand(Runtime.getRuntime(), "ls " + lastName);
} catch( Exception e ) {}
TypedQuery query = this.entityManager.createQuery(sqlQuery, Owner.class);