Reviewed By: sblackshear Differential Revision: D3784844 fbshipit-source-id: 44c021dmaster
parent
0caa7e1826
commit
674f30de2c
@ -0,0 +1,25 @@
|
||||
{
|
||||
"never_returning_null": [
|
||||
{
|
||||
"language": "Java",
|
||||
"source_contains": "_AUTOMATICALLY_GENERATED_"
|
||||
},
|
||||
{
|
||||
"language": "Java",
|
||||
"class": "codetoanalyze.java.infer.SomeLibrary",
|
||||
"method": "get"
|
||||
}
|
||||
],
|
||||
"infer-blacklist-files-containing": [
|
||||
"@generated"
|
||||
],
|
||||
"enable_checks": [
|
||||
"UNSAFE_GUARDED_BY_ACCESS"
|
||||
],
|
||||
"skip_translation": [
|
||||
{
|
||||
"language": "Java",
|
||||
"source_contains": "_SHOULD_BE_SKIPPED_"
|
||||
}
|
||||
]
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
# Copyright (c) 2016 - present Facebook, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# This source code is licensed under the BSD style license found in the
|
||||
# LICENSE file in the root directory of this source tree. An additional grant
|
||||
# of patent rights can be found in the PATENTS file in the same directory.
|
||||
|
||||
include ../Makefile
|
||||
|
||||
ANALYZER = infer
|
||||
|
||||
FILES = \
|
||||
SomeLibrary.java \
|
||||
SkippedSourceFile.java \
|
||||
T.java \
|
||||
Utils.java \
|
||||
\
|
||||
AnalysisStops.java \
|
||||
ArrayOutOfBounds.java \
|
||||
AutoGenerated.java \
|
||||
Builtins.java \
|
||||
ClassCastExceptions.java \
|
||||
CloseableAsResourceExample.java \
|
||||
ContextLeaks.java \
|
||||
CursorLeaks.java \
|
||||
DivideByZero.java \
|
||||
DynamicDispatch.java \
|
||||
FilterInputStreamLeaks.java \
|
||||
FilterOutputStreamLeaks.java \
|
||||
GuardedByExample.java \
|
||||
HashMapExample.java \
|
||||
IntegerExample.java \
|
||||
JunitAssertion.java \
|
||||
NeverNullSource.java \
|
||||
NullPointerExceptions.java \
|
||||
ReaderLeaks.java \
|
||||
ResourceLeaks.java \
|
||||
ReturnValueIgnored.java \
|
||||
TaintExample.java \
|
||||
WriterLeaks.java \
|
||||
|
||||
compile:
|
||||
javac -cp $(CLASSPATH) $(FILES)
|
||||
|
||||
analyze:
|
||||
$(INFER_BIN) -a $(ANALYZER) -- javac -cp $(CLASSPATH) $(FILES) >/dev/null 2>/dev/null
|
@ -0,0 +1,214 @@
|
||||
AnalysisStops.java, void AnalysisStops.accessPathInCalleeMayCauseFalseNegative(), 3, NULL_DEREFERENCE
|
||||
AnalysisStops.java, void AnalysisStops.callOnCastUndefinedObjMayCauseFalseNegative(), 3, DIVIDE_BY_ZERO
|
||||
AnalysisStops.java, void AnalysisStops.callOnUndefinedObjMayCauseFalseNegative(), 2, DIVIDE_BY_ZERO
|
||||
AnalysisStops.java, void AnalysisStops.castFailureOnUndefinedObjMayCauseFalseNegative(), 1, RETURN_VALUE_IGNORED
|
||||
AnalysisStops.java, void AnalysisStops.castFailureOnUndefinedObjMayCauseFalseNegative(), 2, DIVIDE_BY_ZERO
|
||||
AnalysisStops.java, void AnalysisStops.fieldReadAferCastMayCauseFalseNegative(Iterator), 6, DIVIDE_BY_ZERO
|
||||
AnalysisStops.java, void AnalysisStops.fieldReadInCalleeMayCauseFalseNegative(), 3, NULL_DEREFERENCE
|
||||
AnalysisStops.java, void AnalysisStops.fieldReadInCalleeWithAngelicObjFieldMayCauseFalseNegative(), 3, NULL_DEREFERENCE
|
||||
AnalysisStops.java, void AnalysisStops.fieldReadOnUndefinedObjMayCauseFalseNegative(), 3, DIVIDE_BY_ZERO
|
||||
AnalysisStops.java, void AnalysisStops.fieldWriteOnUndefinedObjMayCauseFalseNegative(), 3, DIVIDE_BY_ZERO
|
||||
AnalysisStops.java, void AnalysisStops.heapFieldOfAngelicObjMayCauseFalseNegative(), 4, DIVIDE_BY_ZERO
|
||||
AnalysisStops.java, void AnalysisStops.infiniteMaterializationMayCauseFalseNegative(boolean), 5, DIVIDE_BY_ZERO
|
||||
AnalysisStops.java, void AnalysisStops.primitiveFieldOfAngelicObjMayCauseFalseNegative(), 3, DIVIDE_BY_ZERO
|
||||
AnalysisStops.java, void AnalysisStops.primitiveFieldOfAngelicObjMayCauseFalseNegative(), 5, DIVIDE_BY_ZERO
|
||||
AnalysisStops.java, void AnalysisStops.recursiveAngelicTypesMayCauseFalseNegative(), 4, DIVIDE_BY_ZERO
|
||||
AnalysisStops.java, void AnalysisStops.skipFunctionInLoopMayCauseFalseNegative(), 5, NULL_DEREFERENCE
|
||||
AnalysisStops.java, void AnalysisStops.skipPointerDerefMayCauseCalleeFalseNegative(), 2, DIVIDE_BY_ZERO
|
||||
AnalysisStops.java, void AnalysisStops.skipPointerDerefMayCauseInterprocFalseNegative(), 2, DIVIDE_BY_ZERO
|
||||
AnalysisStops.java, void AnalysisStops.skipPointerDerefMayCauseLocalFalseNegative(), 3, DIVIDE_BY_ZERO
|
||||
AnalysisStops.java, void AnalysisStops.specInferenceMayFailAndCauseFalseNegative(boolean,Iterator), 2, RETURN_VALUE_IGNORED
|
||||
AnalysisStops.java, void AnalysisStops.specInferenceMayFailAndCauseFalseNegative(boolean,Iterator), 26, DIVIDE_BY_ZERO
|
||||
AnalysisStops.java, void AnalysisStops.specInferenceMayFailAndCauseFalseNegative(boolean,Iterator), 3, RETURN_VALUE_IGNORED
|
||||
ArrayOutOfBounds.java, int ArrayOutOfBounds.arrayOutOfBounds(), 2, ARRAY_OUT_OF_BOUNDS_L1
|
||||
Builtins.java, void Builtins.causeError(Object), 2, NULL_DEREFERENCE
|
||||
Builtins.java, void Builtins.doNotBlockError(Object), 3, NULL_DEREFERENCE
|
||||
ClassCastExceptions.java, int ClassCastExceptions.classCastExceptionImplementsInterface(), 0, CLASS_CAST_EXCEPTION
|
||||
ClassCastExceptions.java, void ClassCastExceptions.classCastException(), 2, CLASS_CAST_EXCEPTION
|
||||
CloseableAsResourceExample.java, T CloseableAsResourceExample.sourceOfNullWithResourceLeak(), 1, RESOURCE_LEAK
|
||||
CloseableAsResourceExample.java, void CloseableAsResourceExample.failToCloseWithCloseQuietly(), 5, RESOURCE_LEAK
|
||||
CloseableAsResourceExample.java, void CloseableAsResourceExample.leakFoundWhenIndirectlyImplementingCloseable(), 1, RESOURCE_LEAK
|
||||
CloseableAsResourceExample.java, void CloseableAsResourceExample.notClosingCloseable(), 1, RESOURCE_LEAK
|
||||
CloseableAsResourceExample.java, void CloseableAsResourceExample.notClosingWrapper(), 2, RESOURCE_LEAK
|
||||
CloseableAsResourceExample.java, void CloseableAsResourceExample.skippedVritualCallDoesNotCloseResourceOnReceiver(), 2, RESOURCE_LEAK
|
||||
CloseableAsResourceExample.java, void CloseableAsResourceExample.withException(), 4, RESOURCE_LEAK
|
||||
ContextLeaks.java, ContextLeaks$Singleton ContextLeaks$Singleton.getInstance(Context), 4, CONTEXT_LEAK
|
||||
ContextLeaks.java, ContextLeaks$Singleton ContextLeaks.singletonLeak(), 1, CONTEXT_LEAK
|
||||
ContextLeaks.java, void ContextLeaks.directLeak(), 2, CONTEXT_LEAK
|
||||
ContextLeaks.java, void ContextLeaks.indirectLeak(), 4, CONTEXT_LEAK
|
||||
ContextLeaks.java, void ContextLeaks.leakAfterInstanceFieldWrite(), 3, CONTEXT_LEAK
|
||||
ContextLeaks.java, void ContextLeaks.nonStaticInnerClassLeak(), 2, CONTEXT_LEAK
|
||||
CursorLeaks.java, int CursorLeaks.completeDownloadNotClosed(DownloadManager), 8, RESOURCE_LEAK
|
||||
CursorLeaks.java, int CursorLeaks.cursorNotClosed(SQLiteDatabase), 4, RESOURCE_LEAK
|
||||
CursorLeaks.java, int CursorLeaks.getBucketCountNotClosed(), 10, RESOURCE_LEAK
|
||||
CursorLeaks.java, int CursorLeaks.getImageCountHelperNotClosed(String), 13, RESOURCE_LEAK
|
||||
CursorLeaks.java, void CursorLeaks.loadPrefsFromContentProviderNotClosed(), 11, RESOURCE_LEAK
|
||||
CursorLeaks.java, void CursorLeaks.queryUVMLegacyDbNotClosed(), 4, RESOURCE_LEAK
|
||||
DivideByZero.java, int DivideByZero.callDivideByZeroInterProc(), 1, DIVIDE_BY_ZERO
|
||||
DivideByZero.java, int DivideByZero.divByZeroLocal(String), 3, DIVIDE_BY_ZERO
|
||||
DivideByZero.java, int DivideByZero.divideByZeroWithStaticField(), 2, DIVIDE_BY_ZERO
|
||||
DynamicDispatch.java, void DynamicDispatch.dynamicDispatchShouldNotCauseFalseNegativeEasy(), 3, NULL_DEREFERENCE
|
||||
DynamicDispatch.java, void DynamicDispatch.interfaceShouldNotCauseFalseNegativeEasy(), 3, NULL_DEREFERENCE
|
||||
DynamicDispatch.java, void DynamicDispatch.interfaceShouldNotCauseFalseNegativeHard(DynamicDispatch$Interface), 2, NULL_DEREFERENCE
|
||||
FilterInputStreamLeaks.java, void FilterInputStreamLeaks.bufferedInputStreamNotClosedAfterRead(), 7, RESOURCE_LEAK
|
||||
FilterInputStreamLeaks.java, void FilterInputStreamLeaks.checkedInputStreamNotClosedAfterRead(), 7, RESOURCE_LEAK
|
||||
FilterInputStreamLeaks.java, void FilterInputStreamLeaks.cipherInputStreamNotClosedAfterSkip(), 7, RESOURCE_LEAK
|
||||
FilterInputStreamLeaks.java, void FilterInputStreamLeaks.dataInputStreamNotClosedAfterRead(), 8, RESOURCE_LEAK
|
||||
FilterInputStreamLeaks.java, void FilterInputStreamLeaks.deflaterInputStreamNotClosedAfterRead(), 7, RESOURCE_LEAK
|
||||
FilterInputStreamLeaks.java, void FilterInputStreamLeaks.digestInputStreamNotClosedAfterRead(), 8, RESOURCE_LEAK
|
||||
FilterInputStreamLeaks.java, void FilterInputStreamLeaks.gzipInputStreamNotClosedAfterRead(), 4, RESOURCE_LEAK
|
||||
FilterInputStreamLeaks.java, void FilterInputStreamLeaks.gzipInputStreamNotClosedAfterRead(), 7, RESOURCE_LEAK
|
||||
FilterInputStreamLeaks.java, void FilterInputStreamLeaks.inflaterInputStreamNotClosedAfterRead(), 7, RESOURCE_LEAK
|
||||
FilterInputStreamLeaks.java, void FilterInputStreamLeaks.pushbackInputStreamNotClosedAfterRead(), 7, RESOURCE_LEAK
|
||||
FilterOutputStreamLeaks.java, void FilterOutputStreamLeaks.bufferedOutputStreamNotClosedAfterWrite(), 8, RESOURCE_LEAK
|
||||
FilterOutputStreamLeaks.java, void FilterOutputStreamLeaks.checkedOutputStreamNotClosedAfterWrite(), 8, RESOURCE_LEAK
|
||||
FilterOutputStreamLeaks.java, void FilterOutputStreamLeaks.cipherOutputStreamNotClosedAfterWrite(), 8, RESOURCE_LEAK
|
||||
FilterOutputStreamLeaks.java, void FilterOutputStreamLeaks.dataOutputStreamNotClosedAfterWrite(), 8, RESOURCE_LEAK
|
||||
FilterOutputStreamLeaks.java, void FilterOutputStreamLeaks.deflaterOutputStreamNotClosedAfterWrite(), 8, RESOURCE_LEAK
|
||||
FilterOutputStreamLeaks.java, void FilterOutputStreamLeaks.digestOutputStreamNotClosedAfterWrite(), 8, RESOURCE_LEAK
|
||||
FilterOutputStreamLeaks.java, void FilterOutputStreamLeaks.filterOutputStreamNotClosedAfterWrite(), 8, RESOURCE_LEAK
|
||||
FilterOutputStreamLeaks.java, void FilterOutputStreamLeaks.gzipOutputStreamNotClosedAfterFlush(), 4, RESOURCE_LEAK
|
||||
FilterOutputStreamLeaks.java, void FilterOutputStreamLeaks.gzipOutputStreamNotClosedAfterFlush(), 7, RESOURCE_LEAK
|
||||
FilterOutputStreamLeaks.java, void FilterOutputStreamLeaks.inflaterOutputStreamNotClosedAfterWrite(), 8, RESOURCE_LEAK
|
||||
FilterOutputStreamLeaks.java, void FilterOutputStreamLeaks.printStreamNotClosedAfterWrite(), 6, RESOURCE_LEAK
|
||||
GuardedByExample.java, Object GuardedByExample.byRefTrickyBad(), 5, UNSAFE_GUARDED_BY_ACCESS
|
||||
GuardedByExample.java, String GuardedByExample$3.readFromInnerClassBad1(), 2, UNSAFE_GUARDED_BY_ACCESS
|
||||
GuardedByExample.java, String GuardedByExample$4.readFromInnerClassBad2(), 1, UNSAFE_GUARDED_BY_ACCESS
|
||||
GuardedByExample.java, void GuardedByExample.readFAfterBlockBad(), 3, UNSAFE_GUARDED_BY_ACCESS
|
||||
GuardedByExample.java, void GuardedByExample.readFBad(), 1, UNSAFE_GUARDED_BY_ACCESS
|
||||
GuardedByExample.java, void GuardedByExample.readFBadWrongAnnotation(), 1, UNSAFE_GUARDED_BY_ACCESS
|
||||
GuardedByExample.java, void GuardedByExample.readFBadWrongLock(), 2, UNSAFE_GUARDED_BY_ACCESS
|
||||
GuardedByExample.java, void GuardedByExample.readHBad(), 2, UNSAFE_GUARDED_BY_ACCESS
|
||||
GuardedByExample.java, void GuardedByExample.readHBadSynchronizedMethodShouldntHelp(), 1, UNSAFE_GUARDED_BY_ACCESS
|
||||
GuardedByExample.java, void GuardedByExample.synchronizedMethodReadBad(), 1, UNSAFE_GUARDED_BY_ACCESS
|
||||
GuardedByExample.java, void GuardedByExample.synchronizedMethodWriteBad(), 1, UNSAFE_GUARDED_BY_ACCESS
|
||||
GuardedByExample.java, void GuardedByExample.synchronizedOnThisBad(), 1, UNSAFE_GUARDED_BY_ACCESS
|
||||
GuardedByExample.java, void GuardedByExample.writeFAfterBlockBad(), 3, UNSAFE_GUARDED_BY_ACCESS
|
||||
GuardedByExample.java, void GuardedByExample.writeFBad(), 1, UNSAFE_GUARDED_BY_ACCESS
|
||||
GuardedByExample.java, void GuardedByExample.writeFBadWrongLock(), 2, UNSAFE_GUARDED_BY_ACCESS
|
||||
HashMapExample.java, Integer HashMapExample.getOrCreateInteger(HashMap,int), 8, RETURN_VALUE_IGNORED
|
||||
HashMapExample.java, int HashMapExample.getOneIntegerWithoutCheck(), 6, NULL_DEREFERENCE
|
||||
HashMapExample.java, void HashMapExample.getTwoIntegersWithOneCheck(Integer,Integer), 11, NULL_DEREFERENCE
|
||||
HashMapExample.java, void HashMapExample.putIntegerTwiceThenGetTwice(HashMap), 6, RETURN_VALUE_IGNORED
|
||||
HashMapExample.java, void HashMapExample.putIntegerTwiceThenGetTwice(HashMap), 7, RETURN_VALUE_IGNORED
|
||||
JunitAssertion.java, void JunitAssertion.inconsistentAssertion(JunitAssertion$A), 2, NULL_DEREFERENCE
|
||||
NullPointerExceptions.java, String NullPointerExceptions.hashmapNPE(HashMap,Object), 1, NULL_DEREFERENCE
|
||||
NullPointerExceptions.java, String NullPointerExceptions.nullTryLock(FileChannel), 2, NULL_DEREFERENCE
|
||||
NullPointerExceptions.java, String NullPointerExceptions.testSystemGetPropertyArgument(), 1, NULL_DEREFERENCE
|
||||
NullPointerExceptions.java, String NullPointerExceptions.tryLockThrows(FileChannel), 6, NULL_DEREFERENCE
|
||||
NullPointerExceptions.java, int NullPointerExceptions.NPEvalueOfFromHashmapBad(HashMap,int), 1, NULL_DEREFERENCE
|
||||
NullPointerExceptions.java, int NullPointerExceptions.nullListFiles(String), 3, NULL_DEREFERENCE
|
||||
NullPointerExceptions.java, int NullPointerExceptions.nullPointerException(), 2, NULL_DEREFERENCE
|
||||
NullPointerExceptions.java, int NullPointerExceptions.nullPointerExceptionInterProc(), 2, NULL_DEREFERENCE
|
||||
NullPointerExceptions.java, int NullPointerExceptions.nullPointerExceptionWithAChainOfFields(NullPointerExceptions$C), 2, NULL_DEREFERENCE
|
||||
NullPointerExceptions.java, int NullPointerExceptions.nullPointerExceptionWithArray(), 3, NULL_DEREFERENCE
|
||||
NullPointerExceptions.java, int NullPointerExceptions.nullPointerExceptionWithExceptionHandling(boolean), 5, NULL_DEREFERENCE
|
||||
NullPointerExceptions.java, void NullPointerExceptions$$$Class$Name$With$Dollars.npeWithDollars(), 2, NULL_DEREFERENCE
|
||||
NullPointerExceptions.java, void NullPointerExceptions.badCheckShouldCauseNPE(), 1, NULL_DEREFERENCE
|
||||
NullPointerExceptions.java, void NullPointerExceptions.cursorFromContentResolverNPE(String), 9, NULL_DEREFERENCE
|
||||
NullPointerExceptions.java, void NullPointerExceptions.derefNull(), 2, NULL_DEREFERENCE
|
||||
NullPointerExceptions.java, void NullPointerExceptions.derefNullableGetter(), 2, NULL_DEREFERENCE
|
||||
NullPointerExceptions.java, void NullPointerExceptions.derefNullableRet(boolean), 2, NULL_DEREFERENCE
|
||||
NullPointerExceptions.java, void NullPointerExceptions.derefUndefNullableRet(), 2, NULL_DEREFERENCE
|
||||
NullPointerExceptions.java, void NullPointerExceptions.derefUndefNullableRetWrapper(), 1, NULL_DEREFERENCE
|
||||
NullPointerExceptions.java, void NullPointerExceptions.dereferenceAfterLoopOnList(NullPointerExceptions$L), 2, NULL_DEREFERENCE
|
||||
NullPointerExceptions.java, void NullPointerExceptions.dereferenceAfterUnlock1(Lock), 4, NULL_DEREFERENCE
|
||||
NullPointerExceptions.java, void NullPointerExceptions.dereferenceAfterUnlock2(Lock), 6, NULL_DEREFERENCE
|
||||
NullPointerExceptions.java, void NullPointerExceptions.nullPointerExceptionArrayLength(), 2, NULL_DEREFERENCE
|
||||
NullPointerExceptions.java, void NullPointerExceptions.nullPointerExceptionCallArrayReadMethod(), 2, NULL_DEREFERENCE
|
||||
NullPointerExceptions.java, void NullPointerExceptions.nullPointerExceptionFromFailingFileOutputStreamConstructor(), 7, NULL_DEREFERENCE
|
||||
NullPointerExceptions.java, void NullPointerExceptions.nullPointerExceptionFromFaillingResourceConstructor(), 6, NULL_DEREFERENCE
|
||||
NullPointerExceptions.java, void NullPointerExceptions.nullPointerExceptionInArrayLengthLoop(java.lang.Object[]), 3, NULL_DEREFERENCE
|
||||
NullPointerExceptions.java, void NullPointerExceptions.nullPointerExceptionUnlessFrameFails(), 4, NULL_DEREFERENCE
|
||||
NullPointerExceptions.java, void NullPointerExceptions.nullPointerExceptionWithNullArrayParameter(), 1, NULL_DEREFERENCE
|
||||
NullPointerExceptions.java, void NullPointerExceptions.nullPointerExceptionWithNullObjectParameter(), 1, NULL_DEREFERENCE
|
||||
NullPointerExceptions.java, void NullPointerExceptions.nullableFieldNPE(), 1, NULL_DEREFERENCE
|
||||
NullPointerExceptions.java, void NullPointerExceptions.nullableParamNPE(Object), 1, NULL_DEREFERENCE
|
||||
NullPointerExceptions.java, void NullPointerExceptions.optionalNPE(Optional), 1, NULL_DEREFERENCE
|
||||
NullPointerExceptions.java, void NullPointerExceptions.someNPEAfterResourceLeak(), 2, NULL_DEREFERENCE
|
||||
NullPointerExceptions.java, void NullPointerExceptions.stringConstantEqualsFalseNotNPE_FP(), 10, NULL_DEREFERENCE
|
||||
NullPointerExceptions.java, void NullPointerExceptions.stringVarEqualsFalseNPE(), 5, NULL_DEREFERENCE
|
||||
NullPointerExceptions.java, void NullPointerExceptions.testSystemGetPropertyReturn(), 2, NULL_DEREFERENCE
|
||||
ReaderLeaks.java, void ReaderLeaks.bufferedReaderNotClosedAfterRead(), 6, RESOURCE_LEAK
|
||||
ReaderLeaks.java, void ReaderLeaks.fileReaderNotClosedAfterRead(), 6, RESOURCE_LEAK
|
||||
ReaderLeaks.java, void ReaderLeaks.inputStreamReaderNotClosedAfterRead(), 6, RESOURCE_LEAK
|
||||
ReaderLeaks.java, void ReaderLeaks.pipedReaderFalsePositive(), 5, RESOURCE_LEAK
|
||||
ReaderLeaks.java, void ReaderLeaks.pipedReaderNotClosedAfterConnect(PipedWriter), 7, RESOURCE_LEAK
|
||||
ReaderLeaks.java, void ReaderLeaks.pipedReaderNotClosedAfterConstructedWithWriter(), 8, RESOURCE_LEAK
|
||||
ReaderLeaks.java, void ReaderLeaks.pushbackReaderNotClosedAfterRead(), 6, RESOURCE_LEAK
|
||||
ReaderLeaks.java, void ReaderLeaks.readerNotClosedAfterRead(), 6, RESOURCE_LEAK
|
||||
ResourceLeaks.java, String ResourceLeaks.readInstallationFileBad(File), 6, RESOURCE_LEAK
|
||||
ResourceLeaks.java, boolean ResourceLeaks.jarFileNotClosed(), 3, RESOURCE_LEAK
|
||||
ResourceLeaks.java, int ResourceLeaks.fileOutputStreamTwoLeaks1(boolean), 3, RESOURCE_LEAK
|
||||
ResourceLeaks.java, int ResourceLeaks.fileOutputStreamTwoLeaks1(boolean), 6, RESOURCE_LEAK
|
||||
ResourceLeaks.java, int ResourceLeaks.readConfigNotCloseStream(String), 5, RESOURCE_LEAK
|
||||
ResourceLeaks.java, void ResourceLeaks.activityObtainTypedArrayAndLeak(Activity), 2, RESOURCE_LEAK
|
||||
ResourceLeaks.java, void ResourceLeaks.contextObtainTypedArrayAndLeak(Context), 2, RESOURCE_LEAK
|
||||
ResourceLeaks.java, void ResourceLeaks.copyFileLeak(File,File), 11, RESOURCE_LEAK
|
||||
ResourceLeaks.java, void ResourceLeaks.copyFileLeak(File,File), 11, RESOURCE_LEAK
|
||||
ResourceLeaks.java, void ResourceLeaks.deflaterLeak(), 1, RESOURCE_LEAK
|
||||
ResourceLeaks.java, void ResourceLeaks.fileInputStreamNotClosedAfterRead(), 6, RESOURCE_LEAK
|
||||
ResourceLeaks.java, void ResourceLeaks.fileOutputStreamNotClosed(), 1, RESOURCE_LEAK
|
||||
ResourceLeaks.java, void ResourceLeaks.fileOutputStreamNotClosedAfterWrite(), 7, RESOURCE_LEAK
|
||||
ResourceLeaks.java, void ResourceLeaks.fileOutputStreamOneLeak(), 2, RESOURCE_LEAK
|
||||
ResourceLeaks.java, void ResourceLeaks.fileOutputStreamTwoLeaks2(), 2, RESOURCE_LEAK
|
||||
ResourceLeaks.java, void ResourceLeaks.fileOutputStreamTwoLeaks2(), 5, RESOURCE_LEAK
|
||||
ResourceLeaks.java, void ResourceLeaks.inflaterLeak(), 1, RESOURCE_LEAK
|
||||
ResourceLeaks.java, void ResourceLeaks.jarInputStreamLeak(), 3, RESOURCE_LEAK
|
||||
ResourceLeaks.java, void ResourceLeaks.jarOutputStreamLeak(), 3, RESOURCE_LEAK
|
||||
ResourceLeaks.java, void ResourceLeaks.nestedBad1(), 1, RESOURCE_LEAK
|
||||
ResourceLeaks.java, void ResourceLeaks.nestedBad2(), 1, RESOURCE_LEAK
|
||||
ResourceLeaks.java, void ResourceLeaks.nestedBadJarInputStream(File), 1, RESOURCE_LEAK
|
||||
ResourceLeaks.java, void ResourceLeaks.nestedBadJarOutputStream(), 1, RESOURCE_LEAK
|
||||
ResourceLeaks.java, void ResourceLeaks.objectInputStreamClosedNestedBad(), 3, RESOURCE_LEAK
|
||||
ResourceLeaks.java, void ResourceLeaks.objectInputStreamNotClosedAfterRead(), 3, RESOURCE_LEAK
|
||||
ResourceLeaks.java, void ResourceLeaks.objectInputStreamNotClosedAfterRead(), 6, RESOURCE_LEAK
|
||||
ResourceLeaks.java, void ResourceLeaks.objectOutputStreamClosedNestedBad(), 3, RESOURCE_LEAK
|
||||
ResourceLeaks.java, void ResourceLeaks.objectOutputStreamNotClosedAfterWrite(), 4, RESOURCE_LEAK
|
||||
ResourceLeaks.java, void ResourceLeaks.objectOutputStreamNotClosedAfterWrite(), 7, RESOURCE_LEAK
|
||||
ResourceLeaks.java, void ResourceLeaks.openHttpURLConnectionNotDisconnected(), 7, RESOURCE_LEAK
|
||||
ResourceLeaks.java, void ResourceLeaks.openHttpsURLConnectionNotDisconnected(), 3, RESOURCE_LEAK
|
||||
ResourceLeaks.java, void ResourceLeaks.parseFromInputStreamAndLeak(JsonFactory), 5, RESOURCE_LEAK
|
||||
ResourceLeaks.java, void ResourceLeaks.pipedInputStreamNotClosedAfterRead(PipedOutputStream), 6, RESOURCE_LEAK
|
||||
ResourceLeaks.java, void ResourceLeaks.pipedOutputStreamNotClosedAfterWrite(), 7, RESOURCE_LEAK
|
||||
ResourceLeaks.java, void ResourceLeaks.scannerNotClosed(), 1, RESOURCE_LEAK
|
||||
ResourceLeaks.java, void ResourceLeaks.serverSocketNotClosed(), 12, RESOURCE_LEAK
|
||||
ResourceLeaks.java, void ResourceLeaks.socketNotClosed(), 1, RESOURCE_LEAK
|
||||
ResourceLeaks.java, void ResourceLeaks.themeObtainTypedArrayAndLeak(Resources$Theme), 2, RESOURCE_LEAK
|
||||
ResourceLeaks.java, void ResourceLeaks.twoResources(), 11, RESOURCE_LEAK
|
||||
ResourceLeaks.java, void ResourceLeaks.twoResourcesRandomAccessFile(), 10, RESOURCE_LEAK
|
||||
ResourceLeaks.java, void ResourceLeaks.twoResourcesServerSocket(), 10, RESOURCE_LEAK
|
||||
ResourceLeaks.java, void ResourceLeaks.zipFileLeakExceptionalBranch(), 5, RESOURCE_LEAK
|
||||
ReturnValueIgnored.java, void ReturnValueIgnored.returnValueIgnored(), 1, RETURN_VALUE_IGNORED
|
||||
TaintExample.java, InputStream TaintExample.socketIgnoreExceptionNoVerify(SSLSocketFactory), 9, TAINTED_VALUE_REACHING_SENSITIVE_FUNCTION
|
||||
TaintExample.java, InputStream TaintExample.socketNotVerifiedSimple(SSLSocketFactory), 3, TAINTED_VALUE_REACHING_SENSITIVE_FUNCTION
|
||||
TaintExample.java, InputStream TaintExample.socketVerifiedForgotToCheckRetval(SSLSocketFactory,HostnameVerifier,SSLSession), 7, TAINTED_VALUE_REACHING_SENSITIVE_FUNCTION
|
||||
TaintExample.java, InputStream TaintExample.taintingShouldNotPreventInference1(SSLSocketFactory), 4, TAINTED_VALUE_REACHING_SENSITIVE_FUNCTION
|
||||
TaintExample.java, InputStream TaintExample.taintingShouldNotPreventInference2(SSLSocketFactory), 3, TAINTED_VALUE_REACHING_SENSITIVE_FUNCTION
|
||||
TaintExample.java, Socket TaintExample.callReadInputStreamCauseTaintError(SSLSocketFactory), 3, TAINTED_VALUE_REACHING_SENSITIVE_FUNCTION
|
||||
TaintExample.java, void TaintExample.contentValuesPutWithTaintedString(ContentValues,SharedPreferences,String,String), 2, TAINTED_VALUE_REACHING_SENSITIVE_FUNCTION
|
||||
TaintExample.java, void TaintExample.interprocTaintErrorWithModelMethods1(), 1, TAINTED_VALUE_REACHING_SENSITIVE_FUNCTION
|
||||
TaintExample.java, void TaintExample.interprocTaintErrorWithModelMethods2(), 1, TAINTED_VALUE_REACHING_SENSITIVE_FUNCTION
|
||||
TaintExample.java, void TaintExample.interprocTaintErrorWithModelMethods3(), 1, TAINTED_VALUE_REACHING_SENSITIVE_FUNCTION
|
||||
TaintExample.java, void TaintExample.interprocTaintErrorWithModelMethodsUndefined1(), 1, TAINTED_VALUE_REACHING_SENSITIVE_FUNCTION
|
||||
TaintExample.java, void TaintExample.interprocTaintErrorWithModelMethodsUndefined2(), 1, TAINTED_VALUE_REACHING_SENSITIVE_FUNCTION
|
||||
TaintExample.java, void TaintExample.interprocTaintErrorWithModelMethodsUndefined3(), 1, TAINTED_VALUE_REACHING_SENSITIVE_FUNCTION
|
||||
TaintExample.java, void TaintExample.simpleTaintErrorWithModelMethods(), 2, TAINTED_VALUE_REACHING_SENSITIVE_FUNCTION
|
||||
TaintExample.java, void TaintExample.simpleTaintErrorWithModelMethodsUndefined(), 2, TAINTED_VALUE_REACHING_SENSITIVE_FUNCTION
|
||||
TaintExample.java, void TaintExample.testIntegritySinkAnnotReport(String), 1, TAINTED_VALUE_REACHING_SENSITIVE_FUNCTION
|
||||
TaintExample.java, void TaintExample.testIntegritySourceAnnot(), 1, TAINTED_VALUE_REACHING_SENSITIVE_FUNCTION
|
||||
TaintExample.java, void TaintExample.testIntegritySourceInstanceFieldAnnot(), 2, TAINTED_VALUE_REACHING_SENSITIVE_FUNCTION
|
||||
TaintExample.java, void TaintExample.testIntegritySourceStaticFieldAnnot(), 2, TAINTED_VALUE_REACHING_SENSITIVE_FUNCTION
|
||||
TaintExample.java, void TaintExample.testPrivacySinkAnnot1(), 2, TAINTED_VALUE_REACHING_SENSITIVE_FUNCTION
|
||||
TaintExample.java, void TaintExample.testPrivacySinkAnnot3(), 2, TAINTED_VALUE_REACHING_SENSITIVE_FUNCTION
|
||||
TaintExample.java, void TaintExample.testPrivacySourceAnnot(), 1, TAINTED_VALUE_REACHING_SENSITIVE_FUNCTION
|
||||
TaintExample.java, void TaintExample.testPrivacySourceFieldAnnotPropagation(), 2, TAINTED_VALUE_REACHING_SENSITIVE_FUNCTION
|
||||
TaintExample.java, void TaintExample.testPrivacySourceInstanceFieldAnnot(), 2, TAINTED_VALUE_REACHING_SENSITIVE_FUNCTION
|
||||
TaintExample.java, void TaintExample.testPrivacySourceStaticFieldAnnot(), 2, TAINTED_VALUE_REACHING_SENSITIVE_FUNCTION
|
||||
WriterLeaks.java, void WriterLeaks.bufferedWriterNotClosedAfterWrite(), 7, RESOURCE_LEAK
|
||||
WriterLeaks.java, void WriterLeaks.fileWriterNotClosedAfterWrite(), 6, RESOURCE_LEAK
|
||||
WriterLeaks.java, void WriterLeaks.outputStreamWriterNotClosedAfterWrite(), 6, RESOURCE_LEAK
|
||||
WriterLeaks.java, void WriterLeaks.pipedWriterNotClosedAfterConnect(PipedReader), 7, RESOURCE_LEAK
|
||||
WriterLeaks.java, void WriterLeaks.pipedWriterNotClosedAfterConstructedWithReader(), 8, RESOURCE_LEAK
|
||||
WriterLeaks.java, void WriterLeaks.printWriterNotClosedAfterAppend(), 4, RESOURCE_LEAK
|
||||
WriterLeaks.java, void WriterLeaks.writerNotClosedAfterWrite(), 6, RESOURCE_LEAK
|
@ -1,415 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2013 - present Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
package endtoend.java.infer;
|
||||
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static utils.matchers.ResultContainsErrorInMethod.contains;
|
||||
import static utils.matchers.ResultContainsNumberOfErrorsInMethod.containsNumberOfErrors;
|
||||
import static utils.matchers.ResultContainsZeroErrorsInMethod.containsZeroErrors;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import utils.InferException;
|
||||
import utils.InferResults;
|
||||
|
||||
public class AnalysisStopsTest {
|
||||
|
||||
public static final String AnalysisStops =
|
||||
"infer/tests/codetoanalyze/java/infer/AnalysisStops.java";
|
||||
|
||||
public static final String DIVIDE_BY_ZERO = "DIVIDE_BY_ZERO";
|
||||
public static final String NULL_DEREFERENCE = "NULL_DEREFERENCE";
|
||||
|
||||
private static InferResults inferResults;
|
||||
|
||||
@BeforeClass
|
||||
public static void loadResults() throws InterruptedException, IOException {
|
||||
inferResults = InferResults.loadInferResults(AnalysisStopsTest.class, AnalysisStops);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void skipPtrDerefDoesntCauseLocalFalseNegative()
|
||||
throws InterruptedException, IOException, InferException {
|
||||
assertThat(
|
||||
"Results should contain error",
|
||||
inferResults,
|
||||
contains(
|
||||
DIVIDE_BY_ZERO,
|
||||
AnalysisStops,
|
||||
"skipPointerDerefMayCauseLocalFalseNegative"
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void skipPtrDerefDoesntCauseCalleeFalseNegative()
|
||||
throws InterruptedException, IOException, InferException {
|
||||
assertThat(
|
||||
"Results should contain error",
|
||||
inferResults,
|
||||
contains(
|
||||
DIVIDE_BY_ZERO,
|
||||
AnalysisStops,
|
||||
"skipPointerDerefMayCauseCalleeFalseNegative"
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void skipPtrDerefDoesntCauseCalleeFalsePositive()
|
||||
throws InterruptedException, IOException, InferException {
|
||||
assertThat(
|
||||
"Results should contain no errors",
|
||||
inferResults,
|
||||
containsZeroErrors(
|
||||
AnalysisStops,
|
||||
"skipPointerDerefMayCauseCalleeFalsePositive"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void skipPtrDerefDoesntCauseInterprocFalseNegative()
|
||||
throws InterruptedException, IOException, InferException {
|
||||
assertThat(
|
||||
"Results should contain error",
|
||||
inferResults,
|
||||
contains(
|
||||
DIVIDE_BY_ZERO,
|
||||
AnalysisStops,
|
||||
"skipPointerDerefMayCauseInterprocFalseNegative"
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void castUndefinedObjDoesntCauseFalseNegative()
|
||||
throws InterruptedException, IOException, InferException {
|
||||
assertThat(
|
||||
"Results should contain error",
|
||||
inferResults,
|
||||
contains(
|
||||
DIVIDE_BY_ZERO,
|
||||
AnalysisStops,
|
||||
"castFailureOnUndefinedObjMayCauseFalseNegative"
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void callOnCastUndefinedObjDoesntCauseFalseNegative()
|
||||
throws InterruptedException, IOException, InferException {
|
||||
assertThat(
|
||||
"Results should contain error",
|
||||
inferResults,
|
||||
contains(
|
||||
DIVIDE_BY_ZERO,
|
||||
AnalysisStops,
|
||||
"callOnCastUndefinedObjMayCauseFalseNegative"
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void callOnUndefinedObjDoesntCauseFalseNegative()
|
||||
throws InterruptedException, IOException, InferException {
|
||||
assertThat(
|
||||
"Results should contain error",
|
||||
inferResults,
|
||||
contains(
|
||||
DIVIDE_BY_ZERO,
|
||||
AnalysisStops,
|
||||
"callOnUndefinedObjMayCauseFalseNegative"
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void callOnUndefinedObjDoesntCauseFalsePositive()
|
||||
throws InterruptedException, IOException, InferException {
|
||||
assertThat(
|
||||
"Results should contain no errors",
|
||||
inferResults,
|
||||
containsZeroErrors(
|
||||
AnalysisStops,
|
||||
"callOnUndefinedObjMayCauseFalsePositive"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void fieldWriteOnUndefinedObjDoesntCauseFalseNegative()
|
||||
throws InterruptedException, IOException, InferException {
|
||||
assertThat(
|
||||
"Results should contain error",
|
||||
inferResults,
|
||||
contains(
|
||||
DIVIDE_BY_ZERO,
|
||||
AnalysisStops,
|
||||
"fieldWriteOnUndefinedObjMayCauseFalseNegative"
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void fieldWriteOnUndefinedObjDoesntCauseFalsePositive()
|
||||
throws InterruptedException, IOException, InferException {
|
||||
assertThat(
|
||||
"Results should contain no errors",
|
||||
inferResults,
|
||||
containsZeroErrors(
|
||||
AnalysisStops,
|
||||
"fieldWriteOnUndefinedObjMayCauseFalsePositive"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void fieldReadOnUndefinedObjDoesntCauseFalseNegative()
|
||||
throws InterruptedException, IOException, InferException {
|
||||
assertThat(
|
||||
"Results should contain error",
|
||||
inferResults,
|
||||
contains(
|
||||
DIVIDE_BY_ZERO,
|
||||
AnalysisStops,
|
||||
"fieldReadOnUndefinedObjMayCauseFalseNegative"
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void fieldReadOnUndefinedObjDoesntCauseFalsePositive()
|
||||
throws InterruptedException, IOException, InferException {
|
||||
assertThat(
|
||||
"Results should contain no errors",
|
||||
inferResults,
|
||||
containsZeroErrors(
|
||||
AnalysisStops,
|
||||
"fieldReadOnUndefinedObjMayCauseFalsePositive"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void recursiveAngelicTypesDontCauseFalseNegative()
|
||||
throws InterruptedException, IOException, InferException {
|
||||
assertThat(
|
||||
"Results should contain error",
|
||||
inferResults,
|
||||
contains(
|
||||
DIVIDE_BY_ZERO,
|
||||
AnalysisStops,
|
||||
"recursiveAngelicTypesMayCauseFalseNegative"
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void recursiveAngelicTypesDontCauseFalsePositive()
|
||||
throws InterruptedException, IOException, InferException {
|
||||
assertThat(
|
||||
"Results should contain no errors",
|
||||
inferResults,
|
||||
containsZeroErrors(
|
||||
AnalysisStops,
|
||||
"recursiveAngelicTypeMayCauseFalsePositive"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void infiniteMaterializationDoesntCauseFalseNegative()
|
||||
throws InterruptedException, IOException, InferException {
|
||||
assertThat(
|
||||
"Results should contain error",
|
||||
inferResults,
|
||||
contains(
|
||||
DIVIDE_BY_ZERO,
|
||||
AnalysisStops,
|
||||
"infiniteMaterializationMayCauseFalseNegative"
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void infiniteMaterializationDoesntCauseFalsePositive()
|
||||
throws InterruptedException, IOException, InferException {
|
||||
assertThat(
|
||||
"Results should contain no errors",
|
||||
inferResults,
|
||||
containsZeroErrors(
|
||||
AnalysisStops,
|
||||
"infiniteMaterializationMayCauseFalsePositive"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void primitiveFieldOfAngelicObjDoesntCauseFalseNegative()
|
||||
throws InterruptedException, IOException, InferException {
|
||||
assertThat(
|
||||
"Results should contain error",
|
||||
inferResults,
|
||||
containsNumberOfErrors(
|
||||
DIVIDE_BY_ZERO,
|
||||
AnalysisStops,
|
||||
"primitiveFieldOfAngelicObjMayCauseFalseNegative",
|
||||
2
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void primitiveFieldOfAngelicObjDoesntCauseFalsePositive()
|
||||
throws InterruptedException, IOException, InferException {
|
||||
assertThat(
|
||||
"Results should contain no errors",
|
||||
inferResults,
|
||||
containsZeroErrors(
|
||||
AnalysisStops,
|
||||
"primitiveFieldOfAngelicObjMayCauseFalsePositive"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void heapFieldOfAngelicObjDoesntCauseFalseNegative()
|
||||
throws InterruptedException, IOException, InferException {
|
||||
assertThat(
|
||||
"Results should contain error",
|
||||
inferResults,
|
||||
contains(
|
||||
DIVIDE_BY_ZERO,
|
||||
AnalysisStops,
|
||||
"heapFieldOfAngelicObjMayCauseFalseNegative"
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void heapFieldOfAngelicObjDoesntCauseFalsePositive()
|
||||
throws InterruptedException, IOException, InferException {
|
||||
assertThat(
|
||||
"Results should contain no errors",
|
||||
inferResults,
|
||||
containsZeroErrors(
|
||||
AnalysisStops,
|
||||
"heapFieldOfAngelicObjMayCauseFalsePositive"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void fieldReadAfterCastDoesntCauseFalseNegative()
|
||||
throws InterruptedException, IOException, InferException {
|
||||
assertThat(
|
||||
"Results should contain error",
|
||||
inferResults,
|
||||
contains(
|
||||
DIVIDE_BY_ZERO,
|
||||
AnalysisStops,
|
||||
"fieldReadAferCastMayCauseFalseNegative"
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void fieldReadInCalleeDoesntCauseFalsePositive()
|
||||
throws InterruptedException, IOException, InferException {
|
||||
assertThat(
|
||||
"Results should contain no errors",
|
||||
inferResults,
|
||||
containsZeroErrors(
|
||||
AnalysisStops,
|
||||
"fieldReadInCalleeMayCauseFalsePositive"));
|
||||
}
|
||||
|
||||
// these do not work yet
|
||||
@Test
|
||||
public void fieldReadInCalleeDoesntCauseFalseNegative()
|
||||
throws InterruptedException, IOException, InferException {
|
||||
assertThat(
|
||||
"Results should contain error",
|
||||
inferResults,
|
||||
contains(
|
||||
NULL_DEREFERENCE,
|
||||
AnalysisStops,
|
||||
"fieldReadInCalleeMayCauseFalseNegative"
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void fieldReadInCalleeWithAngelicObjFieldDoesntCauseFalsePositive()
|
||||
throws InterruptedException, IOException, InferException {
|
||||
assertThat(
|
||||
"Results should contain no errors",
|
||||
inferResults,
|
||||
containsZeroErrors(
|
||||
AnalysisStops,
|
||||
"fieldReadInCalleeWithAngelicObjFieldMayCauseFalsePositive"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void fieldReadInCalleeWithAngelicObjFieldDoesntCauseFalseNegative()
|
||||
throws InterruptedException, IOException, InferException {
|
||||
assertThat(
|
||||
"Results should contain error",
|
||||
inferResults,
|
||||
contains(
|
||||
NULL_DEREFERENCE,
|
||||
AnalysisStops,
|
||||
"fieldReadInCalleeWithAngelicObjFieldMayCauseFalseNegative"
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void accessPathInCalleeDoesntCauseFalsePositive()
|
||||
throws InterruptedException, IOException, InferException {
|
||||
assertThat(
|
||||
"Results should contain no errors",
|
||||
inferResults,
|
||||
containsZeroErrors(
|
||||
AnalysisStops,
|
||||
"accessPathInCalleeMayCauseFalseNegative"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void accessPathInCalleeDoesntCauseFalseNegative()
|
||||
throws InterruptedException, IOException, InferException {
|
||||
assertThat(
|
||||
"Results should contain error",
|
||||
inferResults,
|
||||
contains(
|
||||
NULL_DEREFERENCE,
|
||||
AnalysisStops,
|
||||
"accessPathInCalleeMayCauseFalseNegative"
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void skipFunctionInLoopShouldNotCauseFalseNegative()
|
||||
throws InterruptedException, IOException, InferException {
|
||||
assertThat(
|
||||
"Results should contain error",
|
||||
inferResults,
|
||||
contains(
|
||||
NULL_DEREFERENCE,
|
||||
AnalysisStops,
|
||||
"skipFunctionInLoopMayCauseFalseNegative"
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void specInferenceFailureShouldNotCauseFalseNegative()
|
||||
throws InterruptedException, IOException, InferException {
|
||||
assertThat(
|
||||
"Results should contain error",
|
||||
inferResults,
|
||||
contains(
|
||||
DIVIDE_BY_ZERO,
|
||||
AnalysisStops,
|
||||
"specInferenceMayFailAndCauseFalseNegative"
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
@ -1,55 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2013 - present Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
package endtoend.java.infer;
|
||||
|
||||
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static utils.matchers.ResultContainsExactly.containsExactly;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import utils.InferException;
|
||||
import utils.InferResults;
|
||||
|
||||
public class ArrayOutOfBoundsTest {
|
||||
|
||||
|
||||
public static final String SOURCE_FILE =
|
||||
"infer/tests/codetoanalyze/java/infer/ArrayOutOfBounds.java";
|
||||
|
||||
public static final String ARRAY_OUT_OF_BOUNDS_L1 = "ARRAY_OUT_OF_BOUNDS_L1";
|
||||
|
||||
private static InferResults inferResults;
|
||||
|
||||
@BeforeClass
|
||||
public static void loadResults() throws InterruptedException, IOException {
|
||||
inferResults = InferResults.loadInferResults(ArrayOutOfBoundsTest.class, SOURCE_FILE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenInferRunsOnArrayOutOfBoundsThenErrorIsFound()
|
||||
throws IOException, InterruptedException, InferException {
|
||||
String[] methods = {
|
||||
"arrayOutOfBounds",
|
||||
};
|
||||
assertThat(
|
||||
"Results should contain out of bounds error.", inferResults,
|
||||
containsExactly(
|
||||
ARRAY_OUT_OF_BOUNDS_L1,
|
||||
SOURCE_FILE,
|
||||
methods
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
@ -1,55 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2015 - present Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
package endtoend.java.infer;
|
||||
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static utils.matchers.ResultContainsExactly.containsExactly;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import utils.InferException;
|
||||
import utils.InferResults;
|
||||
|
||||
public class AutoGeneratedTest {
|
||||
|
||||
public static final String SOURCE_FILE =
|
||||
"infer/tests/codetoanalyze/java/infer/AutoGenerated.java";
|
||||
|
||||
public static final String NULL_DEREFERENCE = "NULL_DEREFERENCE";
|
||||
|
||||
private static InferResults inferResults;
|
||||
|
||||
@BeforeClass
|
||||
public static void loadResults() throws InterruptedException, IOException {
|
||||
inferResults = InferResults.loadInferResults(
|
||||
AutoGeneratedTest.class,
|
||||
SOURCE_FILE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void matchErrors()
|
||||
throws IOException, InterruptedException, InferException {
|
||||
String[] methods = {
|
||||
};
|
||||
assertThat(
|
||||
"Results should contain no errors",
|
||||
inferResults,
|
||||
containsExactly(
|
||||
NULL_DEREFERENCE,
|
||||
SOURCE_FILE,
|
||||
methods
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
@ -1,57 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2013 - present Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
package endtoend.java.infer;
|
||||
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static utils.matchers.ResultContainsExactly.containsExactly;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import utils.InferException;
|
||||
import utils.InferResults;
|
||||
|
||||
public class BuiltinsTest {
|
||||
|
||||
public static final String SOURCE_FILE =
|
||||
"infer/tests/codetoanalyze/java/infer/Builtins.java";
|
||||
|
||||
public static final String NULL_DEREFERENCE = "NULL_DEREFERENCE";
|
||||
|
||||
private static InferResults inferResults;
|
||||
|
||||
@BeforeClass
|
||||
public static void loadResults() throws InterruptedException, IOException {
|
||||
inferResults = InferResults.loadInferResults(
|
||||
BuiltinsTest.class,
|
||||
SOURCE_FILE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void matchErrors()
|
||||
throws IOException, InterruptedException, InferException {
|
||||
String[] methods = {
|
||||
"doNotBlockError",
|
||||
"causeError"
|
||||
};
|
||||
assertThat(
|
||||
"Results should contain " + NULL_DEREFERENCE,
|
||||
inferResults,
|
||||
containsExactly(
|
||||
NULL_DEREFERENCE,
|
||||
SOURCE_FILE,
|
||||
methods
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
@ -1,100 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2013 - present Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
package endtoend.java.infer;
|
||||
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static utils.matchers.ResultContainsErrorInMethod.contains;
|
||||
import static utils.matchers.ResultContainsNoErrorInMethod.doesNotContain;
|
||||
import static utils.matchers.ResultContainsOnlyTheseErrors.containsOnly;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import utils.InferException;
|
||||
import utils.InferResults;
|
||||
|
||||
public class ClassCastExceptionsTest {
|
||||
|
||||
public static final String ClassCastExceptions =
|
||||
"infer/tests/codetoanalyze/java/infer/ClassCastExceptions.java";
|
||||
|
||||
public static final String CLASS_CAST_EXCEPTION = "CLASS_CAST_EXCEPTION";
|
||||
|
||||
private static InferResults inferResults;
|
||||
|
||||
@BeforeClass
|
||||
public static void loadResults() throws InterruptedException, IOException {
|
||||
inferResults = InferResults.loadInferResults(
|
||||
ClassCastExceptionsTest.class,
|
||||
ClassCastExceptions);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenInferRunsOnClassCastExceptionThenCCEFound()
|
||||
throws InterruptedException, IOException, InferException {
|
||||
assertThat(
|
||||
"Results should contain class cast exception.",
|
||||
inferResults,
|
||||
contains(
|
||||
CLASS_CAST_EXCEPTION,
|
||||
ClassCastExceptions,
|
||||
"classCastException"
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenInferRunsOnClassCastExceptionImplementsIThenCCEErrorFound()
|
||||
throws InterruptedException, IOException, InferException {
|
||||
assertThat(
|
||||
"Results should contain class cast exception.",
|
||||
inferResults,
|
||||
contains(
|
||||
CLASS_CAST_EXCEPTION,
|
||||
ClassCastExceptions,
|
||||
"classCastExceptionImplementsInterface"
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenInferRunsOnOpenHttpURLConnectionThenCCEErrorNotFound()
|
||||
throws InterruptedException, IOException, InferException {
|
||||
assertThat(
|
||||
"Results should not contain class cast exception.",
|
||||
inferResults,
|
||||
doesNotContain(
|
||||
CLASS_CAST_EXCEPTION,
|
||||
ClassCastExceptions,
|
||||
"openHttpURLConnection"
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenInferIsRunCCEThenOnlyTheExpectedErrorsAreFound()
|
||||
throws InterruptedException, IOException, InferException {
|
||||
String[] expectedMethods = {
|
||||
"classCastException",
|
||||
"classCastExceptionImplementsInterface",
|
||||
"openHttpURLConnection"
|
||||
};
|
||||
assertThat(
|
||||
"No unexpected errors should be found",
|
||||
inferResults,
|
||||
containsOnly(
|
||||
CLASS_CAST_EXCEPTION,
|
||||
ClassCastExceptions,
|
||||
expectedMethods));
|
||||
}
|
||||
|
||||
}
|
@ -1,60 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2015 - present Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
package endtoend.java.infer;
|
||||
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static utils.matchers.ResultContainsExactly.containsExactly;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import utils.InferException;
|
||||
import utils.InferResults;
|
||||
|
||||
public class CloseableAsResourceTest {
|
||||
|
||||
public static final String SOURCE_FILE =
|
||||
"infer/tests/codetoanalyze/java/infer/CloseableAsResourceExample.java";
|
||||
|
||||
public static final String RESOURCE_LEAK = "RESOURCE_LEAK";
|
||||
|
||||
private static InferResults inferResults;
|
||||
|
||||
@BeforeClass
|
||||
public static void loadResults() throws IOException {
|
||||
inferResults = InferResults.loadInferResults(CloseableAsResourceTest.class, SOURCE_FILE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test()
|
||||
throws InterruptedException, IOException, InferException {
|
||||
String[] methods = {
|
||||
"withException",
|
||||
"notClosingCloseable",
|
||||
"notClosingWrapper",
|
||||
"failToCloseWithCloseQuietly",
|
||||
"sourceOfNullWithResourceLeak",
|
||||
"leakFoundWhenIndirectlyImplementingCloseable",
|
||||
"skippedVritualCallDoesNotCloseResourceOnReceiver",
|
||||
};
|
||||
assertThat(
|
||||
"Results should contain resource leak errors",
|
||||
inferResults,
|
||||
containsExactly(
|
||||
RESOURCE_LEAK,
|
||||
SOURCE_FILE,
|
||||
methods
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
@ -1,61 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2013 - present Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
package endtoend.java.infer;
|
||||
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static utils.matchers.ResultContainsExactly.containsExactly;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import utils.InferException;
|
||||
import utils.InferResults;
|
||||
|
||||
public class ContextLeaksTest {
|
||||
|
||||
public static final String SOURCE_FILE =
|
||||
"infer/tests/codetoanalyze/java/infer/ContextLeaks.java";
|
||||
|
||||
public static final String CONTEXT_LEAK = "CONTEXT_LEAK";
|
||||
|
||||
private static InferResults inferResults;
|
||||
|
||||
@BeforeClass
|
||||
public static void loadResults() throws InterruptedException, IOException {
|
||||
inferResults = InferResults.loadInferResults(
|
||||
ContextLeaksTest.class,
|
||||
SOURCE_FILE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void matchErrors()
|
||||
throws IOException, InterruptedException, InferException {
|
||||
String[] methods = {
|
||||
"directLeak",
|
||||
"indirectLeak",
|
||||
"nonStaticInnerClassLeak",
|
||||
"leakAfterInstanceFieldWrite",
|
||||
"singletonLeak",
|
||||
"getInstance",
|
||||
};
|
||||
assertThat(
|
||||
"Results should contain " + CONTEXT_LEAK,
|
||||
inferResults,
|
||||
containsExactly(
|
||||
CONTEXT_LEAK,
|
||||
SOURCE_FILE,
|
||||
methods
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
@ -1,60 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2013 - present Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
package endtoend.java.infer;
|
||||
|
||||
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static utils.matchers.ResultContainsExactly.containsExactly;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import utils.InferException;
|
||||
import utils.InferResults;
|
||||
|
||||
public class CursorLeaksTest {
|
||||
|
||||
public static final String SOURCE_FILE =
|
||||
"infer/tests/codetoanalyze/java/infer/CursorLeaks.java";
|
||||
|
||||
public static final String RESOURCE_LEAK = "RESOURCE_LEAK";
|
||||
|
||||
private static InferResults inferResults;
|
||||
|
||||
@BeforeClass
|
||||
public static void loadResults() throws IOException {
|
||||
inferResults = InferResults.loadInferResults(CursorLeaksTest.class, SOURCE_FILE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test()
|
||||
throws InterruptedException, IOException, InferException {
|
||||
String[] methods = {
|
||||
"cursorNotClosed",
|
||||
"getImageCountHelperNotClosed",
|
||||
"getBucketCountNotClosed",
|
||||
"queryUVMLegacyDbNotClosed",
|
||||
"completeDownloadNotClosed",
|
||||
"loadPrefsFromContentProviderNotClosed",
|
||||
};
|
||||
assertThat(
|
||||
"Results should not contain resource leak errors",
|
||||
inferResults,
|
||||
containsExactly(
|
||||
RESOURCE_LEAK,
|
||||
SOURCE_FILE,
|
||||
methods
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
@ -1,52 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2013 - present Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
package endtoend.java.infer;
|
||||
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static utils.matchers.ResultContainsExactly.containsExactly;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import utils.InferException;
|
||||
import utils.InferResults;
|
||||
|
||||
public class DivideByZeroTest {
|
||||
|
||||
public static final String SOURCE_FILE =
|
||||
"infer/tests/codetoanalyze/java/infer/DivideByZero.java";
|
||||
|
||||
public static final String DIVIDE_BY_ZERO = "DIVIDE_BY_ZERO";
|
||||
|
||||
private static InferResults inferResults;
|
||||
|
||||
@BeforeClass
|
||||
public static void loadResults() throws InterruptedException, IOException {
|
||||
inferResults = InferResults.loadInferResults(DivideByZeroTest.class, SOURCE_FILE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void matchErrors()
|
||||
throws IOException, InterruptedException, InferException {
|
||||
String[] methods = {
|
||||
"divByZeroLocal",
|
||||
"callDivideByZeroInterProc",
|
||||
"divideByZeroWithStaticField",
|
||||
};
|
||||
assertThat("Results should contain " + DIVIDE_BY_ZERO,
|
||||
inferResults,
|
||||
containsExactly(DIVIDE_BY_ZERO,
|
||||
SOURCE_FILE,
|
||||
methods));
|
||||
}
|
||||
|
||||
}
|
@ -1,59 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2016 - present Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
package endtoend.java.infer;
|
||||
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static utils.matchers.ResultContainsExactly.containsExactly;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import utils.InferException;
|
||||
import utils.InferResults;
|
||||
|
||||
public class DynamicDispatchTest {
|
||||
|
||||
public static final String DynamicDispatchFile =
|
||||
"infer/tests/codetoanalyze/java/infer/DynamicDispatch.java";
|
||||
|
||||
public static final String NULL_DEREFERENCE = "NULL_DEREFERENCE";
|
||||
|
||||
private static InferResults inferResults;
|
||||
|
||||
@BeforeClass
|
||||
public static void loadResults() throws InterruptedException, IOException {
|
||||
inferResults = InferResults.loadInferResults(DynamicDispatchTest.class, DynamicDispatchFile);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void matchErrors()
|
||||
throws InterruptedException, IOException, InferException {
|
||||
String[] methods = {
|
||||
"interfaceShouldNotCauseFalseNegativeEasy",
|
||||
"dynamicDispatchShouldNotCauseFalseNegativeEasy",
|
||||
"interfaceShouldNotCauseFalseNegativeHard"
|
||||
// TODO: add dynamic dispatch support to make these tests work
|
||||
// "dynamicDispatchShouldNotCauseFalseNegativeHardTODO"
|
||||
};
|
||||
|
||||
assertThat(
|
||||
"Results should contain null dereference",
|
||||
inferResults,
|
||||
containsExactly(
|
||||
NULL_DEREFERENCE,
|
||||
DynamicDispatchFile,
|
||||
methods
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
@ -1,67 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2013 - present Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
//Class to tests resource leaks on the class FilterInputStream and its subclasses
|
||||
|
||||
package endtoend.java.infer;
|
||||
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static utils.matchers.ResultContainsExactly.containsExactly;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import utils.InferException;
|
||||
import utils.InferResults;
|
||||
|
||||
public class FilterInputStreamLeaksTest {
|
||||
|
||||
public static final String SOURCE_FILE =
|
||||
"infer/tests/codetoanalyze/java/infer/FilterInputStreamLeaks.java";
|
||||
|
||||
public static final String RESOURCE_LEAK = "RESOURCE_LEAK";
|
||||
|
||||
private static InferResults inferResults;
|
||||
|
||||
@BeforeClass
|
||||
public static void loadResults() throws InterruptedException, IOException {
|
||||
inferResults = InferResults.loadInferResults(
|
||||
FilterInputStreamLeaksTest.class,
|
||||
SOURCE_FILE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test()
|
||||
throws InterruptedException, IOException, InferException {
|
||||
String[] methods = {
|
||||
"bufferedInputStreamNotClosedAfterRead",
|
||||
"checkedInputStreamNotClosedAfterRead",
|
||||
"cipherInputStreamNotClosedAfterSkip",
|
||||
"dataInputStreamNotClosedAfterRead",
|
||||
"deflaterInputStreamNotClosedAfterRead",
|
||||
"gzipInputStreamNotClosedAfterRead",
|
||||
"gzipInputStreamNotClosedAfterRead",
|
||||
"digestInputStreamNotClosedAfterRead",
|
||||
"inflaterInputStreamNotClosedAfterRead",
|
||||
"pushbackInputStreamNotClosedAfterRead",
|
||||
};
|
||||
assertThat(
|
||||
"Results should contain a resource leak error",
|
||||
inferResults,
|
||||
containsExactly(
|
||||
RESOURCE_LEAK,
|
||||
SOURCE_FILE,
|
||||
methods
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
@ -1,68 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2013 - present Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
//Class to tests resource leaks on the class FilterOutputStream and its subclasses
|
||||
|
||||
package endtoend.java.infer;
|
||||
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static utils.matchers.ResultContainsExactly.containsExactly;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import utils.InferException;
|
||||
import utils.InferResults;
|
||||
|
||||
public class FilterOutputStreamLeaksTest {
|
||||
|
||||
public static final String SOURCE_FILE =
|
||||
"infer/tests/codetoanalyze/java/infer/FilterOutputStreamLeaks.java";
|
||||
|
||||
public static final String RESOURCE_LEAK = "RESOURCE_LEAK";
|
||||
|
||||
private static InferResults inferResults;
|
||||
|
||||
@BeforeClass
|
||||
public static void loadResults() throws InterruptedException, IOException {
|
||||
inferResults = InferResults.loadInferResults(
|
||||
FilterOutputStreamLeaksTest.class,
|
||||
SOURCE_FILE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test()
|
||||
throws InterruptedException, IOException, InferException {
|
||||
String[] methods = {
|
||||
"filterOutputStreamNotClosedAfterWrite",
|
||||
"dataOutputStreamNotClosedAfterWrite",
|
||||
"bufferedOutputStreamNotClosedAfterWrite",
|
||||
"checkedOutputStreamNotClosedAfterWrite",
|
||||
"cipherOutputStreamNotClosedAfterWrite",
|
||||
"deflaterOutputStreamNotClosedAfterWrite",
|
||||
"digestOutputStreamNotClosedAfterWrite",
|
||||
"inflaterOutputStreamNotClosedAfterWrite",
|
||||
"gzipOutputStreamNotClosedAfterFlush",
|
||||
"gzipOutputStreamNotClosedAfterFlush",
|
||||
"printStreamNotClosedAfterWrite",
|
||||
};
|
||||
assertThat(
|
||||
"Results should contain a resource leak error",
|
||||
inferResults,
|
||||
containsExactly(
|
||||
RESOURCE_LEAK,
|
||||
SOURCE_FILE,
|
||||
methods
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
@ -1,74 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2016 - present Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
package endtoend.java.infer;
|
||||
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static utils.matchers.ResultContainsExactly.containsExactly;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import utils.InferException;
|
||||
import utils.InferResults;
|
||||
|
||||
public class GuardedByTest {
|
||||
|
||||
public static final String SOURCE_FILE =
|
||||
"infer/tests/codetoanalyze/java/infer/GuardedByExample.java";
|
||||
|
||||
public static final String UNSAFE_GUARDED_BY_ACCESS = "UNSAFE_GUARDED_BY_ACCESS";
|
||||
|
||||
private static InferResults inferResults;
|
||||
|
||||
@BeforeClass
|
||||
public static void loadResults() throws InterruptedException, IOException {
|
||||
inferResults = InferResults.loadInferResults(
|
||||
GuardedByTest.class,
|
||||
SOURCE_FILE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void matchErrors()
|
||||
throws IOException, InterruptedException, InferException {
|
||||
String[] methods = {
|
||||
"readFBad",
|
||||
"writeFBad",
|
||||
"readFBadWrongLock",
|
||||
"writeFBadWrongLock",
|
||||
"readFAfterBlockBad",
|
||||
"writeFAfterBlockBad",
|
||||
"readFBadWrongAnnotation",
|
||||
"synchronizedMethodReadBad",
|
||||
"synchronizedMethodWriteBad",
|
||||
"readHBad",
|
||||
"readHBadSynchronizedMethodShouldntHelp",
|
||||
"synchronizedOnThisBad",
|
||||
"readFromInnerClassBad1",
|
||||
"readFromInnerClassBad2",
|
||||
"byRefTrickyBad",
|
||||
// TODO: report these
|
||||
// "unguardedCallSiteBad1",
|
||||
// "unguardedCallSiteBad2",
|
||||
// "unguardedCallSiteBad3",
|
||||
};
|
||||
assertThat(
|
||||
"Results should contain " + UNSAFE_GUARDED_BY_ACCESS,
|
||||
inferResults,
|
||||
containsExactly(
|
||||
UNSAFE_GUARDED_BY_ACCESS,
|
||||
SOURCE_FILE,
|
||||
methods
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
@ -1,118 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2013 - present Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
package endtoend.java.infer;
|
||||
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static utils.matchers.ResultContainsErrorInMethod.contains;
|
||||
import static utils.matchers.ResultContainsNoErrorInMethod.doesNotContain;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import utils.InferException;
|
||||
import utils.InferResults;
|
||||
|
||||
public class HashMapModelTest {
|
||||
|
||||
public static final String HashMapModelTest =
|
||||
"infer/tests/codetoanalyze/java/infer/HashMapExample.java";
|
||||
|
||||
public static final String NULL_DEREFERENCE = "NULL_DEREFERENCE";
|
||||
|
||||
private static InferResults inferResults;
|
||||
|
||||
@BeforeClass
|
||||
public static void loadResults() throws InterruptedException, IOException {
|
||||
inferResults = InferResults.loadInferResults(
|
||||
HashMapModelTest.class,
|
||||
HashMapModelTest);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenInferRunsOnPutIntegerTwiceThenGetTwiceThenNPEIsNotFound()
|
||||
throws InterruptedException, IOException, InferException {
|
||||
assertThat(
|
||||
"Results should not contain null pointer exception error",
|
||||
inferResults,
|
||||
doesNotContain(
|
||||
NULL_DEREFERENCE,
|
||||
HashMapModelTest,
|
||||
"putIntegerTwiceThenGetTwice")
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenInferRunsOnContainsIntegerTwiceThenGetTwiceThenNPEIsNotFound()
|
||||
throws InterruptedException, IOException, InferException {
|
||||
assertThat(
|
||||
"Results should contain null pointer exception error",
|
||||
inferResults,
|
||||
doesNotContain(
|
||||
NULL_DEREFERENCE,
|
||||
HashMapModelTest,
|
||||
"containsIntegerTwiceThenGetTwice")
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenInferRunsOnGetOneIntegerWithoutCheckThenNPEIsFound()
|
||||
throws InterruptedException, IOException, InferException {
|
||||
assertThat(
|
||||
"Results should contain null pointer exception error",
|
||||
inferResults,
|
||||
contains(
|
||||
NULL_DEREFERENCE,
|
||||
HashMapModelTest,
|
||||
"getOneIntegerWithoutCheck")
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenInferRunsOnGetTwoIntegersWithOneCheckThenNPEIsFound()
|
||||
throws InterruptedException, IOException, InferException {
|
||||
assertThat(
|
||||
"Results should contain null pointer exception error",
|
||||
inferResults,
|
||||
contains(
|
||||
NULL_DEREFERENCE,
|
||||
HashMapModelTest,
|
||||
"getTwoIntegersWithOneCheck")
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenInferRunsOnGetOrCreateIntegerThenNPEIsNotFound()
|
||||
throws InterruptedException, IOException, InferException {
|
||||
assertThat(
|
||||
"Results should not contain null pointer exception error",
|
||||
inferResults,
|
||||
doesNotContain(
|
||||
NULL_DEREFERENCE,
|
||||
HashMapModelTest,
|
||||
"getOrCreateInteger")
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenInferRunsOnGetOrCreateIntegerThenDerefThenNPEIsNotFound()
|
||||
throws InterruptedException, IOException, InferException {
|
||||
assertThat(
|
||||
"Results should not contain null pointer exception error",
|
||||
inferResults,
|
||||
doesNotContain(
|
||||
NULL_DEREFERENCE,
|
||||
HashMapModelTest,
|
||||
"getOrCreateIntegerThenDeref")
|
||||
);
|
||||
}
|
||||
|
||||
}
|
@ -1,51 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2015 - present Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
package endtoend.java.infer;
|
||||
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static utils.matchers.ResultContainsNoErrorInMethod.doesNotContain;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import utils.InferException;
|
||||
import utils.InferResults;
|
||||
|
||||
public class IntegerClassTest {
|
||||
|
||||
public static final String SOURCE_FILE =
|
||||
"infer/tests/codetoanalyze/java/infer/IntegerExample.java";
|
||||
|
||||
public static final String NULL_DEREFERENCE = "NULL_DEREFERENCE";
|
||||
|
||||
private static InferResults inferResults;
|
||||
|
||||
@BeforeClass
|
||||
public static void loadResults() throws IOException {
|
||||
inferResults = InferResults.loadInferResults(IntegerClassTest.class, SOURCE_FILE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test()
|
||||
throws InterruptedException, IOException, InferException {
|
||||
assertThat(
|
||||
"Results should not contain NPE errors",
|
||||
inferResults,
|
||||
doesNotContain(
|
||||
NULL_DEREFERENCE,
|
||||
SOURCE_FILE,
|
||||
"testIntegerEquals"
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
@ -1,66 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2015 - present Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
package endtoend.java.infer;
|
||||
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static utils.matchers.ResultContainsErrorInMethod.contains;
|
||||
import static utils.matchers.ResultContainsNoErrorInMethod.doesNotContain;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import utils.InferException;
|
||||
import utils.InferResults;
|
||||
|
||||
public class JunitAssertionTest {
|
||||
|
||||
public static final String JunitAssertionFile =
|
||||
"infer/tests/codetoanalyze/java/infer/JunitAssertion.java";
|
||||
|
||||
public static final String NULL_DEREFERENCE = "NULL_DEREFERENCE";
|
||||
|
||||
private static InferResults inferResults;
|
||||
|
||||
@BeforeClass
|
||||
public static void loadResults() throws InterruptedException, IOException {
|
||||
inferResults = InferResults.loadInferResults(JunitAssertionTest.class, JunitAssertionFile);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void inferShouldUseAssertedPredicate()
|
||||
throws IOException, InterruptedException, InferException {
|
||||
assertThat(
|
||||
"Results should contain null pointer exception error",
|
||||
inferResults,
|
||||
doesNotContain(
|
||||
NULL_DEREFERENCE,
|
||||
JunitAssertionFile,
|
||||
"consistentAssertion"
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void inferShouldUseAssertionInconsistency()
|
||||
throws IOException, InterruptedException, InferException {
|
||||
assertThat(
|
||||
"Results should contain null pointer exception error",
|
||||
inferResults,
|
||||
contains(
|
||||
NULL_DEREFERENCE,
|
||||
JunitAssertionFile,
|
||||
"inconsistentAssertion"
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
@ -1,92 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2013 - present Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
package endtoend.java.infer;
|
||||
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static utils.matchers.ResultContainsExactly.containsExactly;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import utils.InferException;
|
||||
import utils.InferResults;
|
||||
|
||||
public class NullPointerExceptionTest {
|
||||
|
||||
public static final String SOURCE_FILE =
|
||||
"infer/tests/codetoanalyze/java/infer/NullPointerExceptions.java";
|
||||
|
||||
public static final String NULL_DEREFERENCE = "NULL_DEREFERENCE";
|
||||
|
||||
private static InferResults inferResults;
|
||||
|
||||
@BeforeClass
|
||||
public static void loadResults() throws InterruptedException, IOException {
|
||||
inferResults = InferResults.loadInferResults(
|
||||
NullPointerExceptionTest.class,
|
||||
SOURCE_FILE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void matchErrors()
|
||||
throws IOException, InterruptedException, InferException {
|
||||
String[] methods = {
|
||||
"nullPointerException",
|
||||
"nullPointerExceptionInterProc",
|
||||
"nullPointerExceptionWithExceptionHandling",
|
||||
"nullPointerExceptionWithArray",
|
||||
"nullPointerExceptionWithAChainOfFields",
|
||||
"nullPointerExceptionWithNullObjectParameter",
|
||||
"nullPointerExceptionWithNullArrayParameter",
|
||||
"nullPointerExceptionFromFaillingResourceConstructor",
|
||||
"nullPointerExceptionFromFailingFileOutputStreamConstructor",
|
||||
"nullPointerExceptionUnlessFrameFails",
|
||||
"hashmapNPE",
|
||||
"NPEvalueOfFromHashmapBad",
|
||||
"cursorFromContentResolverNPE",
|
||||
"nullPointerExceptionInArrayLengthLoop",
|
||||
"nullPointerExceptionCallArrayReadMethod",
|
||||
"nullableFieldNPE",
|
||||
"nullableParamNPE",
|
||||
"badCheckShouldCauseNPE",
|
||||
"nullPointerExceptionArrayLength",
|
||||
"npeWithDollars",
|
||||
"someNPEAfterResourceLeak",
|
||||
"derefNullableGetter",
|
||||
"derefNullableRet",
|
||||
"derefUndefNullableRet",
|
||||
"derefUndefNullableRetWrapper",
|
||||
"testSystemGetPropertyArgument",
|
||||
"testSystemGetPropertyReturn",
|
||||
"derefNull",
|
||||
"nullListFiles",
|
||||
"nullTryLock",
|
||||
"tryLockThrows",
|
||||
"dereferenceAfterLoopOnList",
|
||||
"dereferenceAfterUnlock1",
|
||||
"dereferenceAfterUnlock2",
|
||||
"optionalNPE",
|
||||
"stringVarEqualsFalseNPE",
|
||||
"stringConstantEqualsFalseNotNPE_FP",
|
||||
};
|
||||
assertThat(
|
||||
"Results should contain " + NULL_DEREFERENCE,
|
||||
inferResults,
|
||||
containsExactly(
|
||||
NULL_DEREFERENCE,
|
||||
SOURCE_FILE,
|
||||
methods
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
@ -1,66 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2013 - present Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
//Class to tests resource leaks on the class FilterOutputStream and its subclasses
|
||||
|
||||
package endtoend.java.infer;
|
||||
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static utils.matchers.ResultContainsExactly.containsExactly;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
|
||||
import utils.InferException;
|
||||
import utils.InferResults;
|
||||
|
||||
public class ReaderLeaksTest {
|
||||
|
||||
Path t;
|
||||
|
||||
public static final String ReaderLeaks =
|
||||
"infer/tests/codetoanalyze/java/infer/ReaderLeaks.java";
|
||||
|
||||
public static final String RESOURCE_LEAK = "RESOURCE_LEAK";
|
||||
|
||||
private static InferResults inferResults;
|
||||
|
||||
@BeforeClass
|
||||
public static void loadResults() throws InterruptedException, IOException {
|
||||
inferResults = InferResults.loadInferResults(ReaderLeaksTest.class, ReaderLeaks);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test()
|
||||
throws InterruptedException, IOException, InferException {
|
||||
String[] methods = {
|
||||
"readerNotClosedAfterRead",
|
||||
"bufferedReaderNotClosedAfterRead",
|
||||
"inputStreamReaderNotClosedAfterRead",
|
||||
"fileReaderNotClosedAfterRead",
|
||||
"pushbackReaderNotClosedAfterRead",
|
||||
"pipedReaderNotClosedAfterConstructedWithWriter",
|
||||
"pipedReaderNotClosedAfterConnect",
|
||||
"pipedReaderFalsePositive",
|
||||
};
|
||||
assertThat(
|
||||
"Results should contain the following resource leak errors",
|
||||
inferResults,
|
||||
containsExactly(
|
||||
RESOURCE_LEAK,
|
||||
ReaderLeaks,
|
||||
methods
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
@ -1,138 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2013 - present Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
package endtoend.java.infer;
|
||||
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static utils.matchers.ResultContainsNumberOfErrorsInMethod.containsNumberOfErrors;
|
||||
import static utils.matchers.ResultContainsExactly.containsExactly;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import utils.InferException;
|
||||
import utils.InferResults;
|
||||
|
||||
public class ResourceLeaksTest {
|
||||
|
||||
public static final String SOURCE_FILE =
|
||||
"infer/tests/codetoanalyze/java/infer/ResourceLeaks.java";
|
||||
|
||||
public static final String RESOURCE_LEAK = "RESOURCE_LEAK";
|
||||
|
||||
private static InferResults inferResults;
|
||||
|
||||
@BeforeClass
|
||||
public static void loadResults() throws InterruptedException, IOException {
|
||||
inferResults = InferResults.loadInferResults(ResourceLeaksTest.class, SOURCE_FILE);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void test()
|
||||
throws InterruptedException, IOException, InferException {
|
||||
String[] methods = {
|
||||
"fileOutputStreamNotClosed",
|
||||
"fileOutputStreamNotClosedAfterWrite",
|
||||
"fileOutputStreamOneLeak",
|
||||
"fileOutputStreamTwoLeaks1",
|
||||
"fileOutputStreamTwoLeaks2",
|
||||
"twoResources",
|
||||
"twoResourcesServerSocket",
|
||||
"twoResourcesRandomAccessFile",
|
||||
"nestedBad1",
|
||||
"nestedBad2",
|
||||
"objectInputStreamClosedNestedBad",
|
||||
"objectOutputStreamClosedNestedBad",
|
||||
"zipFileLeakExceptionalBranch",
|
||||
"jarFileNotClosed",
|
||||
"fileInputStreamNotClosedAfterRead",
|
||||
"pipedInputStreamNotClosedAfterRead",
|
||||
"pipedOutputStreamNotClosedAfterWrite",
|
||||
"objectOutputStreamNotClosedAfterWrite",
|
||||
"objectInputStreamNotClosedAfterRead",
|
||||
"jarInputStreamLeak",
|
||||
"nestedBadJarInputStream",
|
||||
"jarOutputStreamLeak",
|
||||
"nestedBadJarOutputStream",
|
||||
"socketNotClosed",
|
||||
"serverSocketNotClosed",
|
||||
"openHttpURLConnectionNotDisconnected",
|
||||
"openHttpsURLConnectionNotDisconnected",
|
||||
"parseFromInputStreamAndLeak",
|
||||
"readInstallationFileBad",
|
||||
"readConfigNotCloseStream",
|
||||
"themeObtainTypedArrayAndLeak",
|
||||
"activityObtainTypedArrayAndLeak",
|
||||
"contextObtainTypedArrayAndLeak",
|
||||
"copyFileLeak",
|
||||
"copyFileLeak",
|
||||
"scannerNotClosed",
|
||||
"deflaterLeak",
|
||||
"inflaterLeak",
|
||||
};
|
||||
assertThat(
|
||||
"Results should contain the following resource leak errors",
|
||||
inferResults,
|
||||
containsExactly(
|
||||
RESOURCE_LEAK,
|
||||
SOURCE_FILE,
|
||||
methods
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenInferRunsOnFileOutputStreamOneLeakThenOneLeaksIsFound()
|
||||
throws InterruptedException, IOException, InferException {
|
||||
assertThat(
|
||||
"Results should contain 1 resource leak error",
|
||||
inferResults,
|
||||
containsNumberOfErrors(
|
||||
RESOURCE_LEAK,
|
||||
SOURCE_FILE,
|
||||
"fileOutputStreamOneLeak",
|
||||
1
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenInferRunsOnFileOutputStreamTwoLeaks1ThenTwoLeaksAreFound()
|
||||
throws InterruptedException, IOException, InferException {
|
||||
assertThat(
|
||||
"Results should contain 2 resource leak errors",
|
||||
inferResults,
|
||||
containsNumberOfErrors(
|
||||
RESOURCE_LEAK,
|
||||
SOURCE_FILE,
|
||||
"fileOutputStreamTwoLeaks1",
|
||||
2
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenInferRunsOnFileOutputStreamTwoLeaks2ThenTwoLeaksAreFound()
|
||||
throws InterruptedException, IOException, InferException {
|
||||
assertThat(
|
||||
"Results should contain 2 resource leak errors",
|
||||
inferResults,
|
||||
containsNumberOfErrors(
|
||||
RESOURCE_LEAK,
|
||||
SOURCE_FILE,
|
||||
"fileOutputStreamTwoLeaks2",
|
||||
2
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
@ -1,65 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2013 - present Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
package endtoend.java.infer;
|
||||
|
||||
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static utils.matchers.ResultContainsErrorInMethod.contains;
|
||||
import static utils.matchers.ResultContainsOnlyTheseErrors.containsOnly;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import utils.InferException;
|
||||
import utils.InferResults;
|
||||
|
||||
public class ReturnValueIgnoredTest {
|
||||
|
||||
public static final String ReturnValueIgnored =
|
||||
"infer/tests/codetoanalyze/java/infer/ReturnValueIgnored.java";
|
||||
|
||||
public static final String RETURN_VALUE_IGNORED = "RETURN_VALUE_IGNORED";
|
||||
|
||||
private static InferResults inferResults;
|
||||
|
||||
@BeforeClass
|
||||
public static void loadResults() throws InterruptedException, IOException {
|
||||
inferResults = InferResults.loadInferResults(ReturnValueIgnoredTest.class, ReturnValueIgnored);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void returnValueIgnoredTest()
|
||||
throws IOException, InferException, InterruptedException {
|
||||
assertThat(
|
||||
"Results should contain a return value ignored error",
|
||||
inferResults,
|
||||
contains(
|
||||
RETURN_VALUE_IGNORED,
|
||||
ReturnValueIgnored,
|
||||
"returnValueIgnored"
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenInferRunsOnReturnValueIgThenOnlyTheExpectedErrorsAreFound()
|
||||
throws InterruptedException, IOException, InferException {
|
||||
String[] expectedMethods = {"returnValueIgnored"};
|
||||
assertThat(
|
||||
"No unexpected errors should be found", inferResults,
|
||||
containsOnly(
|
||||
RETURN_VALUE_IGNORED,
|
||||
ReturnValueIgnored,
|
||||
expectedMethods));
|
||||
}
|
||||
|
||||
}
|
@ -1,81 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2013 - present Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
package endtoend.java.infer;
|
||||
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static utils.matchers.ResultContainsExactly.containsExactly;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import utils.InferException;
|
||||
import utils.InferResults;
|
||||
|
||||
public class TaintTest {
|
||||
|
||||
public static final String TaintFile =
|
||||
"infer/tests/codetoanalyze/java/infer/TaintExample.java";
|
||||
|
||||
public static final String TAINTED_VALUE = "TAINTED_VALUE_REACHING_SENSITIVE_FUNCTION";
|
||||
|
||||
public static final String NULL_DEREFERENCE = "NULL_DEREFERENCE";
|
||||
|
||||
private static InferResults inferResults;
|
||||
|
||||
@BeforeClass
|
||||
public static void loadResults() throws InterruptedException, IOException {
|
||||
inferResults = InferResults.loadInferResults(TaintTest.class, TaintFile);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenInferRunsOnTaintFileErrorFound()
|
||||
throws InterruptedException, IOException, InferException {
|
||||
String[] methods = {
|
||||
"socketNotVerifiedSimple",
|
||||
"socketVerifiedForgotToCheckRetval",
|
||||
"socketIgnoreExceptionNoVerify",
|
||||
"callReadInputStreamCauseTaintError",
|
||||
"taintingShouldNotPreventInference1",
|
||||
"taintingShouldNotPreventInference2",
|
||||
"simpleTaintErrorWithModelMethods",
|
||||
"interprocTaintErrorWithModelMethods1",
|
||||
"interprocTaintErrorWithModelMethods2",
|
||||
"interprocTaintErrorWithModelMethods3",
|
||||
"simpleTaintErrorWithModelMethodsUndefined",
|
||||
"interprocTaintErrorWithModelMethodsUndefined1",
|
||||
"interprocTaintErrorWithModelMethodsUndefined2",
|
||||
"interprocTaintErrorWithModelMethodsUndefined3",
|
||||
"contentValuesPutWithTaintedString",
|
||||
"testPrivacySourceAnnot",
|
||||
"testPrivacySinkAnnot1",
|
||||
"testPrivacySinkAnnot3",
|
||||
"testPrivacySourceInstanceFieldAnnot",
|
||||
"testPrivacySourceStaticFieldAnnot",
|
||||
"testPrivacySourceFieldAnnotPropagation",
|
||||
"testIntegritySourceAnnot",
|
||||
"testIntegritySourceInstanceFieldAnnot",
|
||||
"testIntegritySourceStaticFieldAnnot",
|
||||
"testIntegritySinkAnnotReport",
|
||||
};
|
||||
|
||||
assertThat(
|
||||
"Results should contain tainted value reaching sensitive function.",
|
||||
inferResults,
|
||||
containsExactly(
|
||||
TAINTED_VALUE,
|
||||
TaintFile,
|
||||
methods
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
@ -1,62 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2013 - present Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
package endtoend.java.infer;
|
||||
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static utils.matchers.ResultContainsExactly.containsExactly;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import utils.InferException;
|
||||
import utils.InferResults;
|
||||
|
||||
public class WriterLeaksTest {
|
||||
|
||||
|
||||
public static final String SOURCE_FILE =
|
||||
"infer/tests/codetoanalyze/java/infer/WriterLeaks.java";
|
||||
|
||||
public static final String RESOURCE_LEAK = "RESOURCE_LEAK";
|
||||
|
||||
private static InferResults inferResults;
|
||||
|
||||
@BeforeClass
|
||||
public static void loadResults() throws InterruptedException, IOException {
|
||||
inferResults = InferResults.loadInferResults(WriterLeaksTest.class, SOURCE_FILE);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void test()
|
||||
throws InterruptedException, IOException, InferException {
|
||||
String[] methods = {
|
||||
"writerNotClosedAfterWrite",
|
||||
"printWriterNotClosedAfterAppend",
|
||||
"bufferedWriterNotClosedAfterWrite",
|
||||
"outputStreamWriterNotClosedAfterWrite",
|
||||
"fileWriterNotClosedAfterWrite",
|
||||
"pipedWriterNotClosedAfterConstructedWithReader",
|
||||
"pipedWriterNotClosedAfterConnect",
|
||||
};
|
||||
assertThat(
|
||||
"Results should contain a resource leak error",
|
||||
inferResults,
|
||||
containsExactly(
|
||||
RESOURCE_LEAK,
|
||||
SOURCE_FILE,
|
||||
methods
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in new issue