@@ -31,7 +31,7 @@ string captureFieldFlow(Callable api) {
3131 exists ( FieldAccess fa , ReturnNodeExt postUpdate |
3232 not ( fa .getField ( ) .isStatic ( ) and fa .getField ( ) .isFinal ( ) ) and
3333 postUpdate .getEnclosingCallable ( ) = api and
34- not api .getReturnType ( ) instanceof PrimitiveType and
34+ isRelevantType ( api .getReturnType ( ) ) and
3535 not api .getDeclaringType ( ) instanceof EnumType and
3636 TaintTracking:: localTaint ( DataFlow:: exprNode ( fa ) , postUpdate )
3737 |
@@ -55,7 +55,7 @@ class ParameterToFieldConfig extends TaintTracking::Configuration {
5555
5656 override predicate isSource ( DataFlow:: Node source ) {
5757 source instanceof DataFlow:: ParameterNode and
58- not source .getType ( ) instanceof PrimitiveType
58+ isRelevantType ( source .getType ( ) )
5959 }
6060
6161 override predicate isSink ( DataFlow:: Node sink ) {
@@ -82,10 +82,8 @@ class ParameterToReturnValueTaintConfig extends TaintTracking::Configuration {
8282 exists ( Callable api |
8383 source instanceof DataFlow:: ParameterNode and
8484 api = source .asParameter ( ) .getCallable ( ) and
85- not api .getReturnType ( ) instanceof PrimitiveType and
86- not api .getReturnType ( ) instanceof TypeClass and
87- not source .asParameter ( ) .getType ( ) instanceof PrimitiveType and
88- not source .asParameter ( ) .getType ( ) instanceof TypeClass
85+ isRelevantType ( api .getReturnType ( ) ) and
86+ isRelevantType ( source .asParameter ( ) .getType ( ) )
8987 )
9088 }
9189
@@ -120,6 +118,18 @@ string captureParameterToParameterFlow(Callable api) {
120118 )
121119}
122120
121+ predicate isRelevantType ( Type t ) {
122+ not t instanceof TypeClass and
123+ not t instanceof EnumType and
124+ not t instanceof PrimitiveType and
125+ not t instanceof BoxedType and
126+ not t .( RefType ) .hasQualifiedName ( "java.math" , "BigInteger" ) and
127+ not t .( Array ) .getElementType ( ) instanceof PrimitiveType and
128+ not t .( Array ) .getElementType ( ) .( PrimitiveType ) .getName ( ) .regexpMatch ( "byte|char" ) and
129+ not t .( Array ) .getElementType ( ) instanceof BoxedType and
130+ not t .( CollectionType ) .getElementType ( ) instanceof BoxedType
131+ }
132+
123133// TODO: "com.google.common.base;Converter;true;convertAll;(Iterable);;Element of Argument[0];Element of ReturnValue;taint",
124134// TODO: infer interface from multiple implementations? e.g. UriComponentsContributor
125135// TODO: distinguish between taint and value flows. If we find a value flow, omit the taint flow
0 commit comments