mirror of
https://github.com/github/codeql.git
synced 2026-04-29 18:55:14 +02:00
Merge pull request #8032 from JLLeitschuh/feat/JLL/check_os
Java: Add Guard Classes for checking OS & unify System Property Access
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
|
||||
import Member
|
||||
import semmle.code.java.security.ExternalProcess
|
||||
private import semmle.code.java.dataflow.FlowSteps
|
||||
|
||||
// --- Standard types ---
|
||||
/** The class `java.lang.Object`. */
|
||||
@@ -37,6 +38,27 @@ class StringLengthMethod extends Method {
|
||||
StringLengthMethod() { this.hasName("length") and this.getDeclaringType() instanceof TypeString }
|
||||
}
|
||||
|
||||
/**
|
||||
* The methods on the class `java.lang.String` that are used to perform partial matches with a specified substring or char.
|
||||
*/
|
||||
class StringPartialMatchMethod extends Method {
|
||||
StringPartialMatchMethod() {
|
||||
this.hasName([
|
||||
"contains", "startsWith", "endsWith", "matches", "indexOf", "lastIndexOf", "regionMatches"
|
||||
]) and
|
||||
this.getDeclaringType() instanceof TypeString
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the index of the parameter that is being matched against.
|
||||
*/
|
||||
int getMatchParameterIndex() {
|
||||
if this.hasName("regionMatches")
|
||||
then this.getParameterType(result) instanceof TypeString
|
||||
else result = 0
|
||||
}
|
||||
}
|
||||
|
||||
/** The class `java.lang.StringBuffer`. */
|
||||
class TypeStringBuffer extends Class {
|
||||
TypeStringBuffer() { this.hasQualifiedName("java.lang", "StringBuffer") }
|
||||
@@ -228,11 +250,13 @@ class MethodSystemGetenv extends Method {
|
||||
/**
|
||||
* Any method named `getProperty` on class `java.lang.System`.
|
||||
*/
|
||||
class MethodSystemGetProperty extends Method {
|
||||
class MethodSystemGetProperty extends ValuePreservingMethod {
|
||||
MethodSystemGetProperty() {
|
||||
this.hasName("getProperty") and
|
||||
this.getDeclaringType() instanceof TypeSystem
|
||||
}
|
||||
|
||||
override predicate returnsValue(int arg) { arg = 1 }
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -244,6 +268,9 @@ class MethodAccessSystemGetProperty extends MethodAccess {
|
||||
/**
|
||||
* Holds if this call has a compile-time constant first argument with the value `propertyName`.
|
||||
* For example: `System.getProperty("user.dir")`.
|
||||
*
|
||||
* Note: Better to use `semmle.code.java.environment.SystemProperty#getSystemProperty` instead
|
||||
* as that predicate covers ways of accessing the same information via various libraries.
|
||||
*/
|
||||
predicate hasCompileTimeConstantGetPropertyName(string propertyName) {
|
||||
this.getArgument(0).(CompileTimeConstantExpr).getStringValue() = propertyName
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
import java
|
||||
import dataflow.DefUse
|
||||
private import semmle.code.java.environment.SystemProperty
|
||||
|
||||
/**
|
||||
* A library method that formats a number of its arguments according to a
|
||||
@@ -312,27 +313,7 @@ private predicate formatStringValue(Expr e, string fmtvalue) {
|
||||
or
|
||||
formatStringValue(e.(ChooseExpr).getAResultExpr(), fmtvalue)
|
||||
or
|
||||
exists(Method getprop, MethodAccess ma, string prop |
|
||||
e = ma and
|
||||
ma.getMethod() = getprop and
|
||||
getprop.hasName("getProperty") and
|
||||
getprop.getDeclaringType().hasQualifiedName("java.lang", "System") and
|
||||
getprop.getNumberOfParameters() = 1 and
|
||||
ma.getAnArgument().(StringLiteral).getValue() = prop and
|
||||
(prop = "line.separator" or prop = "file.separator" or prop = "path.separator") and
|
||||
fmtvalue = "x" // dummy value
|
||||
)
|
||||
or
|
||||
exists(Field f |
|
||||
e = f.getAnAccess() and
|
||||
f.getDeclaringType() instanceof TypeFile and
|
||||
fmtvalue = "x" // dummy value
|
||||
|
|
||||
f.hasName("pathSeparator") or
|
||||
f.hasName("pathSeparatorChar") or
|
||||
f.hasName("separator") or
|
||||
f.hasName("separatorChar")
|
||||
)
|
||||
e = getSystemProperty(["line.separator", "file.separator", "path.separator"]) and fmtvalue = "x" // dummy value
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -203,6 +203,7 @@ class EnvReadMethod extends Method {
|
||||
EnvReadMethod() {
|
||||
this instanceof MethodSystemGetenv or
|
||||
this instanceof PropertiesGetPropertyMethod or
|
||||
this instanceof PropertiesGetMethod or
|
||||
this instanceof MethodSystemGetProperty
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,11 +10,13 @@ private import semmle.code.java.dataflow.DataFlow
|
||||
* ensuring that they are visible to the taint tracking library.
|
||||
*/
|
||||
private module Frameworks {
|
||||
private import semmle.code.java.JDK
|
||||
private import semmle.code.java.frameworks.jackson.JacksonSerializability
|
||||
private import semmle.code.java.frameworks.android.AsyncTask
|
||||
private import semmle.code.java.frameworks.android.Intent
|
||||
private import semmle.code.java.frameworks.android.SQLite
|
||||
private import semmle.code.java.frameworks.Guice
|
||||
private import semmle.code.java.frameworks.Properties
|
||||
private import semmle.code.java.frameworks.Protobuf
|
||||
private import semmle.code.java.frameworks.guava.Guava
|
||||
private import semmle.code.java.frameworks.apache.Lang
|
||||
|
||||
286
java/ql/lib/semmle/code/java/environment/SystemProperty.qll
Normal file
286
java/ql/lib/semmle/code/java/environment/SystemProperty.qll
Normal file
@@ -0,0 +1,286 @@
|
||||
/**
|
||||
* Provides classes and predicates for working with java system properties.
|
||||
*/
|
||||
|
||||
import java
|
||||
private import semmle.code.java.dataflow.DataFlow
|
||||
private import semmle.code.java.frameworks.Properties
|
||||
private import semmle.code.java.frameworks.apache.Lang
|
||||
|
||||
/**
|
||||
* Gets an expression that retrieves the value of `propertyName` from `System.getProperty()`.
|
||||
*
|
||||
* Note: Expression type is not just `String`.
|
||||
*/
|
||||
Expr getSystemProperty(string propertyName) {
|
||||
result = getSystemPropertyFromSystem(propertyName) or
|
||||
result = getSystemPropertyFromSystemGetProperties(propertyName) or
|
||||
result = getSystemPropertyFromFile(propertyName) or
|
||||
result = getSystemPropertyFromApacheSystemUtils(propertyName) or
|
||||
result = getSystemPropertyFromApacheFileUtils(propertyName) or
|
||||
result = getSystemPropertyFromGuava(propertyName) or
|
||||
result = getSystemPropertyFromOperatingSystemMXBean(propertyName) or
|
||||
result = getSystemPropertyFromSpringProperties(propertyName)
|
||||
}
|
||||
|
||||
private MethodAccess getSystemPropertyFromSystem(string propertyName) {
|
||||
result.(MethodAccessSystemGetProperty).hasCompileTimeConstantGetPropertyName(propertyName)
|
||||
or
|
||||
result.getMethod().hasName("lineSeparator") and propertyName = "line.separator"
|
||||
}
|
||||
|
||||
/**
|
||||
* A method access that retrieves the value of `propertyName` from the following methods:
|
||||
* - `System.getProperties().getProperty(...)`
|
||||
* - `System.getProperties().get(...)`
|
||||
*/
|
||||
private MethodAccess getSystemPropertyFromSystemGetProperties(string propertyName) {
|
||||
exists(Method getMethod |
|
||||
getMethod instanceof PropertiesGetMethod
|
||||
or
|
||||
getMethod instanceof PropertiesGetPropertyMethod and
|
||||
result.getMethod() = getMethod
|
||||
) and
|
||||
result.getArgument(0).(CompileTimeConstantExpr).getStringValue() = propertyName and
|
||||
localExprFlowPlusInitializers(any(MethodAccess m |
|
||||
m.getMethod().getDeclaringType() instanceof TypeSystem and
|
||||
m.getMethod().hasName("getProperties")
|
||||
), result.getQualifier())
|
||||
}
|
||||
|
||||
private FieldAccess getSystemPropertyFromFile(string propertyName) {
|
||||
result.getField() instanceof FieldFileSeparator and propertyName = "file.separator"
|
||||
or
|
||||
result.getField() instanceof FieldFilePathSeparator and propertyName = "path.separator"
|
||||
}
|
||||
|
||||
/** The field `java.io.File.separator` or `java.io.File.separatorChar` */
|
||||
private class FieldFileSeparator extends Field {
|
||||
FieldFileSeparator() {
|
||||
this.getDeclaringType() instanceof TypeFile and this.hasName(["separator", "separatorChar"])
|
||||
}
|
||||
}
|
||||
|
||||
/* The field `java.io.File.pathSeparator` or `java.io.File.pathSeparatorChar` */
|
||||
private class FieldFilePathSeparator extends Field {
|
||||
FieldFilePathSeparator() {
|
||||
this.getDeclaringType() instanceof TypeFile and
|
||||
this.hasName(["pathSeparator", "pathSeparatorChar"])
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A field access to the system property.
|
||||
* See: https://commons.apache.org/proper/commons-lang/apidocs/org/apache/commons/lang3/SystemUtils.html
|
||||
*/
|
||||
private FieldAccess getSystemPropertyFromApacheSystemUtils(string propertyName) {
|
||||
exists(Field f | f = result.getField() and f.getDeclaringType() instanceof TypeApacheSystemUtils |
|
||||
f.hasName("AWT_TOOLKIT") and propertyName = "awt.toolkit"
|
||||
or
|
||||
f.hasName("FILE_ENCODING") and propertyName = "file.encoding"
|
||||
or
|
||||
f.hasName("FILE_SEPARATOR") and propertyName = "file.separator"
|
||||
or
|
||||
f.hasName("JAVA_AWT_FONTS") and propertyName = "java.awt.fonts"
|
||||
or
|
||||
f.hasName("JAVA_AWT_GRAPHICSENV") and propertyName = "java.awt.graphicsenv"
|
||||
or
|
||||
f.hasName("JAVA_AWT_HEADLESS") and propertyName = "java.awt.headless"
|
||||
or
|
||||
f.hasName("JAVA_AWT_PRINTERJOB") and propertyName = "java.awt.printerjob"
|
||||
or
|
||||
f.hasName("JAVA_CLASS_PATH") and propertyName = "java.class.path"
|
||||
or
|
||||
f.hasName("JAVA_CLASS_VERSION") and propertyName = "java.class.version"
|
||||
or
|
||||
f.hasName("JAVA_COMPILER") and propertyName = "java.compiler"
|
||||
or
|
||||
f.hasName("JAVA_EXT_DIRS") and propertyName = "java.ext.dirs"
|
||||
or
|
||||
f.hasName("JAVA_HOME") and propertyName = "java.home"
|
||||
or
|
||||
f.hasName("JAVA_IO_TMPDIR") and propertyName = "java.io.tmpdir"
|
||||
or
|
||||
f.hasName("JAVA_LIBRARY_PATH") and propertyName = "java.library.path"
|
||||
or
|
||||
f.hasName("JAVA_RUNTIME_NAME") and propertyName = "java.runtime.name"
|
||||
or
|
||||
f.hasName("JAVA_RUNTIME_VERSION") and propertyName = "java.runtime.version"
|
||||
or
|
||||
f.hasName("JAVA_SPECIFICATION_NAME") and propertyName = "java.specification.name"
|
||||
or
|
||||
f.hasName("JAVA_SPECIFICATION_VENDOR") and propertyName = "java.specification.vendor"
|
||||
or
|
||||
f.hasName("JAVA_UTIL_PREFS_PREFERENCES_FACTORY") and
|
||||
propertyName = "java.util.prefs.PreferencesFactory" // This really does break the lowercase convention obeyed everywhere else
|
||||
or
|
||||
f.hasName("JAVA_VENDOR") and propertyName = "java.vendor"
|
||||
or
|
||||
f.hasName("JAVA_VENDOR_URL") and propertyName = "java.vendor.url"
|
||||
or
|
||||
f.hasName("JAVA_VERSION") and propertyName = "java.version"
|
||||
or
|
||||
f.hasName("JAVA_VM_INFO") and propertyName = "java.vm.info"
|
||||
or
|
||||
f.hasName("JAVA_VM_NAME") and propertyName = "java.vm.name"
|
||||
or
|
||||
f.hasName("JAVA_VM_SPECIFICATION_NAME") and propertyName = "java.vm.specification.name"
|
||||
or
|
||||
f.hasName("JAVA_VM_SPECIFICATION_VENDOR") and propertyName = "java.vm.specification.vendor"
|
||||
or
|
||||
f.hasName("JAVA_VM_VENDOR") and propertyName = "java.vm.vendor"
|
||||
or
|
||||
f.hasName("JAVA_VM_VERSION") and propertyName = "java.vm.version"
|
||||
or
|
||||
f.hasName("LINE_SEPARATOR") and propertyName = "line.separator"
|
||||
or
|
||||
f.hasName("OS_ARCH") and propertyName = "os.arch"
|
||||
or
|
||||
f.hasName("OS_NAME") and propertyName = "os.name"
|
||||
or
|
||||
f.hasName("OS_VERSION") and propertyName = "os.version"
|
||||
or
|
||||
f.hasName("PATH_SEPARATOR") and propertyName = "path.separator"
|
||||
or
|
||||
f.hasName("USER_COUNTRY") and propertyName = "user.country"
|
||||
or
|
||||
f.hasName("USER_DIR") and propertyName = "user.dir"
|
||||
or
|
||||
f.hasName("USER_HOME") and propertyName = "user.home"
|
||||
or
|
||||
f.hasName("USER_LANGUAGE") and propertyName = "user.language"
|
||||
or
|
||||
f.hasName("USER_NAME") and propertyName = "user.name"
|
||||
or
|
||||
f.hasName("USER_TIMEZONE") and propertyName = "user.timezone"
|
||||
)
|
||||
}
|
||||
|
||||
private MethodAccess getSystemPropertyFromApacheFileUtils(string propertyName) {
|
||||
exists(Method m |
|
||||
result.getMethod() = m and
|
||||
m.getDeclaringType().hasQualifiedName("org.apache.commons.io", "FileUtils")
|
||||
|
|
||||
m.hasName(["getTempDirectory", "getTempDirectoryPath"]) and propertyName = "java.io.tmpdir"
|
||||
or
|
||||
m.hasName(["getUserDirectory", "getUserDirectoryPath"]) and propertyName = "user.home"
|
||||
)
|
||||
}
|
||||
|
||||
private MethodAccess getSystemPropertyFromGuava(string propertyName) {
|
||||
exists(EnumConstant ec |
|
||||
ec.getDeclaringType().hasQualifiedName("com.google.common.base", "StandardSystemProperty") and
|
||||
// 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
|
||||
ec.hasName("JAVA_VENDOR") and propertyName = "java.vendor"
|
||||
or
|
||||
ec.hasName("JAVA_VENDOR_URL") and propertyName = "java.vendor.url"
|
||||
or
|
||||
ec.hasName("JAVA_HOME") and propertyName = "java.home"
|
||||
or
|
||||
ec.hasName("JAVA_VM_SPECIFICATION_VERSION") and propertyName = "java.vm.specification.version"
|
||||
or
|
||||
ec.hasName("JAVA_VM_SPECIFICATION_VENDOR") and propertyName = "java.vm.specification.vendor"
|
||||
or
|
||||
ec.hasName("JAVA_VM_SPECIFICATION_NAME") and propertyName = "java.vm.specification.name"
|
||||
or
|
||||
ec.hasName("JAVA_VM_VERSION") and propertyName = "java.vm.version"
|
||||
or
|
||||
ec.hasName("JAVA_VM_VENDOR") and propertyName = "java.vm.vendor"
|
||||
or
|
||||
ec.hasName("JAVA_VM_NAME") and propertyName = "java.vm.name"
|
||||
or
|
||||
ec.hasName("JAVA_SPECIFICATION_VERSION") and propertyName = "java.specification.version"
|
||||
or
|
||||
ec.hasName("JAVA_SPECIFICATION_VENDOR") and propertyName = "java.specification.vendor"
|
||||
or
|
||||
ec.hasName("JAVA_SPECIFICATION_NAME") and propertyName = "java.specification.name"
|
||||
or
|
||||
ec.hasName("JAVA_CLASS_VERSION") and propertyName = "java.class.version"
|
||||
or
|
||||
ec.hasName("JAVA_CLASS_PATH") and propertyName = "java.class.path"
|
||||
or
|
||||
ec.hasName("JAVA_LIBRARY_PATH") and propertyName = "java.library.path"
|
||||
or
|
||||
ec.hasName("JAVA_IO_TMPDIR") and propertyName = "java.io.tmpdir"
|
||||
or
|
||||
ec.hasName("JAVA_COMPILER") and propertyName = "java.compiler"
|
||||
or
|
||||
ec.hasName("JAVA_EXT_DIRS") and propertyName = "java.ext.dirs"
|
||||
or
|
||||
ec.hasName("OS_NAME") and propertyName = "os.name"
|
||||
or
|
||||
ec.hasName("OS_ARCH") and propertyName = "os.arch"
|
||||
or
|
||||
ec.hasName("OS_VERSION") and propertyName = "os.version"
|
||||
or
|
||||
ec.hasName("FILE_SEPARATOR") and propertyName = "file.separator"
|
||||
or
|
||||
ec.hasName("PATH_SEPARATOR") and propertyName = "path.separator"
|
||||
or
|
||||
ec.hasName("LINE_SEPARATOR") and propertyName = "line.separator"
|
||||
or
|
||||
ec.hasName("USER_NAME") and propertyName = "user.name"
|
||||
or
|
||||
ec.hasName("USER_HOME") and propertyName = "user.home"
|
||||
or
|
||||
ec.hasName("USER_DIR") and propertyName = "user.dir"
|
||||
)
|
||||
}
|
||||
|
||||
private MethodAccess getSystemPropertyFromOperatingSystemMXBean(string propertyName) {
|
||||
exists(Method m |
|
||||
m = result.getMethod() and
|
||||
m.getDeclaringType().hasQualifiedName("java.lang.management", "OperatingSystemMXBean")
|
||||
|
|
||||
m.getName() = "getName" and propertyName = "os.name"
|
||||
or
|
||||
m.getName() = "getArch" and propertyName = "os.arch"
|
||||
or
|
||||
m.getName() = "getVersion" and propertyName = "os.version"
|
||||
)
|
||||
}
|
||||
|
||||
private MethodAccess getSystemPropertyFromSpringProperties(string propertyName) {
|
||||
exists(Method m |
|
||||
m = result.getMethod() and
|
||||
m.getDeclaringType().hasQualifiedName("org.springframework.core", "SpringProperties") and
|
||||
m.hasName("getProperty")
|
||||
) and
|
||||
result.getArgument(0).(CompileTimeConstantExpr).getStringValue() = propertyName
|
||||
}
|
||||
|
||||
/**
|
||||
* Holds if data can flow from `e1` to `e2` in zero or more
|
||||
* local (intra-procedural) steps or via local variable intializers
|
||||
* for final variables.
|
||||
*/
|
||||
private predicate localExprFlowPlusInitializers(Expr e1, Expr e2) {
|
||||
localFlowPlusInitializers(DataFlow::exprNode(e1), DataFlow::exprNode(e2))
|
||||
}
|
||||
|
||||
/**
|
||||
* Holds if data can flow from `pred` to `succ` in zero or more
|
||||
* local (intra-procedural) steps or via instance or static variable intializers
|
||||
* for final variables.
|
||||
*/
|
||||
private predicate localFlowPlusInitializers(DataFlow::Node pred, DataFlow::Node succ) {
|
||||
exists(Variable v | v.isFinal() and pred.asExpr() = v.getInitializer() |
|
||||
DataFlow::localFlow(DataFlow::exprNode(v.getAnAccess()), succ)
|
||||
)
|
||||
or
|
||||
DataFlow::localFlow(pred, succ)
|
||||
}
|
||||
@@ -1,25 +1,44 @@
|
||||
/* Definitions related to `java.util.Properties`. */
|
||||
import semmle.code.java.Type
|
||||
private import semmle.code.java.dataflow.FlowSteps
|
||||
|
||||
library class TypeProperty extends Class {
|
||||
/**
|
||||
* The `java.util.Properties` class.
|
||||
*/
|
||||
class TypeProperty extends Class {
|
||||
TypeProperty() { hasQualifiedName("java.util", "Properties") }
|
||||
}
|
||||
|
||||
library class PropertiesGetPropertyMethod extends Method {
|
||||
/** The `getProperty` method of the class `java.util.Properties`. */
|
||||
class PropertiesGetPropertyMethod extends ValuePreservingMethod {
|
||||
PropertiesGetPropertyMethod() {
|
||||
getDeclaringType() instanceof TypeProperty and
|
||||
hasName("getProperty")
|
||||
}
|
||||
|
||||
override predicate returnsValue(int arg) { arg = 1 }
|
||||
}
|
||||
|
||||
library class PropertiesSetPropertyMethod extends Method {
|
||||
/** The `get` method of the class `java.util.Properties`. */
|
||||
class PropertiesGetMethod extends Method {
|
||||
PropertiesGetMethod() {
|
||||
getDeclaringType() instanceof TypeProperty and
|
||||
hasName("get")
|
||||
}
|
||||
}
|
||||
|
||||
/** The `setProperty` method of the class `java.util.Properties`. */
|
||||
class PropertiesSetPropertyMethod extends Method {
|
||||
PropertiesSetPropertyMethod() {
|
||||
getDeclaringType() instanceof TypeProperty and
|
||||
hasName("setProperty")
|
||||
}
|
||||
}
|
||||
|
||||
library class PropertiesStoreMethod extends Method {
|
||||
/**
|
||||
* The methods of the class `java.util.Properties` that write the contents to an output.
|
||||
*/
|
||||
class PropertiesStoreMethod extends Method {
|
||||
PropertiesStoreMethod() {
|
||||
getDeclaringType() instanceof TypeProperty and
|
||||
(getName().matches("store%") or getName() = "save")
|
||||
|
||||
@@ -37,3 +37,12 @@ private class ApacheStrBuilderFluentMethod extends FluentMethod {
|
||||
this.getReturnType().(RefType).hasQualifiedName("org.apache.commons.lang3.text", "StrBuilder")
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The class `org.apache.commons.lang.SystemUtils` or `org.apache.commons.lang3.SystemUtils`.
|
||||
*/
|
||||
class TypeApacheSystemUtils extends Class {
|
||||
TypeApacheSystemUtils() {
|
||||
this.hasQualifiedName(["org.apache.commons.lang", "org.apache.commons.lang3"], "SystemUtils")
|
||||
}
|
||||
}
|
||||
|
||||
161
java/ql/lib/semmle/code/java/os/OSCheck.qll
Normal file
161
java/ql/lib/semmle/code/java/os/OSCheck.qll
Normal file
@@ -0,0 +1,161 @@
|
||||
/**
|
||||
* Provides classes and predicates for guards that check for the current OS.
|
||||
*/
|
||||
|
||||
import java
|
||||
import semmle.code.java.controlflow.Guards
|
||||
private import semmle.code.java.environment.SystemProperty
|
||||
private import semmle.code.java.frameworks.apache.Lang
|
||||
private import semmle.code.java.dataflow.DataFlow
|
||||
private import semmle.code.java.dataflow.TaintTracking
|
||||
|
||||
/**
|
||||
* A guard that checks if the current OS is Windows.
|
||||
* When True, the OS is Windows.
|
||||
* When False, the OS is not Windows.
|
||||
*/
|
||||
abstract class IsWindowsGuard extends Guard { }
|
||||
|
||||
/**
|
||||
* A guard that checks if the current OS is a specific Windows variant.
|
||||
* When True, the OS is Windows.
|
||||
* When False, the OS *may* still be Windows.
|
||||
*/
|
||||
abstract class IsSpecificWindowsVariant extends Guard { }
|
||||
|
||||
/**
|
||||
* A guard that checks if the current OS is unix or unix-like.
|
||||
* When True, the OS is unix or unix-like.
|
||||
* When False, the OS is not unix or unix-like.
|
||||
*/
|
||||
abstract class IsUnixGuard extends Guard { }
|
||||
|
||||
/**
|
||||
* A guard that checks if the current OS is a specific unix or unix-like variant.
|
||||
* When True, the OS is unix or unix-like.
|
||||
* When False, the OS *may* still be unix or unix-like.
|
||||
*/
|
||||
abstract class IsSpecificUnixVariant extends Guard { }
|
||||
|
||||
/**
|
||||
* Holds when `ma` compares the current OS against the string constant `osString`.
|
||||
*/
|
||||
private predicate isOsFromSystemProp(MethodAccess ma, string osString) {
|
||||
TaintTracking::localExprTaint(getSystemProperty("os.name"), ma.getQualifier()) and // Call from System.getProperty (or equivalent) to some partial match method
|
||||
exists(StringPartialMatchMethod m, CompileTimeConstantExpr matchedStringConstant |
|
||||
m = ma.getMethod() and
|
||||
matchedStringConstant.getStringValue().toLowerCase() = osString
|
||||
|
|
||||
DataFlow::localExprFlow(matchedStringConstant, ma.getArgument(m.getMatchParameterIndex()))
|
||||
)
|
||||
}
|
||||
|
||||
private class IsWindowsFromSystemProp extends IsWindowsGuard instanceof MethodAccess {
|
||||
IsWindowsFromSystemProp() { isOsFromSystemProp(this, any(string s | s.regexpMatch("windows?"))) }
|
||||
}
|
||||
|
||||
/**
|
||||
* Holds when the Guard is an equality check between the system property with the name `propertyName`
|
||||
* and the string or char constant `compareToLiteral`, and the branch evaluates to `branch`.
|
||||
*/
|
||||
private Guard isOsFromSystemPropertyEqualityCheck(
|
||||
string propertyName, string compareToLiteral, boolean branch
|
||||
) {
|
||||
result
|
||||
.isEquality(getSystemProperty(propertyName),
|
||||
any(Literal literal |
|
||||
(literal instanceof CharacterLiteral or literal instanceof StringLiteral) and
|
||||
literal.getValue() = compareToLiteral
|
||||
), branch)
|
||||
}
|
||||
|
||||
private class IsWindowsFromPathSeparator extends IsWindowsGuard {
|
||||
IsWindowsFromPathSeparator() {
|
||||
this = isOsFromSystemPropertyEqualityCheck("path.separator", ";", true) or
|
||||
this = isOsFromSystemPropertyEqualityCheck("path.separator", ":", false)
|
||||
}
|
||||
}
|
||||
|
||||
private class IsWindowsFromFileSeparator extends IsWindowsGuard {
|
||||
IsWindowsFromFileSeparator() {
|
||||
this = isOsFromSystemPropertyEqualityCheck("file.separator", "\\", true) or
|
||||
this = isOsFromSystemPropertyEqualityCheck("file.separator", "/", false)
|
||||
}
|
||||
}
|
||||
|
||||
private class IsUnixFromPathSeparator extends IsUnixGuard {
|
||||
IsUnixFromPathSeparator() {
|
||||
this = isOsFromSystemPropertyEqualityCheck("path.separator", ":", true) or
|
||||
this = isOsFromSystemPropertyEqualityCheck("path.separator", ";", false)
|
||||
}
|
||||
}
|
||||
|
||||
private class IsUnixFromFileSeparator extends IsUnixGuard {
|
||||
IsUnixFromFileSeparator() {
|
||||
this = isOsFromSystemPropertyEqualityCheck("file.separator", "/", true) or
|
||||
this = isOsFromSystemPropertyEqualityCheck("file.separator", "\\", false)
|
||||
}
|
||||
}
|
||||
|
||||
private class IsUnixFromSystemProp extends IsSpecificUnixVariant instanceof MethodAccess {
|
||||
IsUnixFromSystemProp() {
|
||||
isOsFromSystemProp(this, any(string s | s.regexpMatch(["mac.*", "linux.*"])))
|
||||
}
|
||||
}
|
||||
|
||||
bindingset[fieldNamePattern]
|
||||
private predicate isOsFromApacheCommons(FieldAccess fa, string fieldNamePattern) {
|
||||
exists(Field f | f = fa.getField() |
|
||||
f.getDeclaringType() instanceof TypeApacheSystemUtils and
|
||||
f.getName().matches(fieldNamePattern)
|
||||
)
|
||||
}
|
||||
|
||||
private class IsWindowsFromApacheCommons extends IsWindowsGuard instanceof FieldAccess {
|
||||
IsWindowsFromApacheCommons() { isOsFromApacheCommons(this, "IS_OS_WINDOWS") }
|
||||
}
|
||||
|
||||
private class IsSpecificWindowsVariantFromApacheCommons extends IsSpecificWindowsVariant instanceof FieldAccess {
|
||||
IsSpecificWindowsVariantFromApacheCommons() { isOsFromApacheCommons(this, "IS_OS_WINDOWS_%") }
|
||||
}
|
||||
|
||||
private class IsUnixFromApacheCommons extends IsUnixGuard instanceof FieldAccess {
|
||||
IsUnixFromApacheCommons() { isOsFromApacheCommons(this, "IS_OS_UNIX") }
|
||||
}
|
||||
|
||||
private class IsSpecificUnixVariantFromApacheCommons extends IsSpecificUnixVariant instanceof FieldAccess {
|
||||
IsSpecificUnixVariantFromApacheCommons() {
|
||||
isOsFromApacheCommons(this,
|
||||
[
|
||||
"IS_OS_AIX", "IS_OS_HP_UX", "IS_OS_IRIX", "IS_OS_LINUX", "IS_OS_MAC%", "IS_OS_FREE_BSD",
|
||||
"IS_OS_OPEN_BSD", "IS_OS_NET_BSD", "IS_OS_SOLARIS", "IS_OS_SUN_OS", "IS_OS_ZOS"
|
||||
])
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A guard that checks if the `java.nio.file.FileSystem` supports posix file permissions.
|
||||
* This is often used to infer if the OS is unix-based and can generally be considered to be true for all unix-based OSes
|
||||
* ([source](https://en.wikipedia.org/wiki/POSIX#POSIX-oriented_operating_systems)).
|
||||
* Looks for calls to `contains("posix")` on the `supportedFileAttributeViews()` method returned by `FileSystem`.
|
||||
*/
|
||||
private class IsUnixFromPosixFromFileSystem extends IsUnixGuard instanceof MethodAccess {
|
||||
IsUnixFromPosixFromFileSystem() {
|
||||
exists(Method m | m = this.getMethod() |
|
||||
m.getDeclaringType()
|
||||
.getASupertype*()
|
||||
.getSourceDeclaration()
|
||||
.hasQualifiedName("java.util", "Set") and
|
||||
m.hasName("contains")
|
||||
) and
|
||||
this.getArgument(0).(CompileTimeConstantExpr).getStringValue() = "posix" and
|
||||
exists(Method supportedFileAttributeViewsMethod |
|
||||
supportedFileAttributeViewsMethod.hasName("supportedFileAttributeViews") and
|
||||
supportedFileAttributeViewsMethod.getDeclaringType() instanceof TypeFileSystem
|
||||
|
|
||||
DataFlow::localExprFlow(any(MethodAccess ma |
|
||||
ma.getMethod() = supportedFileAttributeViewsMethod
|
||||
), super.getQualifier())
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,7 @@
|
||||
*/
|
||||
|
||||
import java
|
||||
import semmle.code.java.os.OSCheck
|
||||
import TempDirUtils
|
||||
import DataFlow::PathGraph
|
||||
import semmle.code.java.dataflow.TaintTracking2
|
||||
@@ -102,11 +103,36 @@ private class FileCreateTempFileSink extends FileCreationSink {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A guard that holds when the program is definitely running under some version of Windows.
|
||||
*/
|
||||
abstract private class WindowsOsBarrierGuard extends DataFlow::BarrierGuard { }
|
||||
|
||||
private class IsNotUnixBarrierGuard extends WindowsOsBarrierGuard instanceof IsUnixGuard {
|
||||
override predicate checks(Expr e, boolean branch) {
|
||||
this.controls(e.getBasicBlock(), branch.booleanNot())
|
||||
}
|
||||
}
|
||||
|
||||
private class IsWindowsBarrierGuard extends WindowsOsBarrierGuard instanceof IsWindowsGuard {
|
||||
override predicate checks(Expr e, boolean branch) { this.controls(e.getBasicBlock(), branch) }
|
||||
}
|
||||
|
||||
private class IsSpecificWindowsBarrierGuard extends WindowsOsBarrierGuard instanceof IsSpecificWindowsVariant {
|
||||
override predicate checks(Expr e, boolean branch) {
|
||||
branch = true and this.controls(e.getBasicBlock(), branch)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A taint tracking configuration tracking the access of the system temporary directory
|
||||
* flowing to the creation of files or directories.
|
||||
*/
|
||||
private class TempDirSystemGetPropertyToCreateConfig extends TaintTracking::Configuration {
|
||||
TempDirSystemGetPropertyToCreateConfig() { this = "TempDirSystemGetPropertyToCreateConfig" }
|
||||
|
||||
override predicate isSource(DataFlow::Node source) {
|
||||
source.asExpr() instanceof MethodAccessSystemGetPropertyTempDirTainted
|
||||
source.asExpr() instanceof ExprSystemGetPropertyTempDirTainted
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -129,6 +155,10 @@ private class TempDirSystemGetPropertyToCreateConfig extends TaintTracking::Conf
|
||||
sanitizer.asExpr() = sanitisingMethodAccess.getArgument(0)
|
||||
)
|
||||
}
|
||||
|
||||
override predicate isSanitizerGuard(DataFlow::BarrierGuard guard) {
|
||||
guard instanceof WindowsOsBarrierGuard
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -147,10 +177,8 @@ private class TempDirSystemGetPropertyDirectlyToMkdirConfig extends TaintTrackin
|
||||
}
|
||||
|
||||
override predicate isSource(DataFlow::Node node) {
|
||||
exists(
|
||||
MethodAccessSystemGetPropertyTempDirTainted propertyGetMethodAccess, DataFlow::Node callSite
|
||||
|
|
||||
DataFlow::localFlow(DataFlow::exprNode(propertyGetMethodAccess), callSite)
|
||||
exists(ExprSystemGetPropertyTempDirTainted propertyGetExpr, DataFlow::Node callSite |
|
||||
DataFlow::localFlow(DataFlow::exprNode(propertyGetExpr), callSite)
|
||||
|
|
||||
isFileConstructorArgument(callSite.asExpr(), node.asExpr(), 1)
|
||||
)
|
||||
|
||||
@@ -1,10 +1,14 @@
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.UncheckedIOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.attribute.PosixFilePermission;
|
||||
import java.nio.file.attribute.PosixFilePermissions;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
|
||||
public class TempDirUsageSafe {
|
||||
void exampleSafe() throws IOException {
|
||||
Path temp1 = Files.createTempFile("random", ".txt"); // GOOD: File has permissions `-rw-------`
|
||||
@@ -30,7 +34,7 @@ public class TempDirUsageSafe {
|
||||
createTempFile(tempChildFile.toPath()); // GOOD: Good has permissions `-rw-------`
|
||||
}
|
||||
|
||||
static void createTempFile(Path tempDir) {
|
||||
static void createTempFile(Path tempDirChild) {
|
||||
try {
|
||||
if (tempDirChild.getFileSystem().supportedFileAttributeViews().contains("posix")) {
|
||||
// Explicit permissions setting is only required on unix-like systems because
|
||||
|
||||
@@ -3,34 +3,14 @@
|
||||
*/
|
||||
|
||||
import java
|
||||
private import semmle.code.java.environment.SystemProperty
|
||||
import semmle.code.java.dataflow.FlowSources
|
||||
|
||||
/**
|
||||
* A method that returns a `String` or `File` that has been tainted by `System.getProperty("java.io.tmpdir")`.
|
||||
* A method or field access that returns a `String` or `File` that has been tainted by `System.getProperty("java.io.tmpdir")`.
|
||||
*/
|
||||
abstract class MethodAccessSystemGetPropertyTempDirTainted extends MethodAccess { }
|
||||
|
||||
/**
|
||||
* Method access `System.getProperty("java.io.tmpdir")`.
|
||||
*/
|
||||
private class MethodAccessSystemGetPropertyTempDir extends MethodAccessSystemGetPropertyTempDirTainted,
|
||||
MethodAccessSystemGetProperty {
|
||||
MethodAccessSystemGetPropertyTempDir() {
|
||||
this.hasCompileTimeConstantGetPropertyName("java.io.tmpdir")
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A method call to the `org.apache.commons.io.FileUtils` methods `getTempDirectory` or `getTempDirectoryPath`.
|
||||
*/
|
||||
private class MethodAccessApacheFileUtilsTempDir extends MethodAccessSystemGetPropertyTempDirTainted {
|
||||
MethodAccessApacheFileUtilsTempDir() {
|
||||
exists(Method m |
|
||||
m.getDeclaringType().hasQualifiedName("org.apache.commons.io", "FileUtils") and
|
||||
m.hasName(["getTempDirectory", "getTempDirectoryPath"]) and
|
||||
this.getMethod() = m
|
||||
)
|
||||
}
|
||||
class ExprSystemGetPropertyTempDirTainted extends Expr {
|
||||
ExprSystemGetPropertyTempDirTainted() { this = getSystemProperty("java.io.tmpdir") }
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
7
java/ql/src/change-notes/2022-02-14-os-guards.md
Normal file
7
java/ql/src/change-notes/2022-02-14-os-guards.md
Normal file
@@ -0,0 +1,7 @@
|
||||
---
|
||||
category: minorAnalysis
|
||||
---
|
||||
* Added new guards `IsWindowsGuard`, `IsSpecificWindowsVariant`, `IsUnixGuard`, and `IsSpecificUnixVariant` to detect OS specific guards.
|
||||
* Added a new predicate `getSystemProperty` that gets all expressions that retrieve system properties from a variety of sources (eg. alternative JDK API's, Google Guava, Apache Commons, Apache IO, etc..).
|
||||
* Updated "Local information disclosure in a temporary directory" (`java/local-temp-file-or-directory-information-disclosure`) to remove false-positives when OS is properly used as logical guard.
|
||||
|
||||
@@ -60,6 +60,75 @@ jdk/A.java:
|
||||
# 28| 0: [ArrayTypeAccess] ...[]
|
||||
# 28| 0: [TypeAccess] String
|
||||
# 28| 5: [BlockStmt] { ... }
|
||||
jdk/StringMatch.java:
|
||||
# 0| [CompilationUnit] StringMatch
|
||||
# 1| 1: [Class] StringMatch
|
||||
# 2| 3: [FieldDeclaration] String STR;
|
||||
# 2| -1: [TypeAccess] String
|
||||
# 2| 0: [StringLiteral] "the quick brown fox jumps over the lazy dog"
|
||||
# 4| 4: [Method] a
|
||||
# 4| 3: [TypeAccess] void
|
||||
# 4| 5: [BlockStmt] { ... }
|
||||
# 5| 0: [ExprStmt] <Expr>;
|
||||
# 5| 0: [MethodAccess] matches(...)
|
||||
# 5| -1: [VarAccess] STR
|
||||
# 5| 0: [StringLiteral] "[a-z]+"
|
||||
# 8| 5: [Method] b
|
||||
# 8| 3: [TypeAccess] void
|
||||
# 8| 5: [BlockStmt] { ... }
|
||||
# 9| 0: [ExprStmt] <Expr>;
|
||||
# 9| 0: [MethodAccess] contains(...)
|
||||
# 9| -1: [VarAccess] STR
|
||||
# 9| 0: [StringLiteral] "the"
|
||||
# 12| 6: [Method] c
|
||||
# 12| 3: [TypeAccess] void
|
||||
# 12| 5: [BlockStmt] { ... }
|
||||
# 13| 0: [ExprStmt] <Expr>;
|
||||
# 13| 0: [MethodAccess] startsWith(...)
|
||||
# 13| -1: [VarAccess] STR
|
||||
# 13| 0: [StringLiteral] "the"
|
||||
# 16| 7: [Method] d
|
||||
# 16| 3: [TypeAccess] void
|
||||
# 16| 5: [BlockStmt] { ... }
|
||||
# 17| 0: [ExprStmt] <Expr>;
|
||||
# 17| 0: [MethodAccess] endsWith(...)
|
||||
# 17| -1: [VarAccess] STR
|
||||
# 17| 0: [StringLiteral] "dog"
|
||||
# 20| 8: [Method] e
|
||||
# 20| 3: [TypeAccess] void
|
||||
# 20| 5: [BlockStmt] { ... }
|
||||
# 21| 0: [ExprStmt] <Expr>;
|
||||
# 21| 0: [MethodAccess] indexOf(...)
|
||||
# 21| -1: [VarAccess] STR
|
||||
# 21| 0: [StringLiteral] "lazy"
|
||||
# 24| 9: [Method] f
|
||||
# 24| 3: [TypeAccess] void
|
||||
# 24| 5: [BlockStmt] { ... }
|
||||
# 25| 0: [ExprStmt] <Expr>;
|
||||
# 25| 0: [MethodAccess] lastIndexOf(...)
|
||||
# 25| -1: [VarAccess] STR
|
||||
# 25| 0: [StringLiteral] "lazy"
|
||||
# 28| 10: [Method] g
|
||||
# 28| 3: [TypeAccess] void
|
||||
# 28| 5: [BlockStmt] { ... }
|
||||
# 29| 0: [ExprStmt] <Expr>;
|
||||
# 29| 0: [MethodAccess] regionMatches(...)
|
||||
# 29| -1: [VarAccess] STR
|
||||
# 29| 0: [IntegerLiteral] 0
|
||||
# 29| 1: [StringLiteral] "fox"
|
||||
# 29| 2: [IntegerLiteral] 0
|
||||
# 29| 3: [IntegerLiteral] 4
|
||||
# 32| 11: [Method] h
|
||||
# 32| 3: [TypeAccess] void
|
||||
# 32| 5: [BlockStmt] { ... }
|
||||
# 33| 0: [ExprStmt] <Expr>;
|
||||
# 33| 0: [MethodAccess] regionMatches(...)
|
||||
# 33| -1: [VarAccess] STR
|
||||
# 33| 0: [BooleanLiteral] true
|
||||
# 33| 1: [IntegerLiteral] 0
|
||||
# 33| 2: [StringLiteral] "FOX"
|
||||
# 33| 3: [IntegerLiteral] 0
|
||||
# 33| 4: [IntegerLiteral] 4
|
||||
jdk/SystemGetPropertyCall.java:
|
||||
# 0| [CompilationUnit] SystemGetPropertyCall
|
||||
# 3| 1: [Class] SystemGetPropertyCall
|
||||
|
||||
8
java/ql/test/library-tests/JDK/StringMatch.expected
Normal file
8
java/ql/test/library-tests/JDK/StringMatch.expected
Normal file
@@ -0,0 +1,8 @@
|
||||
| jdk/StringMatch.java:5:9:5:29 | matches(...) | jdk/StringMatch.java:5:21:5:28 | "[a-z]+" |
|
||||
| jdk/StringMatch.java:9:9:9:27 | contains(...) | jdk/StringMatch.java:9:22:9:26 | "the" |
|
||||
| jdk/StringMatch.java:13:9:13:29 | startsWith(...) | jdk/StringMatch.java:13:24:13:28 | "the" |
|
||||
| jdk/StringMatch.java:17:9:17:27 | endsWith(...) | jdk/StringMatch.java:17:22:17:26 | "dog" |
|
||||
| jdk/StringMatch.java:21:9:21:27 | indexOf(...) | jdk/StringMatch.java:21:21:21:26 | "lazy" |
|
||||
| jdk/StringMatch.java:25:9:25:31 | lastIndexOf(...) | jdk/StringMatch.java:25:25:25:30 | "lazy" |
|
||||
| jdk/StringMatch.java:29:9:29:41 | regionMatches(...) | jdk/StringMatch.java:29:30:29:34 | "fox" |
|
||||
| jdk/StringMatch.java:33:9:33:47 | regionMatches(...) | jdk/StringMatch.java:33:36:33:40 | "FOX" |
|
||||
5
java/ql/test/library-tests/JDK/StringMatch.ql
Normal file
5
java/ql/test/library-tests/JDK/StringMatch.ql
Normal file
@@ -0,0 +1,5 @@
|
||||
import java
|
||||
|
||||
from MethodAccess ma, StringPartialMatchMethod m
|
||||
where ma.getMethod() = m
|
||||
select ma, ma.getArgument(m.getMatchParameterIndex())
|
||||
35
java/ql/test/library-tests/JDK/jdk/StringMatch.java
Normal file
35
java/ql/test/library-tests/JDK/jdk/StringMatch.java
Normal file
@@ -0,0 +1,35 @@
|
||||
public class StringMatch {
|
||||
private static String STR = "the quick brown fox jumps over the lazy dog";
|
||||
|
||||
void a() {
|
||||
STR.matches("[a-z]+");
|
||||
}
|
||||
|
||||
void b() {
|
||||
STR.contains("the");
|
||||
}
|
||||
|
||||
void c() {
|
||||
STR.startsWith("the");
|
||||
}
|
||||
|
||||
void d() {
|
||||
STR.endsWith("dog");
|
||||
}
|
||||
|
||||
void e() {
|
||||
STR.indexOf("lazy");
|
||||
}
|
||||
|
||||
void f() {
|
||||
STR.lastIndexOf("lazy");
|
||||
}
|
||||
|
||||
void g() {
|
||||
STR.regionMatches(0, "fox", 0, 4);
|
||||
}
|
||||
|
||||
void h() {
|
||||
STR.regionMatches(true, 0, "FOX", 0, 4);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
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();
|
||||
|
||||
void test() {
|
||||
System.getProperty("os.name");
|
||||
System.getProperty("os.name", "default");
|
||||
System.getProperties().getProperty("os.name");
|
||||
System.getProperties().get("java.io.tmpdir");
|
||||
SYSTEM_PROPERTIES.getProperty("java.home");
|
||||
SYSTEM_PROPERTIES.get("file.encoding");
|
||||
System.lineSeparator();
|
||||
String awtToolkit = SystemUtils.AWT_TOOLKIT;
|
||||
String fileEncoding = SystemUtils.FILE_ENCODING;
|
||||
String tmpDir = SystemUtils.JAVA_IO_TMPDIR;
|
||||
String separator = File.separator;
|
||||
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());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
| ../../stubs/apache-commons-lang3-3.7/org/apache/commons/lang3/SystemUtils.java:93:5:93:50 | AWT_TOOLKIT | awt.toolkit |
|
||||
| ../../stubs/apache-commons-lang3-3.7/org/apache/commons/lang3/SystemUtils.java:115:5:115:52 | FILE_ENCODING | file.encoding |
|
||||
| ../../stubs/apache-commons-lang3-3.7/org/apache/commons/lang3/SystemUtils.java:141:5:142:53 | FILE_SEPARATOR | file.separator |
|
||||
| ../../stubs/apache-commons-lang3-3.7/org/apache/commons/lang3/SystemUtils.java:160:5:160:53 | JAVA_AWT_FONTS | java.awt.fonts |
|
||||
| ../../stubs/apache-commons-lang3-3.7/org/apache/commons/lang3/SystemUtils.java:178:5:178:59 | JAVA_AWT_GRAPHICSENV | java.awt.graphicsenv |
|
||||
| ../../stubs/apache-commons-lang3-3.7/org/apache/commons/lang3/SystemUtils.java:199:5:199:56 | JAVA_AWT_HEADLESS | java.awt.headless |
|
||||
| ../../stubs/apache-commons-lang3-3.7/org/apache/commons/lang3/SystemUtils.java:217:5:217:58 | JAVA_AWT_PRINTERJOB | java.awt.printerjob |
|
||||
| ../../stubs/apache-commons-lang3-3.7/org/apache/commons/lang3/SystemUtils.java:235:5:235:54 | JAVA_CLASS_PATH | java.class.path |
|
||||
| ../../stubs/apache-commons-lang3-3.7/org/apache/commons/lang3/SystemUtils.java:253:5:253:57 | JAVA_CLASS_VERSION | java.class.version |
|
||||
| ../../stubs/apache-commons-lang3-3.7/org/apache/commons/lang3/SystemUtils.java:272:5:272:52 | JAVA_COMPILER | java.compiler |
|
||||
| ../../stubs/apache-commons-lang3-3.7/org/apache/commons/lang3/SystemUtils.java:308:5:308:52 | JAVA_EXT_DIRS | java.ext.dirs |
|
||||
| ../../stubs/apache-commons-lang3-3.7/org/apache/commons/lang3/SystemUtils.java:326:5:326:48 | JAVA_HOME | java.home |
|
||||
| ../../stubs/apache-commons-lang3-3.7/org/apache/commons/lang3/SystemUtils.java:344:5:344:53 | JAVA_IO_TMPDIR | java.io.tmpdir |
|
||||
| ../../stubs/apache-commons-lang3-3.7/org/apache/commons/lang3/SystemUtils.java:362:5:362:56 | JAVA_LIBRARY_PATH | java.library.path |
|
||||
| ../../stubs/apache-commons-lang3-3.7/org/apache/commons/lang3/SystemUtils.java:381:5:381:56 | JAVA_RUNTIME_NAME | java.runtime.name |
|
||||
| ../../stubs/apache-commons-lang3-3.7/org/apache/commons/lang3/SystemUtils.java:400:5:400:59 | JAVA_RUNTIME_VERSION | java.runtime.version |
|
||||
| ../../stubs/apache-commons-lang3-3.7/org/apache/commons/lang3/SystemUtils.java:418:5:418:62 | JAVA_SPECIFICATION_NAME | java.specification.name |
|
||||
| ../../stubs/apache-commons-lang3-3.7/org/apache/commons/lang3/SystemUtils.java:436:5:436:64 | JAVA_SPECIFICATION_VENDOR | java.specification.vendor |
|
||||
| ../../stubs/apache-commons-lang3-3.7/org/apache/commons/lang3/SystemUtils.java:473:5:474:13 | JAVA_UTIL_PREFS_PREFERENCES_FACTORY | java.util.prefs.PreferencesFactory |
|
||||
| ../../stubs/apache-commons-lang3-3.7/org/apache/commons/lang3/SystemUtils.java:492:5:492:50 | JAVA_VENDOR | java.vendor |
|
||||
| ../../stubs/apache-commons-lang3-3.7/org/apache/commons/lang3/SystemUtils.java:510:5:510:54 | JAVA_VENDOR_URL | java.vendor.url |
|
||||
| ../../stubs/apache-commons-lang3-3.7/org/apache/commons/lang3/SystemUtils.java:528:5:528:51 | JAVA_VERSION | java.version |
|
||||
| ../../stubs/apache-commons-lang3-3.7/org/apache/commons/lang3/SystemUtils.java:547:5:547:51 | JAVA_VM_INFO | java.vm.info |
|
||||
| ../../stubs/apache-commons-lang3-3.7/org/apache/commons/lang3/SystemUtils.java:565:5:565:51 | JAVA_VM_NAME | java.vm.name |
|
||||
| ../../stubs/apache-commons-lang3-3.7/org/apache/commons/lang3/SystemUtils.java:583:5:583:65 | JAVA_VM_SPECIFICATION_NAME | java.vm.specification.name |
|
||||
| ../../stubs/apache-commons-lang3-3.7/org/apache/commons/lang3/SystemUtils.java:601:5:601:67 | JAVA_VM_SPECIFICATION_VENDOR | java.vm.specification.vendor |
|
||||
| ../../stubs/apache-commons-lang3-3.7/org/apache/commons/lang3/SystemUtils.java:637:5:637:53 | JAVA_VM_VENDOR | java.vm.vendor |
|
||||
| ../../stubs/apache-commons-lang3-3.7/org/apache/commons/lang3/SystemUtils.java:655:5:655:54 | JAVA_VM_VERSION | java.vm.version |
|
||||
| ../../stubs/apache-commons-lang3-3.7/org/apache/commons/lang3/SystemUtils.java:674:5:675:53 | LINE_SEPARATOR | line.separator |
|
||||
| ../../stubs/apache-commons-lang3-3.7/org/apache/commons/lang3/SystemUtils.java:693:5:693:46 | OS_ARCH | os.arch |
|
||||
| ../../stubs/apache-commons-lang3-3.7/org/apache/commons/lang3/SystemUtils.java:711:5:711:46 | OS_NAME | os.name |
|
||||
| ../../stubs/apache-commons-lang3-3.7/org/apache/commons/lang3/SystemUtils.java:729:5:729:49 | OS_VERSION | os.version |
|
||||
| ../../stubs/apache-commons-lang3-3.7/org/apache/commons/lang3/SystemUtils.java:749:5:750:53 | PATH_SEPARATOR | path.separator |
|
||||
| ../../stubs/apache-commons-lang3-3.7/org/apache/commons/lang3/SystemUtils.java:770:5:770:73 | USER_COUNTRY | user.country |
|
||||
| ../../stubs/apache-commons-lang3-3.7/org/apache/commons/lang3/SystemUtils.java:788:5:788:47 | USER_DIR | user.dir |
|
||||
| ../../stubs/apache-commons-lang3-3.7/org/apache/commons/lang3/SystemUtils.java:806:5:806:48 | USER_HOME | user.home |
|
||||
| ../../stubs/apache-commons-lang3-3.7/org/apache/commons/lang3/SystemUtils.java:825:5:825:52 | USER_LANGUAGE | user.language |
|
||||
| ../../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: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 |
|
||||
@@ -0,0 +1,6 @@
|
||||
import default
|
||||
import semmle.code.java.environment.SystemProperty
|
||||
|
||||
from Expr systemPropertyAccess, string propertyName
|
||||
where systemPropertyAccess = getSystemProperty(propertyName)
|
||||
select systemPropertyAccess, propertyName
|
||||
1
java/ql/test/library-tests/environment/options
Normal file
1
java/ql/test/library-tests/environment/options
Normal file
@@ -0,0 +1 @@
|
||||
//semmle-extractor-options: --javac-args -cp ${testdir}/../../stubs/apache-commons-lang3-3.7/:${testdir}/../../stubs/guava-30.0/
|
||||
147
java/ql/test/library-tests/os/Test.java
Normal file
147
java/ql/test/library-tests/os/Test.java
Normal file
@@ -0,0 +1,147 @@
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.file.FileSystems;
|
||||
import java.nio.file.Path;
|
||||
|
||||
import org.apache.commons.lang3.SystemUtils;
|
||||
|
||||
public class Test {
|
||||
/**
|
||||
* Should only be called on windows
|
||||
*/
|
||||
private void onlyOnWindows() {}
|
||||
|
||||
/**
|
||||
* Should only be called on unix-like systems
|
||||
*/
|
||||
private void onlyOnUnix() {}
|
||||
|
||||
void testWindows() {
|
||||
if (System.getProperty("os.name").contains("Windows")) {
|
||||
onlyOnWindows();
|
||||
}
|
||||
|
||||
if (System.getProperty("os.name").toLowerCase().contains("windows")) {
|
||||
onlyOnWindows();
|
||||
}
|
||||
|
||||
if (System.getProperty("os.name").toLowerCase().contains("window")) {
|
||||
onlyOnWindows();
|
||||
}
|
||||
|
||||
if (System.getProperty("os.name").toUpperCase().contains("WINDOWS")) {
|
||||
onlyOnWindows();
|
||||
}
|
||||
|
||||
if (SystemUtils.IS_OS_WINDOWS) {
|
||||
onlyOnWindows();
|
||||
} else {
|
||||
onlyOnUnix();
|
||||
}
|
||||
|
||||
if (SystemUtils.IS_OS_WINDOWS_XP) {
|
||||
onlyOnWindows();
|
||||
} else {
|
||||
// Might be another version of windows
|
||||
}
|
||||
|
||||
if (File.pathSeparatorChar == ';') {
|
||||
onlyOnWindows();
|
||||
}
|
||||
|
||||
if (File.pathSeparator == ";") {
|
||||
onlyOnWindows();
|
||||
}
|
||||
|
||||
if (File.separatorChar == '\\') {
|
||||
onlyOnWindows();
|
||||
}
|
||||
|
||||
if (File.separator == "\\") {
|
||||
onlyOnWindows();
|
||||
}
|
||||
|
||||
if (System.getProperty("path.separator").equals(";")) {
|
||||
onlyOnWindows();
|
||||
}
|
||||
}
|
||||
|
||||
void testUnix() {
|
||||
if (Path.of("whatever").getFileSystem().supportedFileAttributeViews().contains("posix")) {
|
||||
onlyOnUnix();
|
||||
}
|
||||
|
||||
if (FileSystems.getDefault().supportedFileAttributeViews().contains("posix")) {
|
||||
onlyOnUnix();
|
||||
}
|
||||
|
||||
if (SystemUtils.IS_OS_UNIX) {
|
||||
onlyOnUnix();
|
||||
} else {
|
||||
// Reasonable assumption, maybe not 100% accurate, but it's 'good enough'
|
||||
onlyOnWindows();
|
||||
}
|
||||
|
||||
if (File.pathSeparatorChar == ':') {
|
||||
onlyOnUnix();
|
||||
}
|
||||
|
||||
if (File.pathSeparator == ":") {
|
||||
onlyOnUnix();
|
||||
}
|
||||
|
||||
if (File.separatorChar == '/') {
|
||||
onlyOnUnix();
|
||||
}
|
||||
|
||||
if (File.separator == "/") {
|
||||
onlyOnUnix();
|
||||
}
|
||||
|
||||
if (System.getProperty("path.separator").equals(":")) {
|
||||
onlyOnUnix();
|
||||
}
|
||||
}
|
||||
|
||||
void testLinux() {
|
||||
if (System.getProperty("os.name").toLowerCase().contains("linux")) {
|
||||
onlyOnUnix();
|
||||
}
|
||||
|
||||
if (System.getProperty("os.name").contains("Linux")) {
|
||||
onlyOnUnix();
|
||||
}
|
||||
|
||||
if (SystemUtils.IS_OS_LINUX) {
|
||||
onlyOnUnix();
|
||||
} else {
|
||||
// Might be another different unix-like system, so this can't be `onlyOnWindows()`.
|
||||
}
|
||||
|
||||
if (!SystemUtils.IS_OS_LINUX) {
|
||||
// Might be another different unix-like system, so this can't be `onlyOnWindows()`.
|
||||
} else {
|
||||
onlyOnUnix();
|
||||
}
|
||||
}
|
||||
|
||||
void testMacOs() {
|
||||
if (System.getProperty("os.name").contains("Mac OS X")) {
|
||||
onlyOnUnix();
|
||||
}
|
||||
|
||||
if (System.getProperty("os.name").toLowerCase().contains("mac")) {
|
||||
onlyOnUnix();
|
||||
}
|
||||
|
||||
if (SystemUtils.IS_OS_MAC) {
|
||||
onlyOnUnix();
|
||||
} else {
|
||||
// Can't assume this is windows, it could be another unix-like OS
|
||||
}
|
||||
|
||||
if (SystemUtils.IS_OS_MAC_OSX_MOJAVE) {
|
||||
onlyOnUnix();
|
||||
}
|
||||
}
|
||||
}
|
||||
1
java/ql/test/library-tests/os/options
Normal file
1
java/ql/test/library-tests/os/options
Normal file
@@ -0,0 +1 @@
|
||||
//semmle-extractor-options: --javac-args -cp ${testdir}/../../stubs/apache-commons-lang3-3.7/
|
||||
@@ -0,0 +1,37 @@
|
||||
| ../../stubs/apache-commons-lang3-3.7/org/apache/commons/lang3/SystemUtils.java:1079:5:1079:80 | IS_OS_AIX |
|
||||
| ../../stubs/apache-commons-lang3-3.7/org/apache/commons/lang3/SystemUtils.java:1091:5:1091:82 | IS_OS_HP_UX |
|
||||
| ../../stubs/apache-commons-lang3-3.7/org/apache/commons/lang3/SystemUtils.java:1115:5:1115:81 | IS_OS_IRIX |
|
||||
| ../../stubs/apache-commons-lang3-3.7/org/apache/commons/lang3/SystemUtils.java:1127:5:1127:82 | IS_OS_LINUX |
|
||||
| ../../stubs/apache-commons-lang3-3.7/org/apache/commons/lang3/SystemUtils.java:1139:5:1139:80 | IS_OS_MAC |
|
||||
| ../../stubs/apache-commons-lang3-3.7/org/apache/commons/lang3/SystemUtils.java:1151:5:1151:84 | IS_OS_MAC_OSX |
|
||||
| ../../stubs/apache-commons-lang3-3.7/org/apache/commons/lang3/SystemUtils.java:1163:5:1163:92 | IS_OS_MAC_OSX_CHEETAH |
|
||||
| ../../stubs/apache-commons-lang3-3.7/org/apache/commons/lang3/SystemUtils.java:1175:5:1175:89 | IS_OS_MAC_OSX_PUMA |
|
||||
| ../../stubs/apache-commons-lang3-3.7/org/apache/commons/lang3/SystemUtils.java:1187:5:1187:91 | IS_OS_MAC_OSX_JAGUAR |
|
||||
| ../../stubs/apache-commons-lang3-3.7/org/apache/commons/lang3/SystemUtils.java:1199:5:1199:92 | IS_OS_MAC_OSX_PANTHER |
|
||||
| ../../stubs/apache-commons-lang3-3.7/org/apache/commons/lang3/SystemUtils.java:1211:5:1211:90 | IS_OS_MAC_OSX_TIGER |
|
||||
| ../../stubs/apache-commons-lang3-3.7/org/apache/commons/lang3/SystemUtils.java:1223:5:1223:92 | IS_OS_MAC_OSX_LEOPARD |
|
||||
| ../../stubs/apache-commons-lang3-3.7/org/apache/commons/lang3/SystemUtils.java:1235:5:1235:97 | IS_OS_MAC_OSX_SNOW_LEOPARD |
|
||||
| ../../stubs/apache-commons-lang3-3.7/org/apache/commons/lang3/SystemUtils.java:1247:5:1247:89 | IS_OS_MAC_OSX_LION |
|
||||
| ../../stubs/apache-commons-lang3-3.7/org/apache/commons/lang3/SystemUtils.java:1259:5:1259:98 | IS_OS_MAC_OSX_MOUNTAIN_LION |
|
||||
| ../../stubs/apache-commons-lang3-3.7/org/apache/commons/lang3/SystemUtils.java:1271:5:1271:94 | IS_OS_MAC_OSX_MAVERICKS |
|
||||
| ../../stubs/apache-commons-lang3-3.7/org/apache/commons/lang3/SystemUtils.java:1283:5:1283:93 | IS_OS_MAC_OSX_YOSEMITE |
|
||||
| ../../stubs/apache-commons-lang3-3.7/org/apache/commons/lang3/SystemUtils.java:1295:5:1295:95 | IS_OS_MAC_OSX_EL_CAPITAN |
|
||||
| ../../stubs/apache-commons-lang3-3.7/org/apache/commons/lang3/SystemUtils.java:1307:5:1307:91 | IS_OS_MAC_OSX_SIERRA |
|
||||
| ../../stubs/apache-commons-lang3-3.7/org/apache/commons/lang3/SystemUtils.java:1319:5:1319:96 | IS_OS_MAC_OSX_HIGH_SIERRA |
|
||||
| ../../stubs/apache-commons-lang3-3.7/org/apache/commons/lang3/SystemUtils.java:1331:5:1331:91 | IS_OS_MAC_OSX_MOJAVE |
|
||||
| ../../stubs/apache-commons-lang3-3.7/org/apache/commons/lang3/SystemUtils.java:1343:5:1343:93 | IS_OS_MAC_OSX_CATALINA |
|
||||
| ../../stubs/apache-commons-lang3-3.7/org/apache/commons/lang3/SystemUtils.java:1355:5:1355:92 | IS_OS_MAC_OSX_BIG_SUR |
|
||||
| ../../stubs/apache-commons-lang3-3.7/org/apache/commons/lang3/SystemUtils.java:1367:5:1367:85 | IS_OS_FREE_BSD |
|
||||
| ../../stubs/apache-commons-lang3-3.7/org/apache/commons/lang3/SystemUtils.java:1379:5:1379:85 | IS_OS_OPEN_BSD |
|
||||
| ../../stubs/apache-commons-lang3-3.7/org/apache/commons/lang3/SystemUtils.java:1391:5:1391:84 | IS_OS_NET_BSD |
|
||||
| ../../stubs/apache-commons-lang3-3.7/org/apache/commons/lang3/SystemUtils.java:1415:5:1415:84 | IS_OS_SOLARIS |
|
||||
| ../../stubs/apache-commons-lang3-3.7/org/apache/commons/lang3/SystemUtils.java:1427:5:1427:83 | IS_OS_SUN_OS |
|
||||
| ../../stubs/apache-commons-lang3-3.7/org/apache/commons/lang3/SystemUtils.java:1625:5:1625:80 | IS_OS_ZOS |
|
||||
| Test.java:107:13:107:73 | contains(...) |
|
||||
| Test.java:111:13:111:59 | contains(...) |
|
||||
| Test.java:115:13:115:35 | SystemUtils.IS_OS_LINUX |
|
||||
| Test.java:121:14:121:36 | SystemUtils.IS_OS_LINUX |
|
||||
| Test.java:129:13:129:62 | contains(...) |
|
||||
| Test.java:133:14:133:72 | contains(...) |
|
||||
| Test.java:137:14:137:34 | SystemUtils.IS_OS_MAC |
|
||||
| Test.java:143:14:143:45 | SystemUtils.IS_OS_MAC_OSX_MOJAVE |
|
||||
@@ -0,0 +1,5 @@
|
||||
import default
|
||||
import semmle.code.java.os.OSCheck
|
||||
|
||||
from IsSpecificUnixVariant isAnyUnix
|
||||
select isAnyUnix
|
||||
@@ -0,0 +1,14 @@
|
||||
| ../../stubs/apache-commons-lang3-3.7/org/apache/commons/lang3/SystemUtils.java:1463:5:1463:89 | IS_OS_WINDOWS_2000 |
|
||||
| ../../stubs/apache-commons-lang3-3.7/org/apache/commons/lang3/SystemUtils.java:1475:5:1475:89 | IS_OS_WINDOWS_2003 |
|
||||
| ../../stubs/apache-commons-lang3-3.7/org/apache/commons/lang3/SystemUtils.java:1487:5:1487:89 | IS_OS_WINDOWS_2008 |
|
||||
| ../../stubs/apache-commons-lang3-3.7/org/apache/commons/lang3/SystemUtils.java:1499:5:1499:89 | IS_OS_WINDOWS_2012 |
|
||||
| ../../stubs/apache-commons-lang3-3.7/org/apache/commons/lang3/SystemUtils.java:1511:5:1511:87 | IS_OS_WINDOWS_95 |
|
||||
| ../../stubs/apache-commons-lang3-3.7/org/apache/commons/lang3/SystemUtils.java:1523:5:1523:87 | IS_OS_WINDOWS_98 |
|
||||
| ../../stubs/apache-commons-lang3-3.7/org/apache/commons/lang3/SystemUtils.java:1535:5:1535:87 | IS_OS_WINDOWS_ME |
|
||||
| ../../stubs/apache-commons-lang3-3.7/org/apache/commons/lang3/SystemUtils.java:1547:5:1547:87 | IS_OS_WINDOWS_NT |
|
||||
| ../../stubs/apache-commons-lang3-3.7/org/apache/commons/lang3/SystemUtils.java:1559:5:1559:87 | IS_OS_WINDOWS_XP |
|
||||
| ../../stubs/apache-commons-lang3-3.7/org/apache/commons/lang3/SystemUtils.java:1572:5:1572:90 | IS_OS_WINDOWS_VISTA |
|
||||
| ../../stubs/apache-commons-lang3-3.7/org/apache/commons/lang3/SystemUtils.java:1584:5:1584:86 | IS_OS_WINDOWS_7 |
|
||||
| ../../stubs/apache-commons-lang3-3.7/org/apache/commons/lang3/SystemUtils.java:1596:5:1596:86 | IS_OS_WINDOWS_8 |
|
||||
| ../../stubs/apache-commons-lang3-3.7/org/apache/commons/lang3/SystemUtils.java:1608:5:1608:87 | IS_OS_WINDOWS_10 |
|
||||
| Test.java:42:13:42:40 | SystemUtils.IS_OS_WINDOWS_XP |
|
||||
@@ -0,0 +1,5 @@
|
||||
import default
|
||||
import semmle.code.java.os.OSCheck
|
||||
|
||||
from IsSpecificWindowsVariant isAnyWindows
|
||||
select isAnyWindows
|
||||
9
java/ql/test/library-tests/os/unix-test.expected
Normal file
9
java/ql/test/library-tests/os/unix-test.expected
Normal file
@@ -0,0 +1,9 @@
|
||||
| ../../stubs/apache-commons-lang3-3.7/org/apache/commons/lang3/SystemUtils.java:1439:5:1439:81 | IS_OS_UNIX |
|
||||
| Test.java:70:13:70:95 | contains(...) |
|
||||
| Test.java:74:13:74:84 | contains(...) |
|
||||
| Test.java:78:13:78:34 | SystemUtils.IS_OS_UNIX |
|
||||
| Test.java:85:13:85:41 | ... == ... |
|
||||
| Test.java:89:13:89:37 | ... == ... |
|
||||
| Test.java:93:13:93:37 | ... == ... |
|
||||
| Test.java:97:13:97:33 | ... == ... |
|
||||
| Test.java:101:13:101:60 | equals(...) |
|
||||
5
java/ql/test/library-tests/os/unix-test.ql
Normal file
5
java/ql/test/library-tests/os/unix-test.ql
Normal file
@@ -0,0 +1,5 @@
|
||||
import default
|
||||
import semmle.code.java.os.OSCheck
|
||||
|
||||
from IsUnixGuard isUnix
|
||||
select isUnix
|
||||
11
java/ql/test/library-tests/os/windows-test.expected
Normal file
11
java/ql/test/library-tests/os/windows-test.expected
Normal file
@@ -0,0 +1,11 @@
|
||||
| ../../stubs/apache-commons-lang3-3.7/org/apache/commons/lang3/SystemUtils.java:1451:5:1451:84 | IS_OS_WINDOWS |
|
||||
| Test.java:20:13:20:61 | contains(...) |
|
||||
| Test.java:24:13:24:75 | contains(...) |
|
||||
| Test.java:28:13:28:74 | contains(...) |
|
||||
| Test.java:32:13:32:75 | contains(...) |
|
||||
| Test.java:36:13:36:37 | SystemUtils.IS_OS_WINDOWS |
|
||||
| Test.java:48:13:48:41 | ... == ... |
|
||||
| Test.java:52:13:52:37 | ... == ... |
|
||||
| Test.java:56:13:56:38 | ... == ... |
|
||||
| Test.java:60:13:60:34 | ... == ... |
|
||||
| Test.java:64:13:64:60 | equals(...) |
|
||||
5
java/ql/test/library-tests/os/windows-test.ql
Normal file
5
java/ql/test/library-tests/os/windows-test.ql
Normal file
@@ -0,0 +1,5 @@
|
||||
import default
|
||||
import semmle.code.java.os.OSCheck
|
||||
|
||||
from IsWindowsGuard isWindows
|
||||
select isWindows
|
||||
@@ -6,125 +6,152 @@ edges
|
||||
| Files.java:10:33:10:68 | getProperty(...) : String | Files.java:15:17:15:23 | tempDir |
|
||||
| Files.java:14:28:14:64 | new File(...) : File | Files.java:15:17:15:23 | tempDir |
|
||||
| Files.java:14:37:14:43 | baseDir : File | Files.java:14:28:14:64 | new File(...) : File |
|
||||
| Test.java:34:24:34:69 | new File(...) : File | Test.java:37:63:37:69 | tempDir |
|
||||
| Test.java:34:33:34:68 | getProperty(...) : String | Test.java:34:24:34:69 | new File(...) : File |
|
||||
| Test.java:34:33:34:68 | getProperty(...) : String | Test.java:37:63:37:69 | tempDir |
|
||||
| Test.java:48:29:48:94 | new File(...) : File | Test.java:51:63:51:74 | tempDirChild |
|
||||
| Test.java:48:38:48:83 | new File(...) : File | Test.java:48:29:48:94 | new File(...) : File |
|
||||
| Test.java:48:38:48:83 | new File(...) : File | Test.java:51:63:51:74 | tempDirChild |
|
||||
| Test.java:48:47:48:82 | getProperty(...) : String | Test.java:48:38:48:83 | new File(...) : File |
|
||||
| Test.java:48:47:48:82 | getProperty(...) : String | Test.java:51:63:51:74 | tempDirChild |
|
||||
| Test.java:59:24:59:69 | new File(...) : File | Test.java:62:63:62:69 | tempDir |
|
||||
| Test.java:59:33:59:68 | getProperty(...) : String | Test.java:59:24:59:69 | new File(...) : File |
|
||||
| Test.java:59:33:59:68 | getProperty(...) : String | Test.java:62:63:62:69 | tempDir |
|
||||
| Test.java:73:24:73:69 | new File(...) : File | Test.java:76:63:76:69 | tempDir |
|
||||
| Test.java:73:33:73:68 | getProperty(...) : String | Test.java:73:24:73:69 | new File(...) : File |
|
||||
| Test.java:73:33:73:68 | getProperty(...) : String | Test.java:76:63:76:69 | tempDir |
|
||||
| Test.java:108:29:108:84 | new File(...) : File | Test.java:111:9:111:20 | tempDirChild |
|
||||
| Test.java:108:38:108:73 | getProperty(...) : String | Test.java:108:29:108:84 | new File(...) : File |
|
||||
| Test.java:108:38:108:73 | getProperty(...) : String | Test.java:111:9:111:20 | tempDirChild |
|
||||
| Test.java:132:29:132:84 | new File(...) : File | Test.java:135:9:135:20 | tempDirChild |
|
||||
| Test.java:132:38:132:73 | getProperty(...) : String | Test.java:132:29:132:84 | new File(...) : File |
|
||||
| Test.java:132:38:132:73 | getProperty(...) : String | Test.java:135:9:135:20 | tempDirChild |
|
||||
| Test.java:156:29:156:88 | new File(...) : File | Test.java:157:21:157:32 | tempDirChild : File |
|
||||
| Test.java:156:38:156:73 | getProperty(...) : String | Test.java:156:29:156:88 | new File(...) : File |
|
||||
| Test.java:156:38:156:73 | getProperty(...) : String | Test.java:157:21:157:32 | tempDirChild : File |
|
||||
| Test.java:157:21:157:32 | tempDirChild : File | Test.java:157:21:157:41 | toPath(...) |
|
||||
| Test.java:185:29:185:88 | new File(...) : File | Test.java:186:21:186:32 | tempDirChild : File |
|
||||
| Test.java:185:38:185:73 | getProperty(...) : String | Test.java:185:29:185:88 | new File(...) : File |
|
||||
| Test.java:185:38:185:73 | getProperty(...) : String | Test.java:186:21:186:32 | tempDirChild : File |
|
||||
| Test.java:186:21:186:32 | tempDirChild : File | Test.java:186:21:186:41 | toPath(...) |
|
||||
| Test.java:202:29:202:104 | new File(...) : File | Test.java:202:29:202:113 | toPath(...) : Path |
|
||||
| Test.java:202:29:202:113 | toPath(...) : Path | Test.java:205:33:205:44 | tempDirChild |
|
||||
| Test.java:202:38:202:73 | getProperty(...) : String | Test.java:202:29:202:104 | new File(...) : File |
|
||||
| Test.java:214:29:214:102 | new File(...) : File | Test.java:214:29:214:111 | toPath(...) : Path |
|
||||
| Test.java:214:29:214:111 | toPath(...) : Path | Test.java:217:31:217:42 | tempDirChild |
|
||||
| Test.java:214:38:214:73 | getProperty(...) : String | Test.java:214:29:214:102 | new File(...) : File |
|
||||
| Test.java:226:29:226:100 | new File(...) : File | Test.java:229:26:229:37 | tempDirChild : File |
|
||||
| Test.java:226:38:226:73 | getProperty(...) : String | Test.java:226:29:226:100 | new File(...) : File |
|
||||
| Test.java:226:38:226:73 | getProperty(...) : String | Test.java:229:26:229:37 | tempDirChild : File |
|
||||
| Test.java:229:26:229:37 | tempDirChild : File | Test.java:229:26:229:46 | toPath(...) |
|
||||
| Test.java:247:29:247:101 | new File(...) : File | Test.java:250:31:250:42 | tempDirChild : File |
|
||||
| Test.java:247:38:247:73 | getProperty(...) : String | Test.java:247:29:247:101 | new File(...) : File |
|
||||
| Test.java:247:38:247:73 | getProperty(...) : String | Test.java:250:31:250:42 | tempDirChild : File |
|
||||
| Test.java:250:31:250:42 | tempDirChild : File | Test.java:250:31:250:51 | toPath(...) |
|
||||
| Test.java:258:29:258:109 | new File(...) : File | Test.java:261:33:261:44 | tempDirChild : File |
|
||||
| Test.java:258:38:258:73 | getProperty(...) : String | Test.java:258:29:258:109 | new File(...) : File |
|
||||
| Test.java:258:38:258:73 | getProperty(...) : String | Test.java:261:33:261:44 | tempDirChild : File |
|
||||
| Test.java:261:33:261:44 | tempDirChild : File | Test.java:261:33:261:53 | toPath(...) |
|
||||
| Test.java:36:24:36:69 | new File(...) : File | Test.java:39:63:39:69 | tempDir |
|
||||
| Test.java:36:33:36:68 | getProperty(...) : String | Test.java:36:24:36:69 | new File(...) : File |
|
||||
| Test.java:36:33:36:68 | getProperty(...) : String | Test.java:39:63:39:69 | tempDir |
|
||||
| Test.java:50:29:50:94 | new File(...) : File | Test.java:53:63:53:74 | tempDirChild |
|
||||
| Test.java:50:38:50:83 | new File(...) : File | Test.java:50:29:50:94 | new File(...) : File |
|
||||
| Test.java:50:38:50:83 | new File(...) : File | Test.java:53:63:53:74 | tempDirChild |
|
||||
| Test.java:50:47:50:82 | getProperty(...) : String | Test.java:50:38:50:83 | new File(...) : File |
|
||||
| Test.java:50:47:50:82 | getProperty(...) : String | Test.java:53:63:53:74 | tempDirChild |
|
||||
| Test.java:61:24:61:69 | new File(...) : File | Test.java:64:63:64:69 | tempDir |
|
||||
| Test.java:61:33:61:68 | getProperty(...) : String | Test.java:61:24:61:69 | new File(...) : File |
|
||||
| Test.java:61:33:61:68 | getProperty(...) : String | Test.java:64:63:64:69 | tempDir |
|
||||
| Test.java:75:24:75:69 | new File(...) : File | Test.java:78:63:78:69 | tempDir |
|
||||
| Test.java:75:33:75:68 | getProperty(...) : String | Test.java:75:24:75:69 | new File(...) : File |
|
||||
| Test.java:75:33:75:68 | getProperty(...) : String | Test.java:78:63:78:69 | tempDir |
|
||||
| Test.java:110:29:110:84 | new File(...) : File | Test.java:113:9:113:20 | tempDirChild |
|
||||
| Test.java:110:38:110:73 | getProperty(...) : String | Test.java:110:29:110:84 | new File(...) : File |
|
||||
| Test.java:110:38:110:73 | getProperty(...) : String | Test.java:113:9:113:20 | tempDirChild |
|
||||
| Test.java:134:29:134:84 | new File(...) : File | Test.java:137:9:137:20 | tempDirChild |
|
||||
| Test.java:134:38:134:73 | getProperty(...) : String | Test.java:134:29:134:84 | new File(...) : File |
|
||||
| Test.java:134:38:134:73 | getProperty(...) : String | Test.java:137:9:137:20 | tempDirChild |
|
||||
| Test.java:158:29:158:88 | new File(...) : File | Test.java:159:21:159:32 | tempDirChild : File |
|
||||
| Test.java:158:38:158:73 | getProperty(...) : String | Test.java:158:29:158:88 | new File(...) : File |
|
||||
| Test.java:158:38:158:73 | getProperty(...) : String | Test.java:159:21:159:32 | tempDirChild : File |
|
||||
| Test.java:159:21:159:32 | tempDirChild : File | Test.java:159:21:159:41 | toPath(...) |
|
||||
| Test.java:187:29:187:88 | new File(...) : File | Test.java:188:21:188:32 | tempDirChild : File |
|
||||
| Test.java:187:38:187:73 | getProperty(...) : String | Test.java:187:29:187:88 | new File(...) : File |
|
||||
| Test.java:187:38:187:73 | getProperty(...) : String | Test.java:188:21:188:32 | tempDirChild : File |
|
||||
| Test.java:188:21:188:32 | tempDirChild : File | Test.java:188:21:188:41 | toPath(...) |
|
||||
| Test.java:204:29:204:104 | new File(...) : File | Test.java:204:29:204:113 | toPath(...) : Path |
|
||||
| Test.java:204:29:204:113 | toPath(...) : Path | Test.java:207:33:207:44 | tempDirChild |
|
||||
| Test.java:204:38:204:73 | getProperty(...) : String | Test.java:204:29:204:104 | new File(...) : File |
|
||||
| Test.java:216:29:216:102 | new File(...) : File | Test.java:216:29:216:111 | toPath(...) : Path |
|
||||
| Test.java:216:29:216:111 | toPath(...) : Path | Test.java:219:31:219:42 | tempDirChild |
|
||||
| Test.java:216:38:216:73 | getProperty(...) : String | Test.java:216:29:216:102 | new File(...) : File |
|
||||
| Test.java:228:29:228:100 | new File(...) : File | Test.java:231:26:231:37 | tempDirChild : File |
|
||||
| Test.java:228:38:228:73 | getProperty(...) : String | Test.java:228:29:228:100 | new File(...) : File |
|
||||
| Test.java:228:38:228:73 | getProperty(...) : String | Test.java:231:26:231:37 | tempDirChild : File |
|
||||
| Test.java:231:26:231:37 | tempDirChild : File | Test.java:231:26:231:46 | toPath(...) |
|
||||
| Test.java:249:29:249:101 | new File(...) : File | Test.java:252:31:252:42 | tempDirChild : File |
|
||||
| Test.java:249:38:249:73 | getProperty(...) : String | Test.java:249:29:249:101 | new File(...) : File |
|
||||
| Test.java:249:38:249:73 | getProperty(...) : String | Test.java:252:31:252:42 | tempDirChild : File |
|
||||
| Test.java:252:31:252:42 | tempDirChild : File | Test.java:252:31:252:51 | toPath(...) |
|
||||
| Test.java:260:29:260:109 | new File(...) : File | Test.java:263:33:263:44 | tempDirChild : File |
|
||||
| Test.java:260:38:260:73 | getProperty(...) : String | Test.java:260:29:260:109 | new File(...) : File |
|
||||
| Test.java:260:38:260:73 | getProperty(...) : String | Test.java:263:33:263:44 | tempDirChild : File |
|
||||
| Test.java:263:33:263:44 | tempDirChild : File | Test.java:263:33:263:53 | toPath(...) |
|
||||
| Test.java:294:29:294:101 | new File(...) : File | Test.java:298:35:298:46 | tempDirChild : File |
|
||||
| Test.java:294:38:294:73 | getProperty(...) : String | Test.java:294:29:294:101 | new File(...) : File |
|
||||
| Test.java:294:38:294:73 | getProperty(...) : String | Test.java:298:35:298:46 | tempDirChild : File |
|
||||
| Test.java:298:35:298:46 | tempDirChild : File | Test.java:298:35:298:55 | toPath(...) |
|
||||
| Test.java:313:29:313:101 | new File(...) : File | Test.java:316:35:316:46 | tempDirChild : File |
|
||||
| Test.java:313:38:313:73 | getProperty(...) : String | Test.java:313:29:313:101 | new File(...) : File |
|
||||
| Test.java:313:38:313:73 | getProperty(...) : String | Test.java:316:35:316:46 | tempDirChild : File |
|
||||
| Test.java:316:35:316:46 | tempDirChild : File | Test.java:316:35:316:55 | toPath(...) |
|
||||
| Test.java:322:29:322:101 | new File(...) : File | Test.java:326:35:326:46 | tempDirChild : File |
|
||||
| Test.java:322:38:322:73 | getProperty(...) : String | Test.java:322:29:322:101 | new File(...) : File |
|
||||
| Test.java:322:38:322:73 | getProperty(...) : String | Test.java:326:35:326:46 | tempDirChild : File |
|
||||
| Test.java:326:35:326:46 | tempDirChild : File | Test.java:326:35:326:55 | toPath(...) |
|
||||
nodes
|
||||
| Files.java:10:24:10:69 | new File(...) : File | semmle.label | new File(...) : File |
|
||||
| Files.java:10:33:10:68 | getProperty(...) : String | semmle.label | getProperty(...) : String |
|
||||
| Files.java:14:28:14:64 | new File(...) : File | semmle.label | new File(...) : File |
|
||||
| Files.java:14:37:14:43 | baseDir : File | semmle.label | baseDir : File |
|
||||
| Files.java:15:17:15:23 | tempDir | semmle.label | tempDir |
|
||||
| Test.java:18:25:18:61 | createTempFile(...) | semmle.label | createTempFile(...) |
|
||||
| Test.java:26:25:26:67 | createTempFile(...) | semmle.label | createTempFile(...) |
|
||||
| Test.java:34:24:34:69 | new File(...) : File | semmle.label | new File(...) : File |
|
||||
| Test.java:34:33:34:68 | getProperty(...) : String | semmle.label | getProperty(...) : String |
|
||||
| Test.java:37:63:37:69 | tempDir | semmle.label | tempDir |
|
||||
| Test.java:48:29:48:94 | new File(...) : File | semmle.label | new File(...) : File |
|
||||
| Test.java:48:38:48:83 | new File(...) : File | semmle.label | new File(...) : File |
|
||||
| Test.java:48:47:48:82 | getProperty(...) : String | semmle.label | getProperty(...) : String |
|
||||
| Test.java:51:63:51:74 | tempDirChild | semmle.label | tempDirChild |
|
||||
| Test.java:59:24:59:69 | new File(...) : File | semmle.label | new File(...) : File |
|
||||
| Test.java:59:33:59:68 | getProperty(...) : String | semmle.label | getProperty(...) : String |
|
||||
| Test.java:62:63:62:69 | tempDir | semmle.label | tempDir |
|
||||
| Test.java:73:24:73:69 | new File(...) : File | semmle.label | new File(...) : File |
|
||||
| Test.java:73:33:73:68 | getProperty(...) : String | semmle.label | getProperty(...) : String |
|
||||
| Test.java:76:63:76:69 | tempDir | semmle.label | tempDir |
|
||||
| Test.java:95:24:95:65 | createTempDir(...) | semmle.label | createTempDir(...) |
|
||||
| Test.java:108:29:108:84 | new File(...) : File | semmle.label | new File(...) : File |
|
||||
| Test.java:108:38:108:73 | getProperty(...) : String | semmle.label | getProperty(...) : String |
|
||||
| Test.java:111:9:111:20 | tempDirChild | semmle.label | tempDirChild |
|
||||
| Test.java:132:29:132:84 | new File(...) : File | semmle.label | new File(...) : File |
|
||||
| Test.java:132:38:132:73 | getProperty(...) : String | semmle.label | getProperty(...) : String |
|
||||
| Test.java:135:9:135:20 | tempDirChild | semmle.label | tempDirChild |
|
||||
| Test.java:156:29:156:88 | new File(...) : File | semmle.label | new File(...) : File |
|
||||
| Test.java:156:38:156:73 | getProperty(...) : String | semmle.label | getProperty(...) : String |
|
||||
| Test.java:157:21:157:32 | tempDirChild : File | semmle.label | tempDirChild : File |
|
||||
| Test.java:157:21:157:41 | toPath(...) | semmle.label | toPath(...) |
|
||||
| Test.java:185:29:185:88 | new File(...) : File | semmle.label | new File(...) : File |
|
||||
| Test.java:185:38:185:73 | getProperty(...) : String | semmle.label | getProperty(...) : String |
|
||||
| Test.java:186:21:186:32 | tempDirChild : File | semmle.label | tempDirChild : File |
|
||||
| Test.java:186:21:186:41 | toPath(...) | semmle.label | toPath(...) |
|
||||
| Test.java:202:29:202:104 | new File(...) : File | semmle.label | new File(...) : File |
|
||||
| Test.java:202:29:202:113 | toPath(...) : Path | semmle.label | toPath(...) : Path |
|
||||
| Test.java:202:38:202:73 | getProperty(...) : String | semmle.label | getProperty(...) : String |
|
||||
| Test.java:205:33:205:44 | tempDirChild | semmle.label | tempDirChild |
|
||||
| Test.java:214:29:214:102 | new File(...) : File | semmle.label | new File(...) : File |
|
||||
| Test.java:214:29:214:111 | toPath(...) : Path | semmle.label | toPath(...) : Path |
|
||||
| Test.java:214:38:214:73 | getProperty(...) : String | semmle.label | getProperty(...) : String |
|
||||
| Test.java:217:31:217:42 | tempDirChild | semmle.label | tempDirChild |
|
||||
| Test.java:226:29:226:100 | new File(...) : File | semmle.label | new File(...) : File |
|
||||
| Test.java:226:38:226:73 | getProperty(...) : String | semmle.label | getProperty(...) : String |
|
||||
| Test.java:229:26:229:37 | tempDirChild : File | semmle.label | tempDirChild : File |
|
||||
| Test.java:229:26:229:46 | toPath(...) | semmle.label | toPath(...) |
|
||||
| Test.java:247:29:247:101 | new File(...) : File | semmle.label | new File(...) : File |
|
||||
| Test.java:247:38:247:73 | getProperty(...) : String | semmle.label | getProperty(...) : String |
|
||||
| Test.java:250:31:250:42 | tempDirChild : File | semmle.label | tempDirChild : File |
|
||||
| Test.java:250:31:250:51 | toPath(...) | semmle.label | toPath(...) |
|
||||
| Test.java:258:29:258:109 | new File(...) : File | semmle.label | new File(...) : File |
|
||||
| Test.java:258:38:258:73 | getProperty(...) : String | semmle.label | getProperty(...) : String |
|
||||
| Test.java:261:33:261:44 | tempDirChild : File | semmle.label | tempDirChild : File |
|
||||
| Test.java:261:33:261:53 | toPath(...) | semmle.label | toPath(...) |
|
||||
| Test.java:268:25:268:63 | createTempFile(...) | semmle.label | createTempFile(...) |
|
||||
| Test.java:20:25:20:61 | createTempFile(...) | semmle.label | createTempFile(...) |
|
||||
| Test.java:28:25:28:67 | createTempFile(...) | semmle.label | createTempFile(...) |
|
||||
| Test.java:36:24:36:69 | new File(...) : File | semmle.label | new File(...) : File |
|
||||
| Test.java:36:33:36:68 | getProperty(...) : String | semmle.label | getProperty(...) : String |
|
||||
| Test.java:39:63:39:69 | tempDir | semmle.label | tempDir |
|
||||
| Test.java:50:29:50:94 | new File(...) : File | semmle.label | new File(...) : File |
|
||||
| Test.java:50:38:50:83 | new File(...) : File | semmle.label | new File(...) : File |
|
||||
| Test.java:50:47:50:82 | getProperty(...) : String | semmle.label | getProperty(...) : String |
|
||||
| Test.java:53:63:53:74 | tempDirChild | semmle.label | tempDirChild |
|
||||
| Test.java:61:24:61:69 | new File(...) : File | semmle.label | new File(...) : File |
|
||||
| Test.java:61:33:61:68 | getProperty(...) : String | semmle.label | getProperty(...) : String |
|
||||
| Test.java:64:63:64:69 | tempDir | semmle.label | tempDir |
|
||||
| Test.java:75:24:75:69 | new File(...) : File | semmle.label | new File(...) : File |
|
||||
| Test.java:75:33:75:68 | getProperty(...) : String | semmle.label | getProperty(...) : String |
|
||||
| Test.java:78:63:78:69 | tempDir | semmle.label | tempDir |
|
||||
| Test.java:97:24:97:65 | createTempDir(...) | semmle.label | createTempDir(...) |
|
||||
| Test.java:110:29:110:84 | new File(...) : File | semmle.label | new File(...) : File |
|
||||
| Test.java:110:38:110:73 | getProperty(...) : String | semmle.label | getProperty(...) : String |
|
||||
| Test.java:113:9:113:20 | tempDirChild | semmle.label | tempDirChild |
|
||||
| Test.java:134:29:134:84 | new File(...) : File | semmle.label | new File(...) : File |
|
||||
| Test.java:134:38:134:73 | getProperty(...) : String | semmle.label | getProperty(...) : String |
|
||||
| Test.java:137:9:137:20 | tempDirChild | semmle.label | tempDirChild |
|
||||
| Test.java:158:29:158:88 | new File(...) : File | semmle.label | new File(...) : File |
|
||||
| Test.java:158:38:158:73 | getProperty(...) : String | semmle.label | getProperty(...) : String |
|
||||
| Test.java:159:21:159:32 | tempDirChild : File | semmle.label | tempDirChild : File |
|
||||
| Test.java:159:21:159:41 | toPath(...) | semmle.label | toPath(...) |
|
||||
| Test.java:187:29:187:88 | new File(...) : File | semmle.label | new File(...) : File |
|
||||
| Test.java:187:38:187:73 | getProperty(...) : String | semmle.label | getProperty(...) : String |
|
||||
| Test.java:188:21:188:32 | tempDirChild : File | semmle.label | tempDirChild : File |
|
||||
| Test.java:188:21:188:41 | toPath(...) | semmle.label | toPath(...) |
|
||||
| Test.java:204:29:204:104 | new File(...) : File | semmle.label | new File(...) : File |
|
||||
| Test.java:204:29:204:113 | toPath(...) : Path | semmle.label | toPath(...) : Path |
|
||||
| Test.java:204:38:204:73 | getProperty(...) : String | semmle.label | getProperty(...) : String |
|
||||
| Test.java:207:33:207:44 | tempDirChild | semmle.label | tempDirChild |
|
||||
| Test.java:216:29:216:102 | new File(...) : File | semmle.label | new File(...) : File |
|
||||
| Test.java:216:29:216:111 | toPath(...) : Path | semmle.label | toPath(...) : Path |
|
||||
| Test.java:216:38:216:73 | getProperty(...) : String | semmle.label | getProperty(...) : String |
|
||||
| Test.java:219:31:219:42 | tempDirChild | semmle.label | tempDirChild |
|
||||
| Test.java:228:29:228:100 | new File(...) : File | semmle.label | new File(...) : File |
|
||||
| Test.java:228:38:228:73 | getProperty(...) : String | semmle.label | getProperty(...) : String |
|
||||
| Test.java:231:26:231:37 | tempDirChild : File | semmle.label | tempDirChild : File |
|
||||
| Test.java:231:26:231:46 | toPath(...) | semmle.label | toPath(...) |
|
||||
| Test.java:249:29:249:101 | new File(...) : File | semmle.label | new File(...) : File |
|
||||
| Test.java:249:38:249:73 | getProperty(...) : String | semmle.label | getProperty(...) : String |
|
||||
| Test.java:252:31:252:42 | tempDirChild : File | semmle.label | tempDirChild : File |
|
||||
| Test.java:252:31:252:51 | toPath(...) | semmle.label | toPath(...) |
|
||||
| Test.java:260:29:260:109 | new File(...) : File | semmle.label | new File(...) : File |
|
||||
| Test.java:260:38:260:73 | getProperty(...) : String | semmle.label | getProperty(...) : String |
|
||||
| Test.java:263:33:263:44 | tempDirChild : File | semmle.label | tempDirChild : File |
|
||||
| Test.java:263:33:263:53 | toPath(...) | semmle.label | toPath(...) |
|
||||
| Test.java:270:25:270:63 | createTempFile(...) | semmle.label | createTempFile(...) |
|
||||
| Test.java:294:29:294:101 | new File(...) : File | semmle.label | new File(...) : File |
|
||||
| Test.java:294:38:294:73 | getProperty(...) : String | semmle.label | getProperty(...) : String |
|
||||
| Test.java:298:35:298:46 | tempDirChild : File | semmle.label | tempDirChild : File |
|
||||
| Test.java:298:35:298:55 | toPath(...) | semmle.label | toPath(...) |
|
||||
| Test.java:313:29:313:101 | new File(...) : File | semmle.label | new File(...) : File |
|
||||
| Test.java:313:38:313:73 | getProperty(...) : String | semmle.label | getProperty(...) : String |
|
||||
| Test.java:316:35:316:46 | tempDirChild : File | semmle.label | tempDirChild : File |
|
||||
| Test.java:316:35:316:55 | toPath(...) | semmle.label | toPath(...) |
|
||||
| Test.java:322:29:322:101 | new File(...) : File | semmle.label | new File(...) : File |
|
||||
| Test.java:322:38:322:73 | getProperty(...) : String | semmle.label | getProperty(...) : String |
|
||||
| Test.java:326:35:326:46 | tempDirChild : File | semmle.label | tempDirChild : File |
|
||||
| Test.java:326:35:326:55 | toPath(...) | semmle.label | toPath(...) |
|
||||
subpaths
|
||||
#select
|
||||
| Files.java:10:33:10:68 | getProperty(...) | Files.java:10:33:10:68 | getProperty(...) : String | Files.java:15:17:15:23 | tempDir | Local information disclosure vulnerability from $@ due to use of file or directory readable by other local users. | Files.java:10:33:10:68 | getProperty(...) | system temp directory |
|
||||
| Test.java:18:25:18:61 | createTempFile(...) | Test.java:18:25:18:61 | createTempFile(...) | Test.java:18:25:18:61 | createTempFile(...) | Local information disclosure vulnerability due to use of file readable by other local users. | Test.java:18:25:18:61 | createTempFile(...) | system temp directory |
|
||||
| Test.java:26:25:26:67 | createTempFile(...) | Test.java:26:25:26:67 | createTempFile(...) | Test.java:26:25:26:67 | createTempFile(...) | Local information disclosure vulnerability due to use of file readable by other local users. | Test.java:26:25:26:67 | createTempFile(...) | system temp directory |
|
||||
| Test.java:34:33:34:68 | getProperty(...) | Test.java:34:33:34:68 | getProperty(...) : String | Test.java:37:63:37:69 | tempDir | Local information disclosure vulnerability from $@ due to use of file or directory readable by other local users. | Test.java:34:33:34:68 | getProperty(...) | system temp directory |
|
||||
| Test.java:48:47:48:82 | getProperty(...) | Test.java:48:47:48:82 | getProperty(...) : String | Test.java:51:63:51:74 | tempDirChild | Local information disclosure vulnerability from $@ due to use of file or directory readable by other local users. | Test.java:48:47:48:82 | getProperty(...) | system temp directory |
|
||||
| Test.java:59:33:59:68 | getProperty(...) | Test.java:59:33:59:68 | getProperty(...) : String | Test.java:62:63:62:69 | tempDir | Local information disclosure vulnerability from $@ due to use of file or directory readable by other local users. | Test.java:59:33:59:68 | getProperty(...) | system temp directory |
|
||||
| Test.java:73:33:73:68 | getProperty(...) | Test.java:73:33:73:68 | getProperty(...) : String | Test.java:76:63:76:69 | tempDir | Local information disclosure vulnerability from $@ due to use of file or directory readable by other local users. | Test.java:73:33:73:68 | getProperty(...) | system temp directory |
|
||||
| Test.java:95:24:95:65 | createTempDir(...) | Test.java:95:24:95:65 | createTempDir(...) | Test.java:95:24:95:65 | createTempDir(...) | Local information disclosure vulnerability due to use of directory readable by other local users. | Test.java:95:24:95:65 | createTempDir(...) | system temp directory |
|
||||
| Test.java:108:38:108:73 | getProperty(...) | Test.java:108:38:108:73 | getProperty(...) : String | Test.java:111:9:111:20 | tempDirChild | Local information disclosure vulnerability from $@ due to use of file or directory readable by other local users. | Test.java:108:38:108:73 | getProperty(...) | system temp directory |
|
||||
| Test.java:132:38:132:73 | getProperty(...) | Test.java:132:38:132:73 | getProperty(...) : String | Test.java:135:9:135:20 | tempDirChild | Local information disclosure vulnerability from $@ due to use of file or directory readable by other local users. | Test.java:132:38:132:73 | getProperty(...) | system temp directory |
|
||||
| Test.java:156:38:156:73 | getProperty(...) | Test.java:156:38:156:73 | getProperty(...) : String | Test.java:157:21:157:41 | toPath(...) | Local information disclosure vulnerability from $@ due to use of file or directory readable by other local users. | Test.java:156:38:156:73 | getProperty(...) | system temp directory |
|
||||
| Test.java:185:38:185:73 | getProperty(...) | Test.java:185:38:185:73 | getProperty(...) : String | Test.java:186:21:186:41 | toPath(...) | Local information disclosure vulnerability from $@ due to use of file or directory readable by other local users. | Test.java:185:38:185:73 | getProperty(...) | system temp directory |
|
||||
| Test.java:202:38:202:73 | getProperty(...) | Test.java:202:38:202:73 | getProperty(...) : String | Test.java:205:33:205:44 | tempDirChild | Local information disclosure vulnerability from $@ due to use of file or directory readable by other local users. | Test.java:202:38:202:73 | getProperty(...) | system temp directory |
|
||||
| Test.java:214:38:214:73 | getProperty(...) | Test.java:214:38:214:73 | getProperty(...) : String | Test.java:217:31:217:42 | tempDirChild | Local information disclosure vulnerability from $@ due to use of file or directory readable by other local users. | Test.java:214:38:214:73 | getProperty(...) | system temp directory |
|
||||
| Test.java:226:38:226:73 | getProperty(...) | Test.java:226:38:226:73 | getProperty(...) : String | Test.java:229:26:229:46 | toPath(...) | Local information disclosure vulnerability from $@ due to use of file or directory readable by other local users. | Test.java:226:38:226:73 | getProperty(...) | system temp directory |
|
||||
| Test.java:247:38:247:73 | getProperty(...) | Test.java:247:38:247:73 | getProperty(...) : String | Test.java:250:31:250:51 | toPath(...) | Local information disclosure vulnerability from $@ due to use of file or directory readable by other local users. | Test.java:247:38:247:73 | getProperty(...) | system temp directory |
|
||||
| Test.java:258:38:258:73 | getProperty(...) | Test.java:258:38:258:73 | getProperty(...) : String | Test.java:261:33:261:53 | toPath(...) | Local information disclosure vulnerability from $@ due to use of file or directory readable by other local users. | Test.java:258:38:258:73 | getProperty(...) | system temp directory |
|
||||
| Test.java:20:25:20:61 | createTempFile(...) | Test.java:20:25:20:61 | createTempFile(...) | Test.java:20:25:20:61 | createTempFile(...) | Local information disclosure vulnerability due to use of file readable by other local users. | Test.java:20:25:20:61 | createTempFile(...) | system temp directory |
|
||||
| Test.java:28:25:28:67 | createTempFile(...) | Test.java:28:25:28:67 | createTempFile(...) | Test.java:28:25:28:67 | createTempFile(...) | Local information disclosure vulnerability due to use of file readable by other local users. | Test.java:28:25:28:67 | createTempFile(...) | system temp directory |
|
||||
| Test.java:36:33:36:68 | getProperty(...) | Test.java:36:33:36:68 | getProperty(...) : String | Test.java:39:63:39:69 | tempDir | Local information disclosure vulnerability from $@ due to use of file or directory readable by other local users. | Test.java:36:33:36:68 | getProperty(...) | system temp directory |
|
||||
| Test.java:50:47:50:82 | getProperty(...) | Test.java:50:47:50:82 | getProperty(...) : String | Test.java:53:63:53:74 | tempDirChild | Local information disclosure vulnerability from $@ due to use of file or directory readable by other local users. | Test.java:50:47:50:82 | getProperty(...) | system temp directory |
|
||||
| Test.java:61:33:61:68 | getProperty(...) | Test.java:61:33:61:68 | getProperty(...) : String | Test.java:64:63:64:69 | tempDir | Local information disclosure vulnerability from $@ due to use of file or directory readable by other local users. | Test.java:61:33:61:68 | getProperty(...) | system temp directory |
|
||||
| Test.java:75:33:75:68 | getProperty(...) | Test.java:75:33:75:68 | getProperty(...) : String | Test.java:78:63:78:69 | tempDir | Local information disclosure vulnerability from $@ due to use of file or directory readable by other local users. | Test.java:75:33:75:68 | getProperty(...) | system temp directory |
|
||||
| Test.java:97:24:97:65 | createTempDir(...) | Test.java:97:24:97:65 | createTempDir(...) | Test.java:97:24:97:65 | createTempDir(...) | Local information disclosure vulnerability due to use of directory readable by other local users. | Test.java:97:24:97:65 | createTempDir(...) | system temp directory |
|
||||
| Test.java:110:38:110:73 | getProperty(...) | Test.java:110:38:110:73 | getProperty(...) : String | Test.java:113:9:113:20 | tempDirChild | Local information disclosure vulnerability from $@ due to use of file or directory readable by other local users. | Test.java:110:38:110:73 | getProperty(...) | system temp directory |
|
||||
| Test.java:134:38:134:73 | getProperty(...) | Test.java:134:38:134:73 | getProperty(...) : String | Test.java:137:9:137:20 | tempDirChild | Local information disclosure vulnerability from $@ due to use of file or directory readable by other local users. | Test.java:134:38:134:73 | getProperty(...) | system temp directory |
|
||||
| Test.java:158:38:158:73 | getProperty(...) | Test.java:158:38:158:73 | getProperty(...) : String | Test.java:159:21:159:41 | toPath(...) | Local information disclosure vulnerability from $@ due to use of file or directory readable by other local users. | Test.java:158:38:158:73 | getProperty(...) | system temp directory |
|
||||
| Test.java:187:38:187:73 | getProperty(...) | Test.java:187:38:187:73 | getProperty(...) : String | Test.java:188:21:188:41 | toPath(...) | Local information disclosure vulnerability from $@ due to use of file or directory readable by other local users. | Test.java:187:38:187:73 | getProperty(...) | system temp directory |
|
||||
| Test.java:204:38:204:73 | getProperty(...) | Test.java:204:38:204:73 | getProperty(...) : String | Test.java:207:33:207:44 | tempDirChild | Local information disclosure vulnerability from $@ due to use of file or directory readable by other local users. | Test.java:204:38:204:73 | getProperty(...) | system temp directory |
|
||||
| Test.java:216:38:216:73 | getProperty(...) | Test.java:216:38:216:73 | getProperty(...) : String | Test.java:219:31:219:42 | tempDirChild | Local information disclosure vulnerability from $@ due to use of file or directory readable by other local users. | Test.java:216:38:216:73 | getProperty(...) | system temp directory |
|
||||
| Test.java:228:38:228:73 | getProperty(...) | Test.java:228:38:228:73 | getProperty(...) : String | Test.java:231:26:231:46 | toPath(...) | Local information disclosure vulnerability from $@ due to use of file or directory readable by other local users. | Test.java:228:38:228:73 | getProperty(...) | system temp directory |
|
||||
| Test.java:249:38:249:73 | getProperty(...) | Test.java:249:38:249:73 | getProperty(...) : String | Test.java:252:31:252:51 | toPath(...) | Local information disclosure vulnerability from $@ due to use of file or directory readable by other local users. | Test.java:249:38:249:73 | getProperty(...) | system temp directory |
|
||||
| Test.java:260:38:260:73 | getProperty(...) | Test.java:260:38:260:73 | getProperty(...) : String | Test.java:263:33:263:53 | toPath(...) | Local information disclosure vulnerability from $@ due to use of file or directory readable by other local users. | Test.java:260:38:260:73 | getProperty(...) | system temp directory |
|
||||
| Test.java:294:38:294:73 | getProperty(...) | Test.java:294:38:294:73 | getProperty(...) : String | Test.java:298:35:298:55 | toPath(...) | Local information disclosure vulnerability from $@ due to use of file or directory readable by other local users. | Test.java:294:38:294:73 | getProperty(...) | system temp directory |
|
||||
| Test.java:313:38:313:73 | getProperty(...) | Test.java:313:38:313:73 | getProperty(...) : String | Test.java:316:35:316:55 | toPath(...) | Local information disclosure vulnerability from $@ due to use of file or directory readable by other local users. | Test.java:313:38:313:73 | getProperty(...) | system temp directory |
|
||||
| Test.java:322:38:322:73 | getProperty(...) | Test.java:322:38:322:73 | getProperty(...) : String | Test.java:326:35:326:55 | toPath(...) | Local information disclosure vulnerability from $@ due to use of file or directory readable by other local users. | Test.java:322:38:322:73 | getProperty(...) | system temp directory |
|
||||
|
||||
@@ -11,6 +11,8 @@ import java.nio.file.attribute.PosixFilePermission;
|
||||
import java.nio.file.attribute.PosixFilePermissions;
|
||||
import java.util.EnumSet;
|
||||
|
||||
import org.apache.commons.lang3.SystemUtils;
|
||||
|
||||
public class Test {
|
||||
|
||||
void vulnerableFileCreateTempFile() throws IOException {
|
||||
@@ -279,4 +281,67 @@ public class Test {
|
||||
File tempDir = new File(System.getProperty("java.io.tmpdir"));
|
||||
tempDir.mkdirs();
|
||||
}
|
||||
|
||||
void safeBecauseWindows() {
|
||||
File tempDir = new File(System.getProperty("java.io.tmpdir"), "child");
|
||||
if (System.getProperty("os.name").toLowerCase().contains("windows")) {
|
||||
tempDir.mkdir(); // Safe on windows
|
||||
}
|
||||
}
|
||||
|
||||
void vulnerableBecauseInvertedPosixCheck() throws IOException {
|
||||
// GIVEN:
|
||||
File tempDirChild = new File(System.getProperty("java.io.tmpdir"), "/child-create-directory");
|
||||
|
||||
// Oops, this check should be inverted
|
||||
if (tempDirChild.toPath().getFileSystem().supportedFileAttributeViews().contains("posix")) {
|
||||
Files.createDirectory(tempDirChild.toPath()); // Creates with permissions 'drwxr-xr-x'
|
||||
}
|
||||
}
|
||||
|
||||
void safeBecauseCheckingForWindowsVersion() throws IOException {
|
||||
// GIVEN:
|
||||
File tempDirChild = new File(System.getProperty("java.io.tmpdir"), "/child-create-directory");
|
||||
|
||||
if (SystemUtils.IS_OS_WINDOWS_10) {
|
||||
Files.createDirectory(tempDirChild.toPath());
|
||||
}
|
||||
}
|
||||
|
||||
void vulnerableBecauseCheckingForNotLinux() throws IOException {
|
||||
// GIVEN:
|
||||
File tempDirChild = new File(System.getProperty("java.io.tmpdir"), "/child-create-directory");
|
||||
|
||||
if (!SystemUtils.IS_OS_LINUX) {
|
||||
Files.createDirectory(tempDirChild.toPath());
|
||||
}
|
||||
}
|
||||
|
||||
void vulnerableBecauseInvertedFileSeparatorCheck() throws IOException {
|
||||
// GIVEN:
|
||||
File tempDirChild = new File(System.getProperty("java.io.tmpdir"), "/child-create-directory");
|
||||
|
||||
// Oops, this check should be inverted
|
||||
if (File.separatorChar != '\\') {
|
||||
Files.createDirectory(tempDirChild.toPath()); // Creates with permissions 'drwxr-xr-x'
|
||||
}
|
||||
}
|
||||
|
||||
void safeBecauseFileSeparatorCheck() throws IOException {
|
||||
// GIVEN:
|
||||
File tempDirChild = new File(System.getProperty("java.io.tmpdir"), "/child-create-directory");
|
||||
|
||||
if (File.separatorChar == '\\') {
|
||||
Files.createDirectory(tempDirChild.toPath());
|
||||
}
|
||||
}
|
||||
|
||||
void safeBecauseInvertedFileSeperatorCheck() throws IOException {
|
||||
// GIVEN:
|
||||
File tempDirChild = new File(System.getProperty("java.io.tmpdir"), "/child-create-directory");
|
||||
|
||||
if (File.separatorChar != '/') {
|
||||
Files.createDirectory(tempDirChild.toPath());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,88 @@
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.UncheckedIOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.attribute.PosixFilePermission;
|
||||
import java.nio.file.attribute.PosixFilePermissions;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
public class TestSafe {
|
||||
/*
|
||||
* An example of a safe use of createFile or createDirectory if your code must support windows and unix-like systems.
|
||||
*/
|
||||
void exampleSafeWithWindowsSupportFile() {
|
||||
// Creating a temporary file with a non-randomly generated name
|
||||
File tempChildFile = new File(System.getProperty("java.io.tmpdir"), "/child-create-file.txt");
|
||||
createTempFile(tempChildFile.toPath()); // GOOD: Good has permissions `-rw-------`
|
||||
}
|
||||
|
||||
static void createTempFile(Path tempDirChild) {
|
||||
try {
|
||||
if (tempDirChild.getFileSystem().supportedFileAttributeViews().contains("posix")) {
|
||||
// Explicit permissions setting is only required on unix-like systems because
|
||||
// the temporary directory is shared between all users.
|
||||
// This is not necessary on Windows, each user has their own temp directory
|
||||
final EnumSet<PosixFilePermission> posixFilePermissions =
|
||||
EnumSet.of(
|
||||
PosixFilePermission.OWNER_READ,
|
||||
PosixFilePermission.OWNER_WRITE
|
||||
);
|
||||
if (!Files.exists(tempDirChild)) {
|
||||
Files.createFile(
|
||||
tempDirChild,
|
||||
PosixFilePermissions.asFileAttribute(posixFilePermissions)
|
||||
); // GOOD: Directory has permissions `-rw-------`
|
||||
} else {
|
||||
Files.setPosixFilePermissions(
|
||||
tempDirChild,
|
||||
posixFilePermissions
|
||||
); // GOOD: Good has permissions `-rw-------`, or will throw an exception if this fails
|
||||
}
|
||||
} else if (!Files.exists(tempDirChild)) {
|
||||
// On Windows, we still need to create the directory, when it doesn't already exist.
|
||||
Files.createDirectory(tempDirChild); // GOOD: Windows doesn't share the temp directory between users
|
||||
}
|
||||
} catch (IOException exception) {
|
||||
throw new UncheckedIOException("Failed to create temp file", exception);
|
||||
}
|
||||
}
|
||||
|
||||
void exampleSafeWithWindowsSupportDirectory() {
|
||||
File tempDirChildDir = new File(System.getProperty("java.io.tmpdir"), "/child-dir");
|
||||
createTempDirectories(tempDirChildDir.toPath()); // GOOD: Directory has permissions `drwx------`
|
||||
}
|
||||
|
||||
static void createTempDirectories(Path tempDirChild) {
|
||||
try {
|
||||
if (tempDirChild.getFileSystem().supportedFileAttributeViews().contains("posix")) {
|
||||
// Explicit permissions setting is only required on unix-like systems because
|
||||
// the temporary directory is shared between all users.
|
||||
// This is not necessary on Windows, each user has their own temp directory
|
||||
final EnumSet<PosixFilePermission> posixFilePermissions =
|
||||
EnumSet.of(
|
||||
PosixFilePermission.OWNER_READ,
|
||||
PosixFilePermission.OWNER_WRITE,
|
||||
PosixFilePermission.OWNER_EXECUTE
|
||||
);
|
||||
if (!Files.exists(tempDirChild)) {
|
||||
Files.createDirectories(
|
||||
tempDirChild,
|
||||
PosixFilePermissions.asFileAttribute(posixFilePermissions)
|
||||
); // GOOD: Directory has permissions `drwx------`
|
||||
} else {
|
||||
Files.setPosixFilePermissions(
|
||||
tempDirChild,
|
||||
posixFilePermissions
|
||||
); // GOOD: Good has permissions `drwx------`, or will throw an exception if this fails
|
||||
}
|
||||
} else if (!Files.exists(tempDirChild)) {
|
||||
// On Windows, we still need to create the directory, when it doesn't already exist.
|
||||
Files.createDirectories(tempDirChild); // GOOD: Windows doesn't share the temp directory between users
|
||||
}
|
||||
} catch (IOException exception) {
|
||||
throw new UncheckedIOException("Failed to create temp dir", exception);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
//semmle-extractor-options: --javac-args -cp ${testdir}/../../../../../stubs/apache-commons-lang3-3.7/
|
||||
1786
java/ql/test/stubs/apache-commons-lang3-3.7/org/apache/commons/lang3/SystemUtils.java
generated
Normal file
1786
java/ql/test/stubs/apache-commons-lang3-3.7/org/apache/commons/lang3/SystemUtils.java
generated
Normal file
File diff suppressed because it is too large
Load Diff
131
java/ql/test/stubs/guava-30.0/com/google/common/base/StandardSystemProperty.java
generated
Normal file
131
java/ql/test/stubs/guava-30.0/com/google/common/base/StandardSystemProperty.java
generated
Normal file
@@ -0,0 +1,131 @@
|
||||
/*
|
||||
* Copyright (C) 2012 The Guava Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under the License
|
||||
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
||||
* or implied. See the License for the specific language governing permissions and limitations under
|
||||
* the License.
|
||||
*/
|
||||
|
||||
package com.google.common.base;
|
||||
|
||||
public enum StandardSystemProperty {
|
||||
|
||||
/** Java Runtime Environment version. */
|
||||
JAVA_VERSION("java.version"),
|
||||
|
||||
/** Java Runtime Environment vendor. */
|
||||
JAVA_VENDOR("java.vendor"),
|
||||
|
||||
/** Java vendor URL. */
|
||||
JAVA_VENDOR_URL("java.vendor.url"),
|
||||
|
||||
/** Java installation directory. */
|
||||
JAVA_HOME("java.home"),
|
||||
|
||||
/** Java Virtual Machine specification version. */
|
||||
JAVA_VM_SPECIFICATION_VERSION("java.vm.specification.version"),
|
||||
|
||||
/** Java Virtual Machine specification vendor. */
|
||||
JAVA_VM_SPECIFICATION_VENDOR("java.vm.specification.vendor"),
|
||||
|
||||
/** Java Virtual Machine specification name. */
|
||||
JAVA_VM_SPECIFICATION_NAME("java.vm.specification.name"),
|
||||
|
||||
/** Java Virtual Machine implementation version. */
|
||||
JAVA_VM_VERSION("java.vm.version"),
|
||||
|
||||
/** Java Virtual Machine implementation vendor. */
|
||||
JAVA_VM_VENDOR("java.vm.vendor"),
|
||||
|
||||
/** Java Virtual Machine implementation name. */
|
||||
JAVA_VM_NAME("java.vm.name"),
|
||||
|
||||
/** Java Runtime Environment specification version. */
|
||||
JAVA_SPECIFICATION_VERSION("java.specification.version"),
|
||||
|
||||
/** Java Runtime Environment specification vendor. */
|
||||
JAVA_SPECIFICATION_VENDOR("java.specification.vendor"),
|
||||
|
||||
/** Java Runtime Environment specification name. */
|
||||
JAVA_SPECIFICATION_NAME("java.specification.name"),
|
||||
|
||||
/** Java class format version number. */
|
||||
JAVA_CLASS_VERSION("java.class.version"),
|
||||
|
||||
/** Java class path. */
|
||||
JAVA_CLASS_PATH("java.class.path"),
|
||||
|
||||
/** List of paths to search when loading libraries. */
|
||||
JAVA_LIBRARY_PATH("java.library.path"),
|
||||
|
||||
/** Default temp file path. */
|
||||
JAVA_IO_TMPDIR("java.io.tmpdir"),
|
||||
|
||||
/** Name of JIT compiler to use. */
|
||||
JAVA_COMPILER("java.compiler"),
|
||||
|
||||
/**
|
||||
* Path of extension directory or directories.
|
||||
*
|
||||
* @deprecated This property was <a
|
||||
* href="https://openjdk.java.net/jeps/220#Removed:-The-extension-mechanism">deprecated</a> in
|
||||
* Java 8 and removed in Java 9. We do not plan to remove this API from Guava, but if you are
|
||||
* using it, it is probably not doing what you want.
|
||||
*/
|
||||
@Deprecated
|
||||
JAVA_EXT_DIRS("java.ext.dirs"),
|
||||
|
||||
/** Operating system name. */
|
||||
OS_NAME("os.name"),
|
||||
|
||||
/** Operating system architecture. */
|
||||
OS_ARCH("os.arch"),
|
||||
|
||||
/** Operating system version. */
|
||||
OS_VERSION("os.version"),
|
||||
|
||||
/** File separator ("/" on UNIX). */
|
||||
FILE_SEPARATOR("file.separator"),
|
||||
|
||||
/** Path separator (":" on UNIX). */
|
||||
PATH_SEPARATOR("path.separator"),
|
||||
|
||||
/** Line separator ("\n" on UNIX). */
|
||||
LINE_SEPARATOR("line.separator"),
|
||||
|
||||
/** User's account name. */
|
||||
USER_NAME("user.name"),
|
||||
|
||||
/** User's home directory. */
|
||||
USER_HOME("user.home"),
|
||||
|
||||
/** User's current working directory. */
|
||||
USER_DIR("user.dir");
|
||||
|
||||
private final String key;
|
||||
|
||||
StandardSystemProperty(String key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
/** Returns the key used to lookup this system property. */
|
||||
public String key() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public String value() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/** Returns a string representation of this system property. */
|
||||
@Override
|
||||
public String toString() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user