Add generated tests

This commit is contained in:
Sauyon Lee
2021-06-29 06:40:41 -07:00
parent 16931e5de8
commit eaef1c146c
8 changed files with 822 additions and 0 deletions

View File

@@ -0,0 +1,112 @@
package generatedtest;
import java.util.concurrent.Callable;
import org.springframework.cache.Cache;
// Test case generated by GenerateFlowTestCase.ql
public class Test {
Object getMapKey(Object container) { return null; }
Object getMapValue(Object container) { return null; }
Object newWithMapKey(Object element) { return null; }
Object newWithMapValue(Object element) { return null; }
Object source() { return null; }
void sink(Object o) { }
public void test() {
{
// "org.springframework.cache;Cache$ValueRetrievalException;false;ValueRetrievalException;;;Argument[0];MapKey of Argument[-1];value"
Cache.ValueRetrievalException out = null;
Object in = source();
out = new ValueRetrievalException(in, null, null);
sink(getMapKey(out)); // $hasValueFlow
}
{
// "org.springframework.cache;Cache$ValueRetrievalException;false;getKey;;;MapKey of Argument[-1];ReturnValue;value"
Object out = null;
Cache.ValueRetrievalException in = (Cache.ValueRetrievalException)newWithMapKey(source());
out = in.getKey();
sink(out); // $hasValueFlow
}
{
// "org.springframework.cache;Cache$ValueWrapper;true;get;;;MapValue of Argument[-1];ReturnValue;value"
Object out = null;
Cache.ValueWrapper in = (Cache.ValueWrapper)newWithMapValue(source());
out = in.get();
sink(out); // $hasValueFlow
}
{
// "org.springframework.cache;Cache;true;get;(Object);;MapValue of Argument[-1];MapValue of ReturnValue;value"
Cache.ValueWrapper out = null;
Cache in = (Cache)newWithMapValue(source());
out = in.get(null);
sink(getMapValue(out)); // $hasValueFlow
}
{
// "org.springframework.cache;Cache;true;get;(Object,Callable);;MapValue of Argument[-1];ReturnValue;value"
Object out = null;
Cache in = (Cache)newWithMapValue(source());
out = in.get(null, (Callable)null);
sink(out); // $hasValueFlow
}
{
// "org.springframework.cache;Cache;true;get;(Object,Class);;MapValue of Argument[-1];ReturnValue;value"
Object out = null;
Cache in = (Cache)newWithMapValue(source());
out = in.get(null, (Class)null);
sink(out); // $hasValueFlow
}
{
// "org.springframework.cache;Cache;true;getNativeCache;;;MapKey of Argument[-1];MapKey of ReturnValue;value"
Object out = null;
Cache in = (Cache)newWithMapKey(source());
out = in.getNativeCache();
sink(getMapKey(out)); // $hasValueFlow
}
{
// "org.springframework.cache;Cache;true;getNativeCache;;;MapValue of Argument[-1];MapValue of ReturnValue;value"
Object out = null;
Cache in = (Cache)newWithMapValue(source());
out = in.getNativeCache();
sink(getMapValue(out)); // $hasValueFlow
}
{
// "org.springframework.cache;Cache;true;put;;;Argument[0];MapKey of Argument[-1];value"
Cache out = null;
Object in = source();
out.put(in, null);
sink(getMapKey(out)); // $hasValueFlow
}
{
// "org.springframework.cache;Cache;true;put;;;Argument[1];MapValue of Argument[-1];value"
Cache out = null;
Object in = source();
out.put(null, in);
sink(getMapValue(out)); // $hasValueFlow
}
{
// "org.springframework.cache;Cache;true;putIfAbsent;;;Argument[0];MapKey of Argument[-1];value"
Cache out = null;
Object in = source();
out.putIfAbsent(in, null);
sink(getMapKey(out)); // $hasValueFlow
}
{
// "org.springframework.cache;Cache;true;putIfAbsent;;;Argument[1];MapValue of Argument[-1];value"
Cache out = null;
Object in = source();
out.putIfAbsent(null, in);
sink(getMapValue(out)); // $hasValueFlow
}
{
// "org.springframework.cache;Cache;true;putIfAbsent;;;MapValue of Argument[-1];MapValue of ReturnValue;value"
Cache.ValueWrapper out = null;
Cache in = (Cache)newWithMapValue(source());
out = in.putIfAbsent(null, null);
sink(getMapValue(out)); // $hasValueFlow
}
}
}

