diff --git a/infer/lib/java/android/BUCK b/infer/lib/java/android/BUCK index 9a16e5377..29d842686 100644 --- a/infer/lib/java/android/BUCK +++ b/infer/lib/java/android/BUCK @@ -1,6 +1,6 @@ prebuilt_jar( name = 'android', - binary_jar = 'android-19.jar', + binary_jar = 'android-23.jar', visibility = [ 'PUBLIC' ] diff --git a/infer/lib/java/android/android-19.jar b/infer/lib/java/android/android-23.jar similarity index 56% rename from infer/lib/java/android/android-19.jar rename to infer/lib/java/android/android-23.jar index b9aada2db..3e2434de4 100644 Binary files a/infer/lib/java/android/android-19.jar and b/infer/lib/java/android/android-23.jar differ diff --git a/infer/models/java/Makefile b/infer/models/java/Makefile index 7221e4db5..50f336720 100644 --- a/infer/models/java/Makefile +++ b/infer/models/java/Makefile @@ -8,9 +8,11 @@ ROOT_DIR = ../../.. include $(ROOT_DIR)/Makefile.config -ANDROID_JAR = $(LIB_DIR)/java/android/android-19.jar -JACKSON_JAR = $(DEPENDENCIES_DIR)/java/jackson/jackson-2.2.3.jar +ANDROID_JAR = $(LIB_DIR)/java/android/android-23.jar +GUAVA_JAR = $(DEPENDENCIES_DIR)/java/guava/guava-10.0.1-fork.jar INFER_ANNOTATIONS_JAR = $(ANNOTATIONS_DIR)/annotations.jar +JACKSON_JAR = $(DEPENDENCIES_DIR)/java/jackson/jackson-2.2.3.jar +JSR_305_JAR = $(DEPENDENCIES_DIR)/java/jsr-305/jsr305.jar MODELS_OUT = models INFER_REPORT = $(MODELS_OUT)/infer/report.json @@ -21,6 +23,8 @@ JAVA_MODELS_SOURCES = $(shell find src -name "*.java") JAVA_SOURCES = $(JAVA_BUILTINS_SOURCES) $(JAVA_MODELS_SOURCES) +MODELS_CLASSPATH = $(ANDROID_JAR):$(GUAVA_JAR):$(JACKSON_JAR):$(JSR_305_JAR):$(INFER_ANNOTATIONS_JAR) + all: $(MODELS_JAR) clean: @@ -28,12 +32,12 @@ clean: @rm -f $(MODELS_JAR) @rm -f $(JAVA_MODELS_JAR) -$(INFER_REPORT): $(ANDROID_JAR) $(JACKSON_JAR) $(JAVA_DEPS) $(INFER_ANNOTATIONS_JAR) $(JAVA_SOURCES) +$(INFER_REPORT): $(ANDROID_JAR) $(GUAVA_JAR) $(JACKSON_JAR) $(JSR_305_JAR) $(INFER_ANNOTATIONS_JAR) $(JAVA_DEPS) $(JAVA_SOURCES) @rm -fr $(MODELS_OUT) mkdir -p $(MODELS_OUT) @rm -f $(JAVA_MODELS_JAR) $(call silent_on_success,\ - $(INFER_BIN) --jobs 1 --buck --models-mode -- javac -bootclasspath $(ANDROID_JAR) -d $(MODELS_OUT) -classpath $(JACKSON_JAR):$(INFER_ANNOTATIONS_JAR) $(JAVA_SOURCES)) + $(INFER_BIN) --jobs 1 --buck --models-mode -- javac -bootclasspath $(ANDROID_JAR) -d $(MODELS_OUT) -classpath $(MODELS_CLASSPATH) $(JAVA_SOURCES)) $(MODELS_JAR): $(INFER_REPORT) cd $(MODELS_OUT); jar cf ../$(MODELS_JAR) * diff --git a/infer/models/java/build.xml b/infer/models/java/build.xml index 25e4840a4..18def6380 100644 --- a/infer/models/java/build.xml +++ b/infer/models/java/build.xml @@ -8,7 +8,7 @@ - + diff --git a/infer/models/java/src/com/fasterxml/jackson/core/JsonFactory.java b/infer/models/java/src/com/fasterxml/jackson/core/JsonFactory.java index a4c4893de..2d8276650 100644 --- a/infer/models/java/src/com/fasterxml/jackson/core/JsonFactory.java +++ b/infer/models/java/src/com/fasterxml/jackson/core/JsonFactory.java @@ -9,7 +9,6 @@ package com.fasterxml.jackson.core; -import com.android.internal.util.FileRotator.Reader; import com.fasterxml.jackson.core.json.PackageVersion; import com.fasterxml.jackson.core.json.UTF8StreamJsonParser; @@ -17,12 +16,12 @@ import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; +import java.io.Reader; import java.net.URL; public class JsonFactory implements Versioned, java.io.Serializable { - @Override public Version version() { return PackageVersion.VERSION; diff --git a/infer/tests/build_systems/ant/build.xml b/infer/tests/build_systems/ant/build.xml index b50bb1ea1..6511b884e 100644 --- a/infer/tests/build_systems/ant/build.xml +++ b/infer/tests/build_systems/ant/build.xml @@ -8,10 +8,14 @@ - - + + - + + + + + diff --git a/infer/tests/build_systems/ant/issues.exp b/infer/tests/build_systems/ant/issues.exp index d9b5f86c2..008e171a2 100644 --- a/infer/tests/build_systems/ant/issues.exp +++ b/infer/tests/build_systems/ant/issues.exp @@ -151,6 +151,7 @@ codetoanalyze/java/infer/ResourceLeaks.java, void ResourceLeaks.objectOutputStre codetoanalyze/java/infer/ResourceLeaks.java, void ResourceLeaks.openHttpURLConnectionNotDisconnected(), 7, RESOURCE_LEAK, [start of procedure openHttpURLConnectionNotDisconnected()] codetoanalyze/java/infer/ResourceLeaks.java, void ResourceLeaks.openHttpsURLConnectionNotDisconnected(), 3, RESOURCE_LEAK, [start of procedure openHttpsURLConnectionNotDisconnected()] codetoanalyze/java/infer/ResourceLeaks.java, void ResourceLeaks.parseFromInputStreamAndLeak(JsonFactory), 5, RESOURCE_LEAK, [start of procedure parseFromInputStreamAndLeak(...)] +codetoanalyze/java/infer/ResourceLeaks.java, void ResourceLeaks.parseFromStringAndNotClose(JsonFactory), 4, RESOURCE_LEAK, [start of procedure parseFromStringAndNotClose(...)] codetoanalyze/java/infer/ResourceLeaks.java, void ResourceLeaks.pipedInputStreamNotClosedAfterRead(PipedOutputStream), 6, RESOURCE_LEAK, [start of procedure pipedInputStreamNotClosedAfterRead(...),exception java.io.IOException] codetoanalyze/java/infer/ResourceLeaks.java, void ResourceLeaks.pipedOutputStreamNotClosedAfterWrite(), 7, RESOURCE_LEAK, [start of procedure pipedOutputStreamNotClosedAfterWrite(),exception java.io.IOException] codetoanalyze/java/infer/ResourceLeaks.java, void ResourceLeaks.scannerNotClosed(), 1, RESOURCE_LEAK, [start of procedure scannerNotClosed()] diff --git a/infer/tests/build_systems/buck/issues.exp b/infer/tests/build_systems/buck/issues.exp index 1978aecb7..ddea57a9a 100644 --- a/infer/tests/build_systems/buck/issues.exp +++ b/infer/tests/build_systems/buck/issues.exp @@ -151,6 +151,7 @@ infer/tests/codetoanalyze/java/infer/ResourceLeaks.java, void ResourceLeaks.obje infer/tests/codetoanalyze/java/infer/ResourceLeaks.java, void ResourceLeaks.openHttpURLConnectionNotDisconnected(), 7, RESOURCE_LEAK, [start of procedure openHttpURLConnectionNotDisconnected()] infer/tests/codetoanalyze/java/infer/ResourceLeaks.java, void ResourceLeaks.openHttpsURLConnectionNotDisconnected(), 3, RESOURCE_LEAK, [start of procedure openHttpsURLConnectionNotDisconnected()] infer/tests/codetoanalyze/java/infer/ResourceLeaks.java, void ResourceLeaks.parseFromInputStreamAndLeak(JsonFactory), 5, RESOURCE_LEAK, [start of procedure parseFromInputStreamAndLeak(...)] +infer/tests/codetoanalyze/java/infer/ResourceLeaks.java, void ResourceLeaks.parseFromStringAndNotClose(JsonFactory), 4, RESOURCE_LEAK, [start of procedure parseFromStringAndNotClose(...)] infer/tests/codetoanalyze/java/infer/ResourceLeaks.java, void ResourceLeaks.pipedInputStreamNotClosedAfterRead(PipedOutputStream), 6, RESOURCE_LEAK, [start of procedure pipedInputStreamNotClosedAfterRead(...),exception java.io.IOException] infer/tests/codetoanalyze/java/infer/ResourceLeaks.java, void ResourceLeaks.pipedOutputStreamNotClosedAfterWrite(), 7, RESOURCE_LEAK, [start of procedure pipedOutputStreamNotClosedAfterWrite(),exception java.io.IOException] infer/tests/codetoanalyze/java/infer/ResourceLeaks.java, void ResourceLeaks.scannerNotClosed(), 1, RESOURCE_LEAK, [start of procedure scannerNotClosed()] diff --git a/infer/tests/codetoanalyze/java/harness/issues.exp b/infer/tests/codetoanalyze/java/harness/issues.exp index 147db9bba..5beb83bd0 100644 --- a/infer/tests/codetoanalyze/java/harness/issues.exp +++ b/infer/tests/codetoanalyze/java/harness/issues.exp @@ -1 +1 @@ -codetoanalyze/java/harness/BasicHarnessActivity.java, codetoanalyze.java.harness.BasicHarnessActivity.InferGeneratedHarness(), -1, NULL_DEREFERENCE, [start of procedure InferGeneratedHarness(),start of procedure onCreate(...),return from a call to void BasicHarnessActivity.onCreate(Bundle),start of procedure onPause(),return from a call to void BasicHarnessActivity.onPause(),start of procedure onDestroy()] +codetoanalyze/java/harness/BasicHarnessActivity.java, codetoanalyze.java.harness.BasicHarnessActivity.InferGeneratedHarness(), -1, NULL_DEREFERENCE, [start of procedure InferGeneratedHarness(),start of procedure onPause(),return from a call to void BasicHarnessActivity.onPause(),start of procedure onDestroy()] diff --git a/infer/tests/codetoanalyze/java/infer/ResourceLeaks.java b/infer/tests/codetoanalyze/java/infer/ResourceLeaks.java index e1db9eb47..cd9cf1384 100644 --- a/infer/tests/codetoanalyze/java/infer/ResourceLeaks.java +++ b/infer/tests/codetoanalyze/java/infer/ResourceLeaks.java @@ -690,7 +690,7 @@ public class ResourceLeaks { public void parseFromStringAndNotClose(JsonFactory factory) throws IOException { UTF8StreamJsonParser parser = null; try { - parser = (UTF8StreamJsonParser) factory.createParser("[]"); + parser = (UTF8StreamJsonParser) factory.createParser(new File("[]")); Object o = parser.readValueAs(Object.class); ignore(o); } catch (Exception e) { diff --git a/infer/tests/codetoanalyze/java/infer/issues.exp b/infer/tests/codetoanalyze/java/infer/issues.exp index 77ccdd861..fa2de3f48 100644 --- a/infer/tests/codetoanalyze/java/infer/issues.exp +++ b/infer/tests/codetoanalyze/java/infer/issues.exp @@ -262,7 +262,8 @@ codetoanalyze/java/infer/ResourceLeaks.java, void ResourceLeaks.objectOutputStre codetoanalyze/java/infer/ResourceLeaks.java, void ResourceLeaks.openHttpURLConnectionNotDisconnected(), 7, RESOURCE_LEAK, [start of procedure openHttpURLConnectionNotDisconnected()] codetoanalyze/java/infer/ResourceLeaks.java, void ResourceLeaks.openHttpsURLConnectionNotDisconnected(), 3, RESOURCE_LEAK, [start of procedure openHttpsURLConnectionNotDisconnected()] codetoanalyze/java/infer/ResourceLeaks.java, void ResourceLeaks.parseFromInputStreamAndLeak(JsonFactory), 5, RESOURCE_LEAK, [start of procedure parseFromInputStreamAndLeak(...)] -codetoanalyze/java/infer/ResourceLeaks.java, void ResourceLeaks.parseFromInputStreamAndLeak(JsonFactory), 10, NULL_TEST_AFTER_DEREFERENCE, [start of procedure parseFromInputStreamAndLeak(...),exception com.fasterxml.jackson.core.JsonParseException,Switch condition is true. Entering switch case,Taking false branch] +codetoanalyze/java/infer/ResourceLeaks.java, void ResourceLeaks.parseFromInputStreamAndLeak(JsonFactory), 10, NULL_TEST_AFTER_DEREFERENCE, [start of procedure parseFromInputStreamAndLeak(...),exception java.io.IOException,Switch condition is true. Entering switch case,Taking false branch] +codetoanalyze/java/infer/ResourceLeaks.java, void ResourceLeaks.parseFromStringAndNotClose(JsonFactory), 4, RESOURCE_LEAK, [start of procedure parseFromStringAndNotClose(...)] codetoanalyze/java/infer/ResourceLeaks.java, void ResourceLeaks.pipedInputStreamClosed(PipedOutputStream), 4, RETURN_VALUE_IGNORED, [start of procedure pipedInputStreamClosed(...)] codetoanalyze/java/infer/ResourceLeaks.java, void ResourceLeaks.pipedInputStreamNotClosedAfterRead(PipedOutputStream), 4, RETURN_VALUE_IGNORED, [start of procedure pipedInputStreamNotClosedAfterRead(...)] codetoanalyze/java/infer/ResourceLeaks.java, void ResourceLeaks.pipedInputStreamNotClosedAfterRead(PipedOutputStream), 6, RESOURCE_LEAK, [start of procedure pipedInputStreamNotClosedAfterRead(...),exception java.io.IOException] diff --git a/infer/tests/codetoanalyze/java/quandary/WebViews.java b/infer/tests/codetoanalyze/java/quandary/WebViews.java index d4f6f84a2..316fa539d 100644 --- a/infer/tests/codetoanalyze/java/quandary/WebViews.java +++ b/infer/tests/codetoanalyze/java/quandary/WebViews.java @@ -10,7 +10,12 @@ package codetoanalyze.java.quandary; import android.content.Context; + +import android.content.Intent; +import android.net.Uri; import android.webkit.JavascriptInterface; +import android.webkit.ValueCallback; +import android.webkit.WebMessage; import android.webkit.WebView; import android.webkit.WebViewClient; import android.webkit.WebChromeClient; @@ -27,6 +32,7 @@ public class WebViews { webview.loadData(stringSource, "", ""); webview.loadDataWithBaseURL("", stringSource, "", "", ""); webview.loadUrl(stringSource); // should have 5 reports + webview.postWebMessage(null, (Uri) InferTaint.inferSecretSource()); } void callWebviewClientSinks(WebView webview, WebViewClient client) { diff --git a/infer/tests/codetoanalyze/java/quandary/issues.exp b/infer/tests/codetoanalyze/java/quandary/issues.exp index 6e4fee35b..bd44731f6 100644 --- a/infer/tests/codetoanalyze/java/quandary/issues.exp +++ b/infer/tests/codetoanalyze/java/quandary/issues.exp @@ -179,6 +179,7 @@ codetoanalyze/java/quandary/WebViews.java, void WebViews.callWebviewSinks(WebVie codetoanalyze/java/quandary/WebViews.java, void WebViews.callWebviewSinks(WebView), 5, QUANDARY_TAINT_ERROR, [return from Object InferTaint.inferSecretSource(),call to void WebView.loadData(String,String,String)] codetoanalyze/java/quandary/WebViews.java, void WebViews.callWebviewSinks(WebView), 6, QUANDARY_TAINT_ERROR, [return from Object InferTaint.inferSecretSource(),call to void WebView.loadDataWithBaseURL(String,String,String,String,String)] codetoanalyze/java/quandary/WebViews.java, void WebViews.callWebviewSinks(WebView), 7, QUANDARY_TAINT_ERROR, [return from Object InferTaint.inferSecretSource(),call to void WebView.loadUrl(String)] +codetoanalyze/java/quandary/WebViews.java, void WebViews.callWebviewSinks(WebView), 8, QUANDARY_TAINT_ERROR, [return from Object InferTaint.inferSecretSource(),call to void WebView.postWebMessage(WebMessage,Uri)] codetoanalyze/java/quandary/WebViews.java, void WebViews.callWebviewSubclassSinks(WebViews$MyWebView,WebViews$MyWebViewClient,WebViews$MyWebChromeClient), 4, QUANDARY_TAINT_ERROR, [return from Object InferTaint.inferSecretSource(),call to void WebView.evaluateJavascript(String,ValueCallback)] codetoanalyze/java/quandary/WebViews.java, void WebViews.callWebviewSubclassSinks(WebViews$MyWebView,WebViews$MyWebViewClient,WebViews$MyWebChromeClient), 5, QUANDARY_TAINT_ERROR, [return from Object InferTaint.inferSecretSource(),call to void WebViewClient.onLoadResource(WebView,String)] codetoanalyze/java/quandary/WebViews.java, void WebViews.callWebviewSubclassSinks(WebViews$MyWebView,WebViews$MyWebViewClient,WebViews$MyWebChromeClient), 6, QUANDARY_TAINT_ERROR, [return from Object InferTaint.inferSecretSource(),call to boolean WebChromeClient.onJsAlert(WebView,String,String,JsResult)] diff --git a/infer/tests/java.make b/infer/tests/java.make index d82a4af53..7b695ad84 100644 --- a/infer/tests/java.make +++ b/infer/tests/java.make @@ -9,12 +9,13 @@ ROOT_DIR = $(TESTS_DIR)/../.. include $(ROOT_DIR)/Makefile.config -ANDROID19 = $(JAVA_LIB_DIR)/android/android-19.jar +ANDROID = $(JAVA_LIB_DIR)/android/android-23.jar ANDROIDSUPPORT = $(DEPENDENCIES_DIR)/java/android/support/v4/android-support-v4.jar ANNOTATIONS = $(ANNOTATIONS_DIR)/annotations.jar BUTTERKNIFE = $(DEPENDENCIES_DIR)/java/butterknife/butterknife-7.0.1.jar +GUAVA = $(DEPENDENCIES_DIR)/java/guava/guava-10.0.1-fork.jar JACKSON = $(DEPENDENCIES_DIR)/java/jackson/jackson-2.2.3.jar JSR305 = $(DEPENDENCIES_DIR)/java/jsr-305/jsr305.jar INJECT = $(DEPENDENCIES_DIR)/java/jsr-330/javax.inject.jar -CLASSPATH=$(ANDROID19):$(ANDROIDSUPPORT):$(ANNOTATIONS):$(BUTTERKNIFE):$(JACKSON):$(JSR305):$(INJECT):$(JAVA_BUILTINS_DIR):. +CLASSPATH=$(ANDROID):$(ANDROIDSUPPORT):$(ANNOTATIONS):$(BUTTERKNIFE):$(GUAVA):$(JACKSON):$(JSR305):$(INJECT):$(JAVA_BUILTINS_DIR):.