Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 35baa1c

Browse files
author
Benjamin Muskalla
committed
Support bulkdata for boxed types as well
1 parent 83b4070 commit 35baa1c

3 files changed

Lines changed: 23 additions & 3 deletions

File tree

java/ql/src/utils/model-generator/CaptureSummaryModels.ql

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,20 @@ predicate isRelevantType(Type t) {
131131
not t.(RefType).hasQualifiedName("java.math", "BigInteger") and
132132
(
133133
not t.(Array).getElementType() instanceof PrimitiveType or
134-
t.(Array).getElementType().(PrimitiveType).getName().regexpMatch("byte|char")
134+
isPrimitiveTypeUsedForBulkData(t.(Array).getElementType())
135135
) and
136-
not t.(Array).getElementType() instanceof BoxedType and
137-
not t.(CollectionType).getElementType() instanceof BoxedType
136+
(
137+
not t.(Array).getElementType() instanceof BoxedType or
138+
isPrimitiveTypeUsedForBulkData(t.(Array).getElementType())
139+
) and
140+
(
141+
not t.(CollectionType).getElementType() instanceof BoxedType or
142+
isPrimitiveTypeUsedForBulkData(t.(CollectionType).getElementType())
143+
)
144+
}
145+
146+
predicate isPrimitiveTypeUsedForBulkData(Type t) {
147+
t.getName().regexpMatch("byte|char|Byte|Character")
138148
}
139149

140150
from TargetAPI api, string flow

java/ql/test/utils/model-generator/CaptureSummaryModels.expected

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
| p;ParamFlow;true;returnsInput;(String);;Argument[0];ReturnValue;taint; |
3333
| p;ParamFlow;true;writeChunked;(byte[],OutputStream);;ArrayElement of Argument[0];Argument[1];taint; |
3434
| p;Pojo;false;fillIn;(List);;Argument[-1];Element of Argument[0];taint; |
35+
| p;Pojo;false;getBoxedBytes;();;Argument[-1];ReturnValue;taint; |
36+
| p;Pojo;false;getBoxedChars;();;Argument[-1];ReturnValue;taint; |
3537
| p;Pojo;false;getByteArray;();;Argument[-1];ReturnValue;taint; |
3638
| p;Pojo;false;getCharArray;();;Argument[-1];ReturnValue;taint; |
3739
| p;Pojo;false;getValue;();;Argument[-1];ReturnValue;taint; |

java/ql/test/utils/model-generator/p/Pojo.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,14 @@ public Collection<Integer> getBoxedCollection() {
6767
return List.of(Integer.valueOf(intValue));
6868
}
6969

70+
public List<Character> getBoxedChars() {
71+
return List.of((char)intValue);
72+
}
73+
74+
public Byte[] getBoxedBytes() {
75+
return new Byte[] { Byte.valueOf((byte) intValue) };
76+
}
77+
7078
public BigInteger getBigInt() {
7179
return BigInteger.valueOf(intValue);
7280
}

0 commit comments

Comments
 (0)