View File

@@ -0,0 +1 @@
//semmle-extractor-options: --javac-args -cp ${testdir}/../../../../stubs/springframework-5.3.8

View File

@@ -0,0 +1,66 @@
import java
import semmle.code.java.dataflow.DataFlow
import semmle.code.java.dataflow.ExternalFlow
import semmle.code.java.dataflow.TaintTracking
import TestUtilities.InlineExpectationsTest
class SummaryModelTest extends SummaryModelCsv {
override predicate row(string row) {
row =
[
//"package;type;overrides;name;signature;ext;inputspec;outputspec;kind",
"generatedtest;Test;false;getMapKey;;;MapKey of Argument[0];ReturnValue;value",
"generatedtest;Test;false;newWithMapKey;;;Argument[0];MapKey of ReturnValue;value",
"generatedtest;Test;false;getMapValue;;;MapValue of Argument[0];ReturnValue;value",
"generatedtest;Test;false;newWithMapValue;;;Argument[0];MapValue of ReturnValue;value"
]
}
}
class ValueFlowConf extends DataFlow::Configuration {
ValueFlowConf() { this = "qltest:valueFlowConf" }
override predicate isSource(DataFlow::Node n) {
n.asExpr().(MethodAccess).getMethod().hasName("source")
}
override predicate isSink(DataFlow::Node n) {
n.asExpr().(Argument).getCall().getCallee().hasName("sink")
}
}
class TaintFlowConf extends TaintTracking::Configuration {
TaintFlowConf() { this = "qltest:taintFlowConf" }
override predicate isSource(DataFlow::Node n) {
n.asExpr().(MethodAccess).getMethod().hasName("source")
}
override predicate isSink(DataFlow::Node n) {
n.asExpr().(Argument).getCall().getCallee().hasName("sink")
}
}
class HasFlowTest extends InlineExpectationsTest {
HasFlowTest() { this = "HasFlowTest" }
override string getARelevantTag() { result = ["hasValueFlow", "hasTaintFlow"] }
override predicate hasActualResult(Location location, string element, string tag, string value) {
tag = "hasValueFlow" and
exists(DataFlow::Node src, DataFlow::Node sink, ValueFlowConf conf | conf.hasFlow(src, sink) |
sink.getLocation() = location and
element = sink.toString() and
value = ""
)
or
tag = "hasTaintFlow" and
exists(DataFlow::Node src, DataFlow::Node sink, TaintFlowConf conf |
conf.hasFlow(src, sink) and not any(ValueFlowConf c).hasFlow(src, sink)
|
sink.getLocation() = location and
element = sink.toString() and
value = ""
)
}
}

View File

