Reviewed By: akotulski Differential Revision: D4007372 fbshipit-source-id: 076dc36master
parent
727af5d660
commit
3624fea737
@ -0,0 +1,23 @@
|
||||
# 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.clang
|
||||
|
||||
OPTIONS = -x c++ -std=c++11 -isystem$(MODELS_DIR)/cpp/include -isystem$(CLANG_INCLUDES)/c++/v1/ -c
|
||||
|
||||
ANALYZER = quandary
|
||||
INFERPRINT_OPTIONS = --issues-txt
|
||||
|
||||
FILES = \
|
||||
basics.cpp \
|
||||
|
||||
compile:
|
||||
clang $(OPTIONS) $(FILES)
|
||||
|
||||
analyze:
|
||||
$(INFER_BIN) -a $(ANALYZER) --cxx --ml-buckets cpp --check-duplicate-symbols -- clang $(OPTIONS) $(FILES) >/dev/null 2>duplicates.txt
|
||||
grep "DUPLICATE_SYMBOLS" duplicates.txt; test $$? -ne 0
|
@ -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.
|
||||
*/
|
||||
|
||||
extern void* __infer_taint_source();
|
||||
extern void __infer_taint_sink(void*);
|
||||
|
||||
namespace basics {
|
||||
|
||||
class Obj {
|
||||
public:
|
||||
int field;
|
||||
};
|
||||
|
||||
void* returnSource() { return __infer_taint_source(); }
|
||||
|
||||
void callSink(void* param) { __infer_taint_sink(param); }
|
||||
|
||||
void* id(void* param) { return param; }
|
||||
|
||||
void sourceToSinkDirectBad() {
|
||||
void* source = __infer_taint_source();
|
||||
__infer_taint_sink(source);
|
||||
}
|
||||
|
||||
void returnSourceToSinkBad() {
|
||||
void* source = returnSource();
|
||||
__infer_taint_sink(source);
|
||||
}
|
||||
|
||||
void sourceThenCallSinkBad() {
|
||||
void* source = __infer_taint_source();
|
||||
callSink(source);
|
||||
}
|
||||
|
||||
void propagateBad() {
|
||||
void* source = __infer_taint_source();
|
||||
void* launderedSource = id(source);
|
||||
callSink(launderedSource);
|
||||
}
|
||||
}
|
@ -0,0 +1,4 @@
|
||||
basics.cpp:28: ERROR: QUANDARY_TAINT_ERROR Error: Other(__infer_taint_source at [line 27]) -> Other(__infer_taint_sink at [line 28]) via { }
|
||||
basics.cpp:33: ERROR: QUANDARY_TAINT_ERROR Error: Other(__infer_taint_source at [line 20]) -> Other(__infer_taint_sink at [line 33]) via { basics::returnSource at [line 32] }
|
||||
basics.cpp:38: ERROR: QUANDARY_TAINT_ERROR Error: Other(__infer_taint_source at [line 37]) -> Other(__infer_taint_sink at [line 22]) via { basics::callSink at [line 38] }
|
||||
basics.cpp:44: ERROR: QUANDARY_TAINT_ERROR Error: Other(__infer_taint_source at [line 42]) -> Other(__infer_taint_sink at [line 22]) via { basics::callSink at [line 44], basics::id at [line 43] }
|
Loading…
Reference in new issue