43 lines
883 B
Plaintext
43 lines
883 B
Plaintext
include::../description.adoc[]
|
|
|
|
== Noncompliant Code Example
|
|
|
|
----
|
|
import java.io.IOException;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
public void runUnsafe(HttpServletRequest request) throws IOException {
|
|
String folder = request.getParameter("folder");
|
|
|
|
String cmd = "mkdir " + folder;
|
|
|
|
Runtime.getRuntime().exec(cmd); // Noncompliant
|
|
}
|
|
----
|
|
|
|
== Compliant Solution
|
|
|
|
----
|
|
import java.io.IOException;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
public void runSafe(HttpServletRequest request) throws IOException {
|
|
String folderarg1 = request.getParameter("folder");
|
|
|
|
String cmd[] = new String[] { "mkdir", folderarg1 };
|
|
|
|
Runtime.getRuntime().exec(cmd); // Compliant
|
|
}
|
|
----
|
|
|
|
include::../see.adoc[]
|
|
ifdef::env-github,rspecator-view[]
|
|
|
|
'''
|
|
== Implementation Specification
|
|
(visible only on this page)
|
|
|
|
include::../message.adoc[]
|
|
|
|
endif::env-github,rspecator-view[]
|