@@ -0,0 +1,575 @@
package generatedtest;
import java.util.Collection;
import java.util.Map;
import org.springframework.ui.ConcurrentModel;
import org.springframework.ui.Model;
import org.springframework.ui.ModelMap;
// Test case generated by GenerateFlowTestCase.ql
public class Test {
Object getMapKey(Object container) { return null; }
Object getMapValue(Object container) { return null; }
Object newWithElement(Object element) { return null; }
Object newWithMapKey(Object element) { return null; }
Object newWithMapValue(Object element) { return null; }
Object source() { return null; }
void sink(Object o) { }
public void test() {
{
// "org.springframework.ui;ConcurrentModel;false;ConcurrentModel;(Object);;Argument[0];MapValue of Argument[-1];value"
ConcurrentModel out = null;
Object in = source();
out = new ConcurrentModel(in);
sink(getMapValue(out)); // $hasValueFlow
}
{
// "org.springframework.ui;ConcurrentModel;false;ConcurrentModel;(String,Object);;Argument[0];MapKey of Argument[-1];value"
ConcurrentModel out = null;
String in = (String)source();
out = new ConcurrentModel(in, null);
sink(getMapKey(out)); // $hasValueFlow
}
{
// "org.springframework.ui;ConcurrentModel;false;ConcurrentModel;(String,Object);;Argument[1];MapValue of Argument[-1];value"
ConcurrentModel out = null;
Object in = source();
out = new ConcurrentModel(null, in);
sink(getMapValue(out)); // $hasValueFlow
}
{
// "org.springframework.ui;Model;true;addAllAttributes;(Collection);;Element of Argument[0];MapValue of Argument[-1];value"
Model out = null;
Collection in = (Collection)newWithElement(source());
out.addAllAttributes(in);
sink(getMapValue(out)); // $hasValueFlow
}
{
// "org.springframework.ui;Model;true;addAllAttributes;(Collection);;Element of Argument[0];MapValue of Argument[-1];value"
ConcurrentModel out = null;
Collection in = (Collection)newWithElement(source());
out.addAllAttributes(in);
sink(getMapValue(out)); // $hasValueFlow
}
{
// "org.springframework.ui;Model;true;addAllAttributes;(Collection);;Element of Argument[0];MapValue of ReturnValue;value"
Model out = null;
Collection in = (Collection)newWithElement(source());
Model instance = null;
out = instance.addAllAttributes(in);
sink(getMapValue(out)); // $hasValueFlow
}
{
// "org.springframework.ui;Model;true;addAllAttributes;(Collection);;Element of Argument[0];MapValue of ReturnValue;value"
ConcurrentModel out = null;
Collection in = (Collection)newWithElement(source());
ConcurrentModel instance = null;
out = instance.addAllAttributes(in);
sink(getMapValue(out)); // $hasValueFlow
}
{
// "org.springframework.ui;Model;true;addAllAttributes;(Map);;MapKey of Argument[0];MapKey of Argument[-1];value"
Model out = null;
Map in = (Map)newWithMapKey(source());
out.addAllAttributes(in);
sink(getMapKey(out)); // $hasValueFlow
}
{
// "org.springframework.ui;Model;true;addAllAttributes;(Map);;MapKey of Argument[0];MapKey of Argument[-1];value"
ConcurrentModel out = null;
Map in = (Map)newWithMapKey(source());
out.addAllAttributes(in);
sink(getMapKey(out)); // $hasValueFlow
}
{
// "org.springframework.ui;Model;true;addAllAttributes;(Map);;MapKey of Argument[0];MapKey of ReturnValue;value"
Model out = null;
Map in = (Map)newWithMapKey(source());
Model instance = null;
out = instance.addAllAttributes(in);
sink(getMapKey(out)); // $hasValueFlow
}
{
// "org.springframework.ui;Model;true;addAllAttributes;(Map);;MapKey of Argument[0];MapKey of ReturnValue;value"
ConcurrentModel out = null;
Map in = (Map)newWithMapKey(source());
ConcurrentModel instance = null;
out = instance.addAllAttributes(in);
sink(getMapKey(out)); // $hasValueFlow
}
{
// "org.springframework.ui;Model;true;addAllAttributes;(Map);;MapValue of Argument[0];MapValue of Argument[-1];value"
Model out = null;
Map in = (Map)newWithMapValue(source());
out.addAllAttributes(in);
sink(getMapValue(out)); // $hasValueFlow
}
{
// "org.springframework.ui;Model;true;addAllAttributes;(Map);;MapValue of Argument[0];MapValue of Argument[-1];value"
ConcurrentModel out = null;
Map in = (Map)newWithMapValue(source());
out.addAllAttributes(in);
sink(getMapValue(out)); // $hasValueFlow
}
{
// "org.springframework.ui;Model;true;addAllAttributes;(Map);;MapValue of Argument[0];MapValue of ReturnValue;value"
Model out = null;
Map in = (Map)newWithMapValue(source());
Model instance = null;
out = instance.addAllAttributes(in);
sink(getMapValue(out)); // $hasValueFlow
}
{
// "org.springframework.ui;Model;true;addAllAttributes;(Map);;MapValue of Argument[0];MapValue of ReturnValue;value"
ConcurrentModel out = null;
Map in = (Map)newWithMapValue(source());
ConcurrentModel instance = null;
out = instance.addAllAttributes(in);
sink(getMapValue(out)); // $hasValueFlow
}
{
// "org.springframework.ui;Model;true;addAllAttributes;;;Argument[-1];ReturnValue;value"
Model out = null;
Model in = (Model)source();
out = in.addAllAttributes((Map)null);
sink(out); // $hasValueFlow
}
{
// "org.springframework.ui;Model;true;addAllAttributes;;;Argument[-1];ReturnValue;value"
Model out = null;
Model in = (Model)source();
out = in.addAllAttributes((Collection)null);
sink(out); // $hasValueFlow
}
{
// "org.springframework.ui;Model;true;addAllAttributes;;;Argument[-1];ReturnValue;value"
ConcurrentModel out = null;
ConcurrentModel in = (ConcurrentModel)source();
out = in.addAllAttributes((Map)null);
sink(out); // $hasValueFlow
}
{
// "org.springframework.ui;Model;true;addAllAttributes;;;Argument[-1];ReturnValue;value"
ConcurrentModel out = null;
ConcurrentModel in = (ConcurrentModel)source();
out = in.addAllAttributes((Collection)null);
sink(out); // $hasValueFlow
}
{
// "org.springframework.ui;Model;true;addAttribute;(Object);;Argument[0];MapValue of Argument[-1];value"
Model out = null;
Object in = source();
out.addAttribute(in);
sink(getMapValue(out)); // $hasValueFlow
}
{
// "org.springframework.ui;Model;true;addAttribute;(Object);;Argument[0];MapValue of Argument[-1];value"
ConcurrentModel out = null;
Object in = source();
out.addAttribute(in);
sink(getMapValue(out)); // $hasValueFlow
}
{
// "org.springframework.ui;Model;true;addAttribute;(Object);;Argument[0];MapValue of ReturnValue;value"
Model out = null;
Object in = source();
Model instance = null;
out = instance.addAttribute(in);
sink(getMapValue(out)); // $hasValueFlow
}
{
// "org.springframework.ui;Model;true;addAttribute;(Object);;Argument[0];MapValue of ReturnValue;value"
ConcurrentModel out = null;
Object in = source();
ConcurrentModel instance = null;
out = instance.addAttribute(in);
sink(getMapValue(out)); // $hasValueFlow
}
{
// "org.springframework.ui;Model;true;addAttribute;(String,Object);;Argument[0];MapKey of Argument[-1];value"
Model out = null;
String in = (String)source();
out.addAttribute(in, null);
sink(getMapKey(out)); // $hasValueFlow
}
{
// "org.springframework.ui;Model;true;addAttribute;(String,Object);;Argument[0];MapKey of Argument[-1];value"
ConcurrentModel out = null;
String in = (String)source();
out.addAttribute(in, null);
sink(getMapKey(out)); // $hasValueFlow
}
{
// "org.springframework.ui;Model;true;addAttribute;(String,Object);;Argument[0];MapKey of ReturnValue;value"
Model out = null;
String in = (String)source();
Model instance = null;
out = instance.addAttribute(in, null);
sink(getMapKey(out)); // $hasValueFlow
}
{
// "org.springframework.ui;Model;true;addAttribute;(String,Object);;Argument[0];MapKey of ReturnValue;value"
ConcurrentModel out = null;
String in = (String)source();
ConcurrentModel instance = null;
out = instance.addAttribute(in, null);
sink(getMapKey(out)); // $hasValueFlow
}
{
// "org.springframework.ui;Model;true;addAttribute;(String,Object);;Argument[1];MapValue of Argument[-1];value"
Model out = null;
Object in = source();
out.addAttribute(null, in);
sink(getMapValue(out)); // $hasValueFlow
}
{
// "org.springframework.ui;Model;true;addAttribute;(String,Object);;Argument[1];MapValue of Argument[-1];value"
ConcurrentModel out = null;
Object in = source();
out.addAttribute(null, in);
sink(getMapValue(out)); // $hasValueFlow
}
{
// "org.springframework.ui;Model;true;addAttribute;(String,Object);;Argument[1];MapValue of ReturnValue;value"
Model out = null;
Object in = source();
Model instance = null;
out = instance.addAttribute(null, in);
sink(getMapValue(out)); // $hasValueFlow
}
{
// "org.springframework.ui;Model;true;addAttribute;(String,Object);;Argument[1];MapValue of ReturnValue;value"
ConcurrentModel out = null;
Object in = source();
ConcurrentModel instance = null;
out = instance.addAttribute(null, in);
sink(getMapValue(out)); // $hasValueFlow
}
{
// "org.springframework.ui;Model;true;addAttribute;;;Argument[-1];ReturnValue;value"
Model out = null;
Model in = (Model)source();
out = in.addAttribute(null, null);
sink(out); // $hasValueFlow
}
{
// "org.springframework.ui;Model;true;addAttribute;;;Argument[-1];ReturnValue;value"
Model out = null;
Model in = (Model)source();
out = in.addAttribute(null);
sink(out); // $hasValueFlow
}
{
// "org.springframework.ui;Model;true;addAttribute;;;Argument[-1];ReturnValue;value"
ConcurrentModel out = null;
ConcurrentModel in = (ConcurrentModel)source();
out = in.addAttribute(null, null);
sink(out); // $hasValueFlow
}
{
// "org.springframework.ui;Model;true;addAttribute;;;Argument[-1];ReturnValue;value"
ConcurrentModel out = null;
ConcurrentModel in = (ConcurrentModel)source();
out = in.addAttribute(null);
sink(out); // $hasValueFlow
}
{
// "org.springframework.ui;Model;true;asMap;;;MapKey of Argument[-1];MapKey of ReturnValue;value"
Map out = null;
Model in = (Model)newWithMapKey(source());
out = in.asMap();
sink(getMapKey(out)); // $hasValueFlow
}
{
// "org.springframework.ui;Model;true;asMap;;;MapKey of Argument[-1];MapKey of ReturnValue;value"
Map out = null;
ConcurrentModel in = (ConcurrentModel)newWithMapKey(source());
out = in.asMap();
sink(getMapKey(out)); // $hasValueFlow
}
{
// "org.springframework.ui;Model;true;asMap;;;MapValue of Argument[-1];MapValue of ReturnValue;value"
Map out = null;
Model in = (Model)newWithMapValue(source());
out = in.asMap();
sink(getMapValue(out)); // $hasValueFlow
}
{
// "org.springframework.ui;Model;true;asMap;;;MapValue of Argument[-1];MapValue of ReturnValue;value"
Map out = null;
ConcurrentModel in = (ConcurrentModel)newWithMapValue(source());
out = in.asMap();
sink(getMapValue(out)); // $hasValueFlow
}
{
// "org.springframework.ui;Model;true;getAttribute;;;MapValue of Argument[-1];ReturnValue;value"
Object out = null;
Model in = (Model)newWithMapValue(source());
out = in.getAttribute(null);
sink(out); // $hasValueFlow
}
{
// "org.springframework.ui;Model;true;getAttribute;;;MapValue of Argument[-1];ReturnValue;value"
Object out = null;
ConcurrentModel in = (ConcurrentModel)newWithMapValue(source());
out = in.getAttribute(null);
sink(out); // $hasValueFlow
}
{
// "org.springframework.ui;Model;true;mergeAttributes;;;Argument[-1];ReturnValue;value"
Model out = null;
Model in = (Model)source();
out = in.mergeAttributes(null);
sink(out); // $hasValueFlow
}
{
// "org.springframework.ui;Model;true;mergeAttributes;;;Argument[-1];ReturnValue;value"
ConcurrentModel out = null;
ConcurrentModel in = (ConcurrentModel)source();
out = in.mergeAttributes(null);
sink(out); // $hasValueFlow
}
{
// "org.springframework.ui;Model;true;mergeAttributes;;;MapKey of Argument[-1];MapKey of ReturnValue;value"
Model out = null;
Model in = (Model)newWithMapKey(source());
out = in.mergeAttributes(null);
sink(getMapKey(out)); // $hasValueFlow
}
{
// "org.springframework.ui;Model;true;mergeAttributes;;;MapKey of Argument[-1];MapKey of ReturnValue;value"
ConcurrentModel out = null;
ConcurrentModel in = (ConcurrentModel)newWithMapKey(source());
out = in.mergeAttributes(null);
sink(getMapKey(out)); // $hasValueFlow
}
{
// "org.springframework.ui;Model;true;mergeAttributes;;;MapKey of Argument[0];MapKey of Argument[-1];value"
Model out = null;
Map in = (Map)newWithMapKey(source());
out.mergeAttributes(in);
sink(getMapKey(out)); // $hasValueFlow
}
{
// "org.springframework.ui;Model;true;mergeAttributes;;;MapKey of Argument[0];MapKey of Argument[-1];value"
ConcurrentModel out = null;
Map in = (Map)newWithMapKey(source());
out.mergeAttributes(in);
sink(getMapKey(out)); // $hasValueFlow
}
{
// "org.springframework.ui;Model;true;mergeAttributes;;;MapValue of Argument[-1];MapValue of ReturnValue;value"
Model out = null;
Model in = (Model)newWithMapValue(source());
out = in.mergeAttributes(null);
sink(getMapValue(out)); // $hasValueFlow
}
{
// "org.springframework.ui;Model;true;mergeAttributes;;;MapValue of Argument[-1];MapValue of ReturnValue;value"
ConcurrentModel out = null;
ConcurrentModel in = (ConcurrentModel)newWithMapValue(source());
out = in.mergeAttributes(null);
sink(getMapValue(out)); // $hasValueFlow
}
{
// "org.springframework.ui;Model;true;mergeAttributes;;;MapValue of Argument[0];MapValue of Argument[-1];value"
Model out = null;
Map in = (Map)newWithMapValue(source());
out.mergeAttributes(in);
sink(getMapValue(out)); // $hasValueFlow
}
{
// "org.springframework.ui;Model;true;mergeAttributes;;;MapValue of Argument[0];MapValue of Argument[-1];value"
ConcurrentModel out = null;
Map in = (Map)newWithMapValue(source());
out.mergeAttributes(in);
sink(getMapValue(out)); // $hasValueFlow
}
{
// "org.springframework.ui;ModelMap;false;ModelMap;(Object);;Argument[0];MapValue of Argument[-1];value"
ModelMap out = null;
Object in = source();
out = new ModelMap(in);
sink(getMapValue(out)); // $hasValueFlow
}
{
// "org.springframework.ui;ModelMap;false;ModelMap;(String,Object);;Argument[0];MapKey of Argument[-1];value"
ModelMap out = null;
String in = (String)source();
out = new ModelMap(in, null);
sink(getMapKey(out)); // $hasValueFlow
}
{
// "org.springframework.ui;ModelMap;false;ModelMap;(String,Object);;Argument[1];MapValue of Argument[-1];value"
ModelMap out = null;
Object in = source();
out = new ModelMap(null, in);
sink(getMapValue(out)); // $hasValueFlow
}
{
// "org.springframework.ui;ModelMap;false;addAllAttributes;(Collection);;Element of Argument[0];MapValue of Argument[-1];value"
ModelMap out = null;
Collection in = (Collection)newWithElement(source());
out.addAllAttributes(in);
sink(getMapValue(out)); // $hasValueFlow
}
{
// "org.springframework.ui;ModelMap;false;addAllAttributes;(Collection);;Element of Argument[0];MapValue of ReturnValue;value"
ModelMap out = null;
Collection in = (Collection)newWithElement(source());
ModelMap instance = null;
out = instance.addAllAttributes(in);
sink(getMapValue(out)); // $hasValueFlow
}
{
// "org.springframework.ui;ModelMap;false;addAllAttributes;(Map);;MapKey of Argument[0];MapKey of Argument[-1];value"
ModelMap out = null;
Map in = (Map)newWithMapKey(source());
out.addAllAttributes(in);
sink(getMapKey(out)); // $hasValueFlow
}
{
// "org.springframework.ui;ModelMap;false;addAllAttributes;(Map);;MapKey of Argument[0];MapKey of ReturnValue;value"
ModelMap out = null;
Map in = (Map)newWithMapKey(source());
ModelMap instance = null;
out = instance.addAllAttributes(in);
sink(getMapKey(out)); // $hasValueFlow
}
{
// "org.springframework.ui;ModelMap;false;addAllAttributes;(Map);;MapValue of Argument[0];MapValue of Argument[-1];value"
ModelMap out = null;
Map in = (Map)newWithMapValue(source());
out.addAllAttributes(in);
sink(getMapValue(out)); // $hasValueFlow
}
{
// "org.springframework.ui;ModelMap;false;addAllAttributes;(Map);;MapValue of Argument[0];MapValue of ReturnValue;value"
ModelMap out = null;
Map in = (Map)newWithMapValue(source());
ModelMap instance = null;
out = instance.addAllAttributes(in);
sink(getMapValue(out)); // $hasValueFlow
}
{
// "org.springframework.ui;ModelMap;false;addAllAttributes;;;Argument[-1];ReturnValue;value"
ModelMap out = null;
ModelMap in = (ModelMap)source();
out = in.addAllAttributes((Map)null);
sink(out); // $hasValueFlow
}
{
// "org.springframework.ui;ModelMap;false;addAllAttributes;;;Argument[-1];ReturnValue;value"
ModelMap out = null;
ModelMap in = (ModelMap)source();
out = in.addAllAttributes((Collection)null);
sink(out); // $hasValueFlow
}
{
// "org.springframework.ui;ModelMap;false;addAttribute;(Object);;Argument[0];MapValue of Argument[-1];value"
ModelMap out = null;
Object in = source();
out.addAttribute(in);
sink(getMapValue(out)); // $hasValueFlow
}
{
// "org.springframework.ui;ModelMap;false;addAttribute;(Object);;Argument[0];MapValue of ReturnValue;value"
ModelMap out = null;
Object in = source();
ModelMap instance = null;
out = instance.addAttribute(in);
sink(getMapValue(out)); // $hasValueFlow
}
{
// "org.springframework.ui;ModelMap;false;addAttribute;(String,Object);;Argument[0];MapKey of Argument[-1];value"
ModelMap out = null;
String in = (String)source();
out.addAttribute(in, null);
sink(getMapKey(out)); // $hasValueFlow
}
{
// "org.springframework.ui;ModelMap;false;addAttribute;(String,Object);;Argument[0];MapKey of ReturnValue;value"
ModelMap out = null;
String in = (String)source();
ModelMap instance = null;
out = instance.addAttribute(in, null);
sink(getMapKey(out)); // $hasValueFlow
}
{
// "org.springframework.ui;ModelMap;false;addAttribute;(String,Object);;Argument[1];MapValue of Argument[-1];value"
ModelMap out = null;
Object in = source();
out.addAttribute(null, in);
sink(getMapValue(out)); // $hasValueFlow
}
{
// "org.springframework.ui;ModelMap;false;addAttribute;(String,Object);;Argument[1];MapValue of ReturnValue;value"
ModelMap out = null;
Object in = source();
ModelMap instance = null;
out = instance.addAttribute(null, in);
sink(getMapValue(out)); // $hasValueFlow
}
{
// "org.springframework.ui;ModelMap;false;addAttribute;;;Argument[-1];ReturnValue;value"
ModelMap out = null;
ModelMap in = (ModelMap)source();
out = in.addAttribute(null, null);
sink(out); // $hasValueFlow
}
{
// "org.springframework.ui;ModelMap;false;addAttribute;;;Argument[-1];ReturnValue;value"
ModelMap out = null;
ModelMap in = (ModelMap)source();
out = in.addAttribute(null);
sink(out); // $hasValueFlow
}
{
// "org.springframework.ui;ModelMap;false;getAttribute;;;MapValue of Argument[-1];ReturnValue;value"
Object out = null;
ModelMap in = (ModelMap)newWithMapValue(source());
out = in.getAttribute(null);
sink(out); // $hasValueFlow
}
{
// "org.springframework.ui;ModelMap;false;mergeAttributes;;;Argument[-1];ReturnValue;value"
ModelMap out = null;
ModelMap in = (ModelMap)source();
out = in.mergeAttributes(null);
sink(out); // $hasValueFlow
}
{
// "org.springframework.ui;ModelMap;false;mergeAttributes;;;MapKey of Argument[-1];MapKey of ReturnValue;value"
ModelMap out = null;
ModelMap in = (ModelMap)newWithMapKey(source());
out = in.mergeAttributes(null);
sink(getMapKey(out)); // $hasValueFlow
}
{
// "org.springframework.ui;ModelMap;false;mergeAttributes;;;MapKey of Argument[0];MapKey of Argument[-1];value"
ModelMap out = null;
Map in = (Map)newWithMapKey(source());
out.mergeAttributes(in);
sink(getMapKey(out)); // $hasValueFlow
}
{
// "org.springframework.ui;ModelMap;false;mergeAttributes;;;MapValue of Argument[-1];MapValue of ReturnValue;value"
ModelMap out = null;
ModelMap in = (ModelMap)newWithMapValue(source());
out = in.mergeAttributes(null);
sink(getMapValue(out)); // $hasValueFlow
}
{
// "org.springframework.ui;ModelMap;false;mergeAttributes;;;MapValue of Argument[0];MapValue of Argument[-1];value"
ModelMap out = null;
Map in = (Map)newWithMapValue(source());
out.mergeAttributes(in);
sink(getMapValue(out)); // $hasValueFlow
}
}
}

