Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduced protections against system command injection #18

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This library holds security tools for protecting Java API calls.

License: MIT ✅ | Open source ✅ | More facts

<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
Loading