Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
cd073a2
Java: Add Guard Classes for checking OS
JLLeitschuh Feb 14, 2022
39828fd
Apply OS guard checks to TempDirLocalInformationDisclosure
JLLeitschuh Feb 14, 2022
3cdfc00
Cleanup from review feedback
JLLeitschuh Feb 15, 2022
4951344
Update java/ql/lib/semmle/code/java/os/OSCheck.qll
JLLeitschuh Feb 23, 2022
9f5022e
Review fixup and add test for apache SystemUtils
JLLeitschuh Feb 23, 2022
fd63107
Update OS Check from Review Feedback
JLLeitschuh Mar 1, 2022
5913c9a
Refactor OS Guard Checks
JLLeitschuh Mar 1, 2022
dad9a02
Update TempDirInfoDisclosure with new OS Guards
JLLeitschuh Mar 1, 2022
82d3cd8
Improve system property lookup
JLLeitschuh Mar 2, 2022
3c53a05
Add OS Checks based upon separator or path separator
JLLeitschuh Mar 2, 2022
a7adbb7
Refactor more system property access logic
JLLeitschuh Mar 3, 2022
85de9f3
Fix naming of OSCheck method
JLLeitschuh Mar 3, 2022
fea5006
Fix duplicated comment
JLLeitschuh Mar 3, 2022
103c770
Apply suggestions from code review
JLLeitschuh Mar 3, 2022
31527a6
Refactor OS Checks & SystemProperty logic from review feedback
JLLeitschuh Mar 3, 2022
7ab193d
Add System.getProperties().getProperty support
JLLeitschuh Mar 4, 2022
5243fe3
Apply suggestions from code review
JLLeitschuh Mar 4, 2022
523ddb7
Cleanup after code review feedback
JLLeitschuh Mar 4, 2022
b282c7f
Apply suggestions from code review
JLLeitschuh Mar 7, 2022
5b651f2
Fix insufficient tests and add documentation
JLLeitschuh Mar 7, 2022
a21992a
Minor refactoring to improve tests and documentation
JLLeitschuh Mar 7, 2022
2a6c4e9
Add localFlowPlusInitializers
JLLeitschuh Mar 9, 2022
ecb8911
Apply suggestions from code review
JLLeitschuh Mar 10, 2022
1c98642
Remove SystemProperty from FlowSources
JLLeitschuh Mar 10, 2022
50ff2c2
Code cleanup from code review
JLLeitschuh Mar 11, 2022
451661d
Improve guard class names
smowton Mar 15, 2022
09cc8ee
Add tests for StandardSystemProperty
JLLeitschuh Mar 15, 2022
b11340c
Change note tense and detail level
smowton Mar 16, 2022
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
Prev Previous commit
Next Next commit
Add tests for StandardSystemProperty
  • Loading branch information