View File

@@ -0,0 +1 @@
//semmle-extractor-options: --javac-args -cp ${testdir}/../../../../stubs/springframework-5.3.8

View File

@@ -0,0 +1,67 @@
import java
import semmle.code.java.dataflow.DataFlow
import semmle.code.java.dataflow.ExternalFlow
import semmle.code.java.dataflow.TaintTracking
import TestUtilities.InlineExpectationsTest
class SummaryModelTest extends SummaryModelCsv {
override predicate row(string row) {
row =
[
//"package;type;overrides;name;signature;ext;inputspec;outputspec;kind",
"generatedtest;Test;false;getMapKey;;;MapKey of Argument[0];ReturnValue;value",
"generatedtest;Test;false;newWithMapKey;;;Argument[0];MapKey of ReturnValue;value",
"generatedtest;Test;false;newWithElement;;;Argument[0];Element of ReturnValue;value",
"generatedtest;Test;false;getMapValue;;;MapValue of Argument[0];ReturnValue;value",
"generatedtest;Test;false;newWithMapValue;;;Argument[0];MapValue of ReturnValue;value"
]
}
}
class ValueFlowConf extends DataFlow::Configuration {
ValueFlowConf() { this = "qltest:valueFlowConf" }
override predicate isSource(DataFlow::Node n) {
n.asExpr().(MethodAccess).getMethod().hasName("source")
}
override predicate isSink(DataFlow::Node n) {
n.asExpr().(Argument).getCall().getCallee().hasName("sink")
}
}
class TaintFlowConf extends TaintTracking::Configuration {
TaintFlowConf() { this = "qltest:taintFlowConf" }
override predicate isSource(DataFlow::Node n) {
n.asExpr().(MethodAccess).getMethod().hasName("source")
}
override predicate isSink(DataFlow::Node n) {
n.asExpr().(Argument).getCall().getCallee().hasName("sink")
}
}
class HasFlowTest extends InlineExpectationsTest {
HasFlowTest() { this = "HasFlowTest" }
override string getARelevantTag() { result = ["hasValueFlow", "hasTaintFlow"] }
override predicate hasActualResult(Location location, string element, string tag, string value) {
tag = "hasValueFlow" and
exists(DataFlow::Node src, DataFlow::Node sink, ValueFlowConf conf | conf.hasFlow(src, sink) |
sink.getLocation() = location and
element = sink.toString() and
value = ""
)
or
tag = "hasTaintFlow" and
exists(DataFlow::Node src, DataFlow::Node sink, TaintFlowConf conf |
conf.hasFlow(src, sink) and not any(ValueFlowConf c).hasFlow(src, sink)
|
sink.getLocation() = location and
element = sink.toString() and
value = ""
)
}
}