Skip to content

Commit 9d64cad

Browse files
committed
Adapt tests after applying changes from code review
1 parent b64b8ec commit 9d64cad

File tree

2 files changed

+27
-31
lines changed

2 files changed

+27
-31
lines changed

java/ql/src/semmle/code/java/frameworks/spring/SpringBeans.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ private class FlowSummaries extends SummaryModelCsv {
2020
"org.springframework.beans;PropertyValue;false;PropertyValue;(PropertyValue,Object);;Argument[1];MapValue of Argument[-1];value",
2121
"org.springframework.beans;PropertyValue;false;getName;;;MapKey of Argument[-1];ReturnValue;value",
2222
"org.springframework.beans;PropertyValue;false;getValue;;;MapValue of Argument[-1];ReturnValue;value",
23-
"org.springframework.beans;PropertyValues;true;getPropertyValue;;;MapValue of Element of Argument[-1];ReturnValue;value",
23+
"org.springframework.beans;PropertyValues;true;getPropertyValue;;;Element of Argument[-1];ReturnValue;value",
2424
"org.springframework.beans;PropertyValues;true;getPropertyValues;;;Element of Argument[-1];ArrayElement of ReturnValue;value",
2525
"org.springframework.beans;MutablePropertyValues;true;add;(String,Object);;Argument[0];MapKey of Element of Argument[-1];value",
2626
"org.springframework.beans;MutablePropertyValues;true;add;(String,Object);;Argument[-1];ReturnValue;value",

java/ql/test/library-tests/frameworks/spring/beans/Test.java

Lines changed: 26 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ public void test() {
9797
sink(v.getName()); // Safe
9898
sink(v.getValue()); // $hasValueFlow
9999
}
100-
// "org.springframework.beans;PropertyValues;true;getPropertyValue;;;MapValue of Element of Argument[-1];ReturnValue;value",
100+
// "org.springframework.beans;PropertyValues;true;getPropertyValue;;;Element of Argument[-1];ReturnValue;value",
101101
{
102102
PropertyValues pv = newWithElement(newWithMapValue(source()));
103103
sink(pv.getPropertyValue("safe").getValue()); // $hasValueFlow
@@ -116,25 +116,24 @@ public void test() {
116116
sink(getMapKey(getElement(pv))); // $hasValueFlow
117117
sink(getMapValue(getElement(pv))); // Safe
118118
}
119-
// "org.springframework.beans;MutablePropertyValues;true;add;(String,Object);;Argument[0];MapKey of Element of ReturnValue;value",
119+
// "org.springframework.beans;MutablePropertyValues;true;add;(String,Object);;Argument[-1];ReturnValue;value",
120120
{
121121
MutablePropertyValues pv = new MutablePropertyValues();
122122
sink(getMapKey(getElement(pv.add(source(), null)))); // $hasValueFlow
123123
sink(getMapValue(getElement(pv.add(source(), null)))); // Safe
124124
}
125+
{
126+
MutablePropertyValues pv = new MutablePropertyValues();
127+
sink(getMapKey(getElement(pv.add("safe", source())))); // Safe
128+
sink(getMapValue(getElement(pv.add("safe", source())))); // $hasValueFlow
129+
}
125130
// "org.springframework.beans;MutablePropertyValues;true;add;(String,Object);;Argument[1];MapValue of Element of Argument[-1];value",
126131
{
127132
MutablePropertyValues pv = new MutablePropertyValues();
128133
pv.add("safe", source());
129134
sink(getMapKey(getElement(pv))); // Safe
130135
sink(getMapValue(getElement(pv))); // $hasValueFlow
131136
}
132-
// "org.springframework.beans;MutablePropertyValues;true;add;(String,Object);;Argument[1];MapValue of Element of ReturnValue;value",
133-
{
134-
MutablePropertyValues pv = new MutablePropertyValues();
135-
sink(getMapKey(getElement(pv.add("safe", source())))); // Safe
136-
sink(getMapValue(getElement(pv.add("safe", source())))); // $hasValueFlow
137-
}
138137
// "org.springframework.beans;MutablePropertyValues;true;addPropertyValue;(PropertyValue);;Argument[0];Element of Argument[-1];value",
139138
{
140139
MutablePropertyValues pv1 = new MutablePropertyValues();
@@ -149,7 +148,7 @@ public void test() {
149148
sink(getMapKey(getElement(pv2))); // Safe
150149
sink(getMapValue(getElement(pv2))); // $hasValueFlow
151150
}
152-
// "org.springframework.beans;MutablePropertyValues;true;addPropertyValue;(PropertyValue);;Argument[0];Element of ReturnValue;value",
151+
// "org.springframework.beans;MutablePropertyValues;true;addPropertyValue;(PropertyValue);;Argument[-1];ReturnValue;value",
153152
{
154153
MutablePropertyValues pv1 = new MutablePropertyValues();
155154
PropertyValue v1 = newWithMapKey(source());
@@ -186,15 +185,6 @@ public void test() {
186185
sink(getMapKey(getElement(pv))); // $hasValueFlow
187186
sink(getMapValue(getElement(pv))); // Safe
188187
}
189-
// "org.springframework.beans;MutablePropertyValues;true;addPropertyValues;(Map);;MapKey of Argument[0];MapKey of Element of ReturnValue;value",
190-
{
191-
MutablePropertyValues pv = new MutablePropertyValues();
192-
Map<String, Object> values = new HashMap<String, Object>();
193-
values.put(source(), null);
194-
PropertyValues pv2 = pv.addPropertyValues(values);
195-
sink(getMapKey(getElement(pv2))); // $hasValueFlow
196-
sink(getMapValue(getElement(pv2))); // Safe
197-
}
198188
// "org.springframework.beans;MutablePropertyValues;true;addPropertyValues;(Map);;MapValue of Argument[0];MapValue of Element of Argument[-1];value",
199189
{
200190
MutablePropertyValues pv = new MutablePropertyValues();
@@ -204,7 +194,7 @@ public void test() {
204194
sink(getMapKey(getElement(pv))); // Safe
205195
sink(getMapValue(getElement(pv))); // $hasValueFlow
206196
}
207-
// "org.springframework.beans;MutablePropertyValues;true;addPropertyValues;(Map);;MapValue of Argument[0];MapValue of Element of ReturnValue;value",
197+
// "org.springframework.beans;MutablePropertyValues;true;addPropertyValues;(Map);;Argument[-1];ReturnValue;value",
208198
{
209199
MutablePropertyValues pv = new MutablePropertyValues();
210200
Map<String, Object> values = new HashMap<String, Object>();
@@ -213,31 +203,37 @@ public void test() {
213203
sink(getMapKey(getElement(pv2))); // Safe
214204
sink(getMapValue(getElement(pv2))); // $hasValueFlow
215205
}
216-
// "org.springframework.beans;MutablePropertyValues;true;addPropertyValues;(PropertyValues);;MapKey of Element of Argument[0];MapKey of Element of Argument[-1];value",
217206
{
218207
MutablePropertyValues pv = new MutablePropertyValues();
219-
PropertyValues values = newWithElement(newWithMapKey(source()));
220-
pv.addPropertyValues(values);
221-
sink(getMapKey(getElement(pv))); // $hasValueFlow
222-
sink(getMapValue(getElement(pv))); // Safe
208+
Map<String, Object> values = new HashMap<String, Object>();
209+
values.put(source(), null);
210+
PropertyValues pv2 = pv.addPropertyValues(values);
211+
sink(getMapKey(getElement(pv2))); // $hasValueFlow
212+
sink(getMapValue(getElement(pv2))); // Safe
223213
}
224-
// "org.springframework.beans;MutablePropertyValues;true;addPropertyValues;(PropertyValues);;MapKey of Element of Argument[0];MapKey of Element of ReturnValue;value",
214+
// "org.springframework.beans;MutablePropertyValues;true;addPropertyValues;(PropertyValues);;Element of Argument[0];Element of Argument[-1];value",
225215
{
226216
MutablePropertyValues pv = new MutablePropertyValues();
227217
PropertyValues values = newWithElement(newWithMapKey(source()));
228-
PropertyValues pv2 = pv.addPropertyValues(values);
229-
sink(getMapKey(getElement(pv2))); // $hasValueFlow
230-
sink(getMapValue(getElement(pv2))); // Safe
218+
pv.addPropertyValues(values);
219+
sink(getMapKey(getElement(pv))); // $hasValueFlow
220+
sink(getMapValue(getElement(pv))); // Safe
231221
}
232-
// "org.springframework.beans;MutablePropertyValues;true;addPropertyValues;(PropertyValues);;MapValue of Element of Argument[0];MapValue of Element of Argument[-1];value",
233222
{
234223
MutablePropertyValues pv = new MutablePropertyValues();
235224
PropertyValues values = newWithElement(newWithMapValue(source()));
236225
pv.addPropertyValues(values);
237226
sink(getMapKey(getElement(pv))); // Safe
238227
sink(getMapValue(getElement(pv))); // $hasValueFlow
239228
}
240-
// "org.springframework.beans;MutablePropertyValues;true;addPropertyValues;(PropertyValues);;MapValue of Element of Argument[0];MapValue of Element of ReturnValue;value",
229+
// "org.springframework.beans;MutablePropertyValues;true;addPropertyValues;(PropertyValues);;Argument[-1];ReturnValue;value",
230+
{
231+
MutablePropertyValues pv = new MutablePropertyValues();
232+
PropertyValues values = newWithElement(newWithMapKey(source()));
233+
PropertyValues pv2 = pv.addPropertyValues(values);
234+
sink(getMapKey(getElement(pv2))); // $hasValueFlow
235+
sink(getMapValue(getElement(pv2))); // Safe
236+
}
241237
{
242238
MutablePropertyValues pv = new MutablePropertyValues();
243239
PropertyValues values = newWithElement(newWithMapValue(source()));

0 commit comments

Comments
 (0)