Skip to content

Commit

Permalink
Code cleanup from code review
Browse files Browse the repository at this point in the history
  • Loading branch information
JLLeitschuh committed Mar 11, 2022
1 parent 1c98642 commit b73c74a
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 7 deletions.
4 changes: 4 additions & 0 deletions java/ql/lib/semmle/code/java/environment/SystemProperty.qll
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
/**
* 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
Expand Down
9 changes: 9 additions & 0 deletions java/ql/lib/semmle/code/java/frameworks/Properties.qll
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@
import semmle.code.java.Type
private import semmle.code.java.dataflow.FlowSteps

/**
* The `java.util.Properties` class.
*/
class TypeProperty extends Class {
TypeProperty() { hasQualifiedName("java.util", "Properties") }
}

/** The `getProperty` method of the class `java.util.Properties`. */
class PropertiesGetPropertyMethod extends ValuePreservingMethod {
PropertiesGetPropertyMethod() {
getDeclaringType() instanceof TypeProperty and
Expand All @@ -15,20 +19,25 @@ class PropertiesGetPropertyMethod extends ValuePreservingMethod {
override predicate returnsValue(int arg) { arg = 1 }
}

/** 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")
}
}

/**
* The methods of the class `java.util.Properties` that write the contents to an output.
*/
class PropertiesStoreMethod extends Method {
PropertiesStoreMethod() {
getDeclaringType() instanceof TypeProperty and
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,7 @@ private class TempDirSystemGetPropertyDirectlyToMkdirConfig extends TaintTrackin
}

override predicate isSource(DataFlow::Node node) {
exists(
ExprSystemGetPropertyTempDirTainted propertyGetExpr, DataFlow::Node callSite
|
exists(ExprSystemGetPropertyTempDirTainted propertyGetExpr, DataFlow::Node callSite |
DataFlow::localFlow(DataFlow::exprNode(propertyGetExpr), callSite)
|
isFileConstructorArgument(callSite.asExpr(), node.asExpr(), 1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ import default
import semmle.code.java.os.OSCheck

from IsSpecificUnixVariant isAnyUnix
select isAnyUnix
select isAnyUnix
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ import default
import semmle.code.java.os.OSCheck

from IsSpecificWindowsVariant isAnyWindows
select isAnyWindows
select isAnyWindows
2 changes: 1 addition & 1 deletion java/ql/test/library-tests/os/unix-test.ql
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ import default
import semmle.code.java.os.OSCheck

from IsUnixGuard isUnix
select isUnix
select isUnix
2 changes: 1 addition & 1 deletion java/ql/test/library-tests/os/windows-test.ql
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ import default
import semmle.code.java.os.OSCheck

from IsWindowsGuard isWindows
select isWindows
select isWindows

0 comments on commit b73c74a

Please sign in to comment.