Skip to content

Commit

Permalink
Merge pull request #16290 from aschackmull/java/oscheck-perf
Browse files Browse the repository at this point in the history
Java: Fix join-order.
  • Loading branch information
aschackmull committed Apr 19, 2024
2 parents bcedf68 + c45fd40 commit 874d9d1
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion java/ql/lib/semmle/code/java/os/OSCheck.qll
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,17 @@ abstract class IsUnixGuard extends Guard { }
*/
abstract class IsSpecificUnixVariant extends Guard { }

private DataFlow::Node osNameFlow() {
result.asExpr() = getSystemProperty("os.name")
or
TaintTracking::localTaintStep(osNameFlow(), result)
}

/**
* Holds when `ma` compares the current OS against the string constant `osString`.
*/
private predicate isOsFromSystemProp(MethodCall ma, string osString) {
TaintTracking::localExprTaint(getSystemProperty("os.name"), ma.getQualifier()) and // Call from System.getProperty (or equivalent) to some partial match method
osNameFlow().asExpr() = 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
Expand Down

0 comments on commit 874d9d1

Please sign in to comment.