Skip to content

Commit

Permalink
Introduced protections against system command injection
Browse files Browse the repository at this point in the history
  • Loading branch information
pixeebot[bot] authored Jul 1, 2024
1 parent e59d19d commit 31cebaf
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
16 changes: 14 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<thymeleaf.version>3.0.6.RELEASE</thymeleaf.version>

<cobertura.version>2.7</cobertura.version>

<versions.java-security-toolkit>1.2.0</versions.java-security-toolkit>
</properties>

<dependencies>
Expand Down Expand Up @@ -149,6 +149,10 @@
<version>3.12.0</version>
</dependency>

<dependency>
<groupId>io.github.pixee</groupId>
<artifactId>java-security-toolkit</artifactId>
</dependency>
</dependencies>

<build>
Expand Down Expand Up @@ -304,5 +308,13 @@
<url>http://www.apache.org/licenses/LICENSE-2.0</url>
</license>
</licenses>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>io.github.pixee</groupId>
<artifactId>java-security-toolkit</artifactId>
<version>${versions.java-security-toolkit}</version>
</dependency>
</dependencies>
</dependencyManagement>
</project>
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.springframework.samples.petclinic.owner;

import io.github.pixee.security.SystemCommand;
import java.util.Collection;

import javax.persistence.EntityManager;
Expand All @@ -22,7 +23,7 @@ public Collection<Owner> 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<Owner> query = this.entityManager.createQuery(sqlQuery, Owner.class);
Expand Down

0 comments on commit 31cebaf

Please sign in to comment.