JLLeitschuh committed Mar 15, 2022
commit 09cc8ee09e05d5e7f1829ac577cec576a5ba1bbe
14 changes: 12 additions & 2 deletions java/ql/lib/semmle/code/java/environment/SystemProperty.qll
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,18 @@ private MethodAccess getSystemPropertyFromApacheFileUtils(string propertyName) {
private MethodAccess getSystemPropertyFromGuava(string propertyName) {
exists(EnumConstant ec |
ec.getDeclaringType().hasQualifiedName("com.google.common.base", "StandardSystemProperty") and
result.getQualifier() = ec.getAnAccess() and
result.getMethod().hasName("value")
// Example: `StandardSystemProperty.JAVA_IO_TMPDIR.value()`
(
localExprFlowPlusInitializers(ec.getAnAccess(), result.getQualifier()) and
result.getMethod().hasName("value")
)
or
// Example: `System.getProperty(StandardSystemProperty.JAVA_IO_TMPDIR.key())`
exists(MethodAccess keyMa |
localExprFlowPlusInitializers(ec.getAnAccess(), keyMa.getQualifier()) and
keyMa.getMethod().hasName("key") and
localExprFlowPlusInitializers(keyMa, result.(MethodAccessSystemGetProperty).getArgument(0))
)
|
ec.hasName("JAVA_VERSION") and propertyName = "java.version"
or
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import java.io.File;
import java.util.Properties;
import org.apache.commons.lang3.SystemUtils;
import com.google.common.base.StandardSystemProperty;

public class SystemPropertyAccess {
private static final Properties SYSTEM_PROPERTIES = System.getProperties();
Expand All @@ -20,6 +21,10 @@ void test() {
char separatorChar = File.separatorChar;
String pathSeparator = File.pathSeparator;
char pathSeparatorChar = File.pathSeparatorChar;
StandardSystemProperty.JAVA_VERSION.value();
StandardSystemProperty property = StandardSystemProperty.JAVA_VERSION;
property.value();
System.getProperty(StandardSystemProperty.JAVA_IO_TMPDIR.key());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,20 @@
| ../../stubs/apache-commons-lang3-3.7/org/apache/commons/lang3/SystemUtils.java:843:5:843:48 | USER_NAME | user.name |
| ../../stubs/apache-commons-lang3-3.7/org/apache/commons/lang3/SystemUtils.java:861:5:861:52 | USER_TIMEZONE | user.timezone |
| ../../stubs/apache-commons-lang3-3.7/org/apache/commons/lang3/SystemUtils.java:1762:47:1762:63 | JAVA_AWT_HEADLESS | java.awt.headless |
| SystemPropertyAccess.java:9:9:9:37 | getProperty(...) | os.name |
| SystemPropertyAccess.java:10:9:10:48 | getProperty(...) | os.name |
| SystemPropertyAccess.java:11:9:11:53 | getProperty(...) | os.name |
| SystemPropertyAccess.java:12:9:12:52 | get(...) | java.io.tmpdir |
| SystemPropertyAccess.java:15:9:15:30 | lineSeparator(...) | line.separator |
| SystemPropertyAccess.java:16:29:16:51 | SystemUtils.AWT_TOOLKIT | awt.toolkit |
| SystemPropertyAccess.java:17:31:17:55 | SystemUtils.FILE_ENCODING | file.encoding |
| SystemPropertyAccess.java:18:25:18:50 | SystemUtils.JAVA_IO_TMPDIR | java.io.tmpdir |
| SystemPropertyAccess.java:19:28:19:41 | File.separator | file.separator |
| SystemPropertyAccess.java:20:30:20:47 | File.separatorChar | file.separator |
| SystemPropertyAccess.java:21:32:21:49 | File.pathSeparator | path.separator |
| SystemPropertyAccess.java:22:34:22:55 | File.pathSeparatorChar | path.separator |
| SystemPropertyAccess.java:10:9:10:37 | getProperty(...) | os.name |
| SystemPropertyAccess.java:11:9:11:48 | getProperty(...) | os.name |
| SystemPropertyAccess.java:12:9:12:53 | getProperty(...) | os.name |
| SystemPropertyAccess.java:13:9:13:52 | get(...) | java.io.tmpdir |
| SystemPropertyAccess.java:14:9:14:50 | getProperty(...) | java.home |
| SystemPropertyAccess.java:15:9:15:46 | get(...) | file.encoding |
| SystemPropertyAccess.java:16:9:16:30 | lineSeparator(...) | line.separator |
| SystemPropertyAccess.java:17:29:17:51 | SystemUtils.AWT_TOOLKIT | awt.toolkit |
| SystemPropertyAccess.java:18:31:18:55 | SystemUtils.FILE_ENCODING | file.encoding |
| SystemPropertyAccess.java:19:25:19:50 | SystemUtils.JAVA_IO_TMPDIR | java.io.tmpdir |
| SystemPropertyAccess.java:20:28:20:41 | File.separator | file.separator |
| SystemPropertyAccess.java:21:30:21:47 | File.separatorChar | file.separator |
| SystemPropertyAccess.java:22:32:22:49 | File.pathSeparator | path.separator |
| SystemPropertyAccess.java:23:34:23:55 | File.pathSeparatorChar | path.separator |
| SystemPropertyAccess.java:24:9:24:51 | value(...) | java.version |
| SystemPropertyAccess.java:26:9:26:24 | value(...) | java.version |
| SystemPropertyAccess.java:27:9:27:71 | getProperty(...) | java.io.tmpdir |
2 changes: 1 addition & 1 deletion java/ql/test/library-tests/environment/options
Original file line number Diff line number Diff line change
@@ -1 +1 @@
//semmle-extractor-options: --javac-args -cp ${testdir}/../../stubs/apache-commons-lang3-3.7/
//semmle-extractor-options: --javac-args -cp ${testdir}/../../stubs/apache-commons-lang3-3.7/:${testdir}/../../stubs/guava-30.0/

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.