@@ -40,19 +40,18 @@ abstract class IsSpecificUnixVariant extends Guard { }
4040/**
4141 * Holds when `ma` compares the current OS against the string constant `osString`.
4242 */
43- bindingset [ osString]
4443private predicate isOsFromSystemProp ( MethodAccess ma , string osString ) {
4544 TaintTracking:: localExprTaint ( getSystemProperty ( "os.name" ) , ma .getQualifier ( ) ) and // Call from System.getProperty (or equivalent) to some partial match method
4645 exists ( StringPartialMatchMethod m , CompileTimeConstantExpr matchedStringConstant |
4746 m = ma .getMethod ( ) and
48- matchedStringConstant .getStringValue ( ) .toLowerCase ( ) . matches ( osString )
47+ matchedStringConstant .getStringValue ( ) .toLowerCase ( ) = osString
4948 |
5049 DataFlow:: localExprFlow ( matchedStringConstant , ma .getArgument ( m .getMatchParameterIndex ( ) ) )
5150 )
5251}
5352
5453private class IsWindowsFromSystemProp extends IsWindowsGuard instanceof MethodAccess {
55- IsWindowsFromSystemProp ( ) { isOsFromSystemProp ( this , "window%" ) }
54+ IsWindowsFromSystemProp ( ) { isOsFromSystemProp ( this , any ( string s | s . regexpMatch ( "windows?" ) ) ) }
5655}
5756
5857/**
@@ -99,13 +98,15 @@ private class IsUnixFromCharSeparator extends IsUnixGuard {
9998}
10099
101100private class IsUnixFromSystemProp extends IsSpecificUnixVariant instanceof MethodAccess {
102- IsUnixFromSystemProp ( ) { isOsFromSystemProp ( this , [ "mac%" , "linux%" ] ) }
101+ IsUnixFromSystemProp ( ) {
102+ isOsFromSystemProp ( this , any ( string s | s .regexpMatch ( [ "mac.*" , "linux.*" ] ) ) )
103+ }
103104}
104105
105106bindingset [ fieldNamePattern]
106107private predicate isOsFromApacheCommons ( FieldAccess fa , string fieldNamePattern ) {
107108 exists ( Field f | f = fa .getField ( ) |
108- f .getDeclaringType ( ) instanceof ApacheSystemUtils and
109+ f .getDeclaringType ( ) instanceof TypeApacheSystemUtils and
109110 f .getName ( ) .matches ( fieldNamePattern )
110111 )
111112}
0 commit comments