Skip to content

Commit 076aeb5

Browse files
Update tests
1 parent 48c61fc commit 076aeb5

File tree

2 files changed

+23
-7
lines changed
  • java/ql
    • src/semmle/code/java/frameworks/guava
    • test/library-tests/frameworks/guava/generated/cache

2 files changed

+23
-7
lines changed

java/ql/src/semmle/code/java/frameworks/guava/Cache.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ private class GuavaBaseCsv extends SummaryModelCsv {
2525
"com.google.common.cache;LoadingCache;true;getUnchecked;(Object);;MapValue of Argument[-1];ReturnValue;value",
2626
"com.google.common.cache;LoadingCache;true;apply;(Object);;MapValue of Argument[-1];ReturnValue;value",
2727
"com.google.common.cache;LoadingCache;true;getAll;(Iterable);;Element of Argument[0];MapKey of ReturnValue;value",
28-
"com.google.common.cache;LoadingCache;true;getAll;(Iterable);;Element of Argument[0];MapKey of Agument[-1];value",
28+
"com.google.common.cache;LoadingCache;true;getAll;(Iterable);;Element of Argument[0];MapKey of Argument[-1];value",
2929
"com.google.common.cache;LoadingCache;true;getAll;(Iterable);;MapValue of Argument[-1];MapValue of ReturnValue;value"
3030
]
3131
}

java/ql/test/library-tests/frameworks/guava/generated/cache/Test.java

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,19 @@ public void test() throws Exception {
8383
sink(out); // $ hasValueFlow
8484
}
8585
{
86-
// "com.google.common.cache;Cache;true;getAllPresent;(Iterable);;MapValue of Argument[-1];MapValue of ReturnValue;value"
86+
// "com.google.common.cache;Cache;true;getAllPresent;(Iterable);;Element of Argument[0];MapKey of ReturnValue;value"
8787
ImmutableMap out = null;
88-
Cache in = newCacheWithMapValue(source());
88+
Iterable in = newWithElement(source());
89+
Cache instance = null;
90+
out = instance.getAllPresent(in);
91+
sink(getMapKey(out)); // $ hasValueFlow
92+
}
93+
{
94+
// "com.google.common.cache;Cache;true;getAllPresent;(Iterable);;MapKey of Argument[-1];MapKey of ReturnValue;value"
95+
ImmutableMap out = null;
96+
Cache in = newCacheWithMapKey(source());
8997
out = in.getAllPresent(null);
90-
sink(getMapValue(out)); // $ hasValueFlow
98+
sink(getMapKey(out)); // $ hasValueFlow
9199
}
92100
{
93101
// "com.google.common.cache;Cache;true;getIfPresent;;;MapValue of Argument[-1];ReturnValue;value"
@@ -139,10 +147,18 @@ public void test() throws Exception {
139147
sink(out); // $ hasValueFlow
140148
}
141149
{
142-
// "com.google.common.cache;LoadingCache;true;getAll;(Iterable);;MapKey of Argument[-1];MapKey of ReturnValue;value"
150+
// "com.google.common.cache;LoadingCache;true;getAll;(Iterable);;Element of Argument[0];MapKey of Argument[-1];value"
151+
LoadingCache out = null;
152+
Iterable in = (Iterable)newWithElement(source());
153+
out.getAll(in);
154+
sink(getMapKey(out)); // $ hasValueFlow
155+
}
156+
{
157+
// "com.google.common.cache;LoadingCache;true;getAll;(Iterable);;Element of Argument[0];MapKey of ReturnValue;value"
143158
ImmutableMap out = null;
144-
LoadingCache in = newCacheWithMapKey(source());
145-
out = in.getAll(null);
159+
Iterable in = (Iterable)newWithElement(source());
160+
LoadingCache instance = null;
161+
out = instance.getAll(in);
146162
sink(getMapKey(out)); // $ hasValueFlow
147163
}
148164
{

0 commit comments

Comments
 (0)