Skip to content

Commit 9551321

Browse files
committed
Fix LinkedMultiValueMap models and make tests more realistic
1 parent 60179ce commit 9551321

File tree

2 files changed

+7
-12
lines changed

2 files changed

+7
-12
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ private class FlowSummaries extends SummaryModelCsv {
5454
"org.springframework.util;FileSystemUtils;false;copyRecursively;(java.io.File,java.io.File);;Argument[0];Argument[1];taint",
5555
"org.springframework.util;LinkedMultiValueMap;false;LinkedMultiValueMap;(java.util.Map);;MapKey of Argument[0];MapKey of Argument[-1];value",
5656
"org.springframework.util;LinkedMultiValueMap;false;LinkedMultiValueMap;(java.util.Map);;Element of MapValue of Argument[0];Element of MapValue of Argument[-1];value",
57-
"org.springframework.util;LinkedMultiValueMap;false;deepCopy;;;MapKey of Argument[-1];MapValue of ReturnValue;value",
57+
"org.springframework.util;LinkedMultiValueMap;false;deepCopy;;;MapKey of Argument[-1];MapKey of ReturnValue;value",
5858
"org.springframework.util;LinkedMultiValueMap;false;deepCopy;;;MapValue of Argument[-1];MapValue of ReturnValue;value",
5959
"org.springframework.util;MultiValueMap;true;add;;;Argument[0];MapKey of Argument[-1];value",
6060
"org.springframework.util;MultiValueMap;true;add;;;Argument[1];Element of MapValue of Argument[-1];value",

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

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -439,16 +439,18 @@ public void test() throws Exception {
439439
{
440440
// "org.springframework.util;LinkedMultiValueMap;false;deepCopy;;;MapKey of Argument[-1];MapValue of ReturnValue;value"
441441
LinkedMultiValueMap<Object, Object> out = null;
442-
LinkedMultiValueMap in = (LinkedMultiValueMap)Map.of(source(), null);
442+
LinkedMultiValueMap in = new LinkedMultiValueMap<Object, Object>();
443+
in.set(source(), null);
443444
out = in.deepCopy();
444-
sink(getMapValue(out)); // $hasValueFlow
445+
sink(getMapKey(out)); // $hasValueFlow
445446
}
446447
{
447448
// "org.springframework.util;LinkedMultiValueMap;false;deepCopy;;;MapValue of Argument[-1];MapValue of ReturnValue;value"
448449
LinkedMultiValueMap<Object, Object> out = null;
449-
LinkedMultiValueMap in = (LinkedMultiValueMap)Map.of(null, source());
450+
LinkedMultiValueMap in = new LinkedMultiValueMap<Object, Object>();
451+
in.set(null, source());
450452
out = in.deepCopy();
451-
sink(getMapValue(out)); // $hasValueFlow
453+
sink(getElement(getMapValue(out))); // $hasValueFlow
452454
}
453455
{
454456
// "org.springframework.util;MultiValueMap;true;add;;;Argument[0];MapKey of Argument[-1];value"
@@ -620,13 +622,6 @@ public void test() throws Exception {
620622
out.set(in, null);
621623
sink(getMapKey(out)); // $hasValueFlow
622624
}
623-
{
624-
// "org.springframework.util;MultiValueMap;true;set;;;Argument[0];MapKey of Argument[-1];value"
625-
MultiValueMap<Object, Object> out = null;
626-
Object in = source();
627-
out.set(in, (Object)null);
628-
sink(getMapKey(out)); // $hasValueFlow
629-
}
630625
{
631626
// "org.springframework.util;MultiValueMap;true;set;;;Argument[1];Element of MapValue of Argument[-1];value"
632627
MultiValueMapAdapter<Object, Object> out = null;

0 commit comments

Comments
 (0)