@@ -38,49 +38,53 @@ private class IfConditionSink extends UseOfLessTrustedSink {
38
38
IfConditionSink ( ) {
39
39
exists ( IfStmt is |
40
40
is .getCondition ( ) = this .asExpr ( ) and
41
- not exists ( EQExpr eqe |
42
- eqe .getAnOperand ( ) instanceof NullLiteral and
43
- is .getCondition ( ) = eqe .getParent * ( )
44
- ) and
45
- not exists ( NEExpr nee |
46
- nee .getAnOperand ( ) instanceof NullLiteral and
47
- is .getCondition ( ) = nee .getParent * ( )
48
- ) and
49
- not exists ( MethodAccess ma |
50
- ma .getMethod ( ) .hasName ( "equals" ) and
51
- ma .getMethod ( ) .getNumberOfParameters ( ) = 1 and
52
- (
53
- ma .getQualifier ( ) .( CompileTimeConstantExpr ) .getStringValue ( ) = "" or
54
- ma .getArgument ( 0 ) .( CompileTimeConstantExpr ) .getStringValue ( ) = ""
55
- ) and
56
- is .getCondition ( ) = ma .getParent * ( )
57
- ) and
58
- not exists ( MethodAccess ma |
59
- ma .getMethod ( ) .hasName ( "equalsIgnoreCase" ) and
60
- ma .getMethod ( ) .getNumberOfParameters ( ) = 1 and
61
- (
62
- ma .getQualifier ( ) .( CompileTimeConstantExpr ) .getStringValue ( ) = "unknown" or
63
- ma .getArgument ( 0 ) .( CompileTimeConstantExpr ) .getStringValue ( ) = "unknown"
64
- ) and
65
- is .getCondition ( ) = ma .getParent * ( )
66
- ) and
67
- not exists ( MethodAccess ma |
68
- ma .getMethod ( ) .getName ( ) in [ "isEmpty" , "isNotEmpty" ] and
69
- ma .getMethod ( ) .getNumberOfParameters ( ) = 1 and
70
- is .getCondition ( ) = ma .getParent * ( )
71
- ) and
72
- not exists ( MethodAccess ma |
73
- (
74
- ma .getMethod ( ) .hasQualifiedName ( "org.apache.commons.lang3" , "StringUtils" , "isBlank" ) or
75
- ma .getMethod ( ) .hasQualifiedName ( "org.apache.commons.lang3" , "StringUtils" , "isNotBlank" )
76
- ) and
77
- is .getCondition ( ) = ma .getParent * ( )
78
- ) and
79
- not exists ( MethodAccess ma |
80
- ma .getMethod ( )
81
- .hasQualifiedName ( "org.apache.commons.lang3" , "StringUtils" , "equalsIgnoreCase" ) and
82
- ma .getAnArgument ( ) .( CompileTimeConstantExpr ) .getStringValue ( ) = "unknown" and
83
- is .getCondition ( ) = ma .getParent * ( )
41
+ (
42
+ exists ( MethodAccess ma |
43
+ ma .getMethod ( ) .getName ( ) in [ "equals" , "equalsIgnoreCase" ] and
44
+ ma .getMethod ( ) .getDeclaringType ( ) instanceof TypeString and
45
+ ma .getMethod ( ) .getNumberOfParameters ( ) = 1 and
46
+ not ma .getQualifier ( ) .( CompileTimeConstantExpr ) .getStringValue ( ) .toLowerCase ( ) in [
47
+ "" , "unknown" , ":"
48
+ ] and
49
+ not ma .getArgument ( 0 ) .( CompileTimeConstantExpr ) .getStringValue ( ) .toLowerCase ( ) in [
50
+ "" , "unknown" , ":"
51
+ ] and
52
+ is .getCondition ( ) = ma .getParent * ( )
53
+ )
54
+ or
55
+ exists ( MethodAccess ma |
56
+ ma .getMethod ( ) .hasName ( "contains" ) and
57
+ ma .getMethod ( ) .getDeclaringType ( ) instanceof TypeString and
58
+ ma .getMethod ( ) .getNumberOfParameters ( ) = 1 and
59
+ ma .getAnArgument ( ) .( CompileTimeConstantExpr ) .getStringValue ( ) .toLowerCase ( ) in [
60
+ "" , "unknown"
61
+ ] and
62
+ is .getCondition ( ) = ma .getParent * ( )
63
+ )
64
+ or
65
+ exists ( MethodAccess ma |
66
+ ma .getMethod ( ) .hasName ( "startsWith" ) and
67
+ ma .getMethod ( )
68
+ .getDeclaringType ( )
69
+ .hasQualifiedName ( [ "org.apache.commons.lang3" , "org.apache.commons.lang" ] ,
70
+ "StringUtils" ) and
71
+ ma .getMethod ( ) .getNumberOfParameters ( ) = 2 and
72
+ ma .getAnArgument ( ) .( CompileTimeConstantExpr ) .getStringValue ( ) != "" and
73
+ is .getCondition ( ) = ma .getParent * ( )
74
+ )
75
+ or
76
+ exists ( MethodAccess ma |
77
+ ma .getMethod ( ) .getName ( ) in [ "equals" , "equalsIgnoreCase" ] and
78
+ ma .getMethod ( )
79
+ .getDeclaringType ( )
80
+ .hasQualifiedName ( [ "org.apache.commons.lang3" , "org.apache.commons.lang" ] ,
81
+ "StringUtils" ) and
82
+ ma .getMethod ( ) .getNumberOfParameters ( ) = 2 and
83
+ not ma .getAnArgument ( ) .( CompileTimeConstantExpr ) .getStringValue ( ) .toLowerCase ( ) in [
84
+ "" , "unknown" , ":"
85
+ ] and
86
+ is .getCondition ( ) = ma .getParent * ( )
87
+ )
84
88
)
85
89
)
86
90
}
@@ -101,9 +105,7 @@ private class PrintSink extends UseOfLessTrustedSink {
101
105
PrintSink ( ) {
102
106
exists ( MethodAccess ma |
103
107
ma .getMethod ( ) .getName ( ) in [ "print" , "println" ] and
104
- (
105
- ma .getMethod ( ) .getDeclaringType ( ) .hasQualifiedName ( "java.io" , [ "PrintWriter" , "PrintStream" ] )
106
- ) and
108
+ ma .getMethod ( ) .getDeclaringType ( ) .hasQualifiedName ( "java.io" , [ "PrintWriter" , "PrintStream" ] ) and
107
109
ma .getAnArgument ( ) = this .asExpr ( )
108
110
)
109
111
}
0 commit comments