42 lines
1.0 KiB
Plaintext
42 lines
1.0 KiB
Plaintext
include::../description.adoc[]
|
|
|
|
include::../ask-yourself.adoc[]
|
|
|
|
include::../recommended.adoc[]
|
|
|
|
== Sensitive Code Example
|
|
|
|
----
|
|
Runtime.getRuntime().exec("file.exe"); // Sensitive: an absolute path is used
|
|
|
|
ProcessBuilder pb = new ProcessBuilder("file.exe"); // Sensitive: an absolute path is used
|
|
pb.command("file.exe"; // Sensitive.
|
|
|
|
CommandLine cmdLine = CommandLine.parse("file.exe"); // Sensitive: an absolute path is used
|
|
DefaultExecutor executor = new DefaultExecutor();
|
|
executor.execute(cmdLine);
|
|
----
|
|
|
|
== Compliant Solution
|
|
|
|
----
|
|
Runtime.getRuntime().exec("/usr/bin/file.exe"); // Compliant
|
|
|
|
ProcessBuilder pb = new ProcessBuilder("/usr/bin/file.exe"); // Compliant
|
|
pb.command("/usr/bin/file.exe"; // Sensitive.
|
|
|
|
CommandLine cmdLine = CommandLine.parse("/usr/bin/file.exe"); // Compliant
|
|
DefaultExecutor executor = new DefaultExecutor();
|
|
executor.execute(cmdLine);
|
|
----
|
|
|
|
include::../see.adoc[]
|
|
|
|
ifdef::env-github,rspecator-view[]
|
|
'''
|
|
== Comments And Links
|
|
(visible only on this page)
|
|
|
|
include::comments-and-links.adoc[]
|
|
endif::env-github,rspecator-view[]
|