Add tests for StandardSystemProperty

This commit is contained in:
Jonathan Leitschuh
2022-03-15 12:37:42 -04:00
parent 451661dd20
commit 09cc8ee09e
5 changed files with 166 additions and 15 deletions

View File

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