Summary: Change the logic of the annotation reachability checker in the following ways: 1. Sanitizers take priority over sinks, i.e. a procedure that is both a sink and a sanitizer is not a sink. This changes the existing tests that seemed to assume the opposite. However I think that way is more useful and goes better with the fact that sanitizers are specified as "overrides". 2. When applying a summary, check again that we are not in a sanitizer for the corresponding sink. Without (2) this there was a subtle bug when several rules were specified. For example, if `sink_wrapper()` wraps `sink()` for a rule `R` then the summary of `sink_wrapper()` will be: `R-sink : call to sink()`. Then, suppose `sanitizer()` calls `sink_wrapper()` and `sanitizer()` is a sanitizer for `R` but not for another rule `R'`. The previous code would add the call to `sink()` to the summary of `sanitizer()` because it's not a sanitizer for `R'`, even though `sink()` is not a sink for `R'`! The current code will re-apply the rules correctly so that sinks are matched only against the right sanitizers. Reviewed By: skcho Differential Revision: D16895577 fbshipit-source-id: 266cc4940master
parent
00cbc9c1e4
commit
0af754f3d7
@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
// low-level implementation, clients shouldn't use directly
|
||||
namespace details {
|
||||
|
||||
struct LowLevel {
|
||||
LowLevel() {}
|
||||
~LowLevel() {}
|
||||
};
|
||||
|
||||
void low_level() {}
|
||||
} // namespace details
|
||||
|
||||
// calls into this namespace from client code are allowed
|
||||
namespace safewrapper {
|
||||
|
||||
struct Wrapper {
|
||||
details::LowLevel wrapped;
|
||||
|
||||
Wrapper() : wrapped() {}
|
||||
~Wrapper() {}
|
||||
};
|
||||
|
||||
void wrapper() { details::low_level(); }
|
||||
|
||||
} // namespace safewrapper
|
@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
namespace safewrapper {
|
||||
|
||||
struct Wrapper {
|
||||
Wrapper();
|
||||
~Wrapper();
|
||||
};
|
||||
|
||||
void wrapper();
|
||||
} // namespace safewrapper
|
||||
|
||||
namespace details {
|
||||
void low_level();
|
||||
|
||||
struct LowLevel {
|
||||
LowLevel();
|
||||
~LowLevel();
|
||||
};
|
||||
} // namespace details
|
@ -1,5 +1,5 @@
|
||||
codetoanalyze/cpp/annotation-reachability/reachability.cpp, CheckFrom::Destructive::~Destructive, 0, TEST_ANNOT_REACH, no_bucket, ERROR, []
|
||||
codetoanalyze/cpp/annotation-reachability/reachability.cpp, CheckFrom::danger_via, 2, TEST_ANNOT_REACH, no_bucket, ERROR, []
|
||||
codetoanalyze/cpp/annotation-reachability/reachability.cpp, CheckFrom::death_via, 0, TEST_ANNOT_REACH, no_bucket, ERROR, []
|
||||
codetoanalyze/cpp/annotation-reachability/reachability.cpp, CheckFrom::imminent_danger, 0, TEST_ANNOT_REACH, no_bucket, ERROR, []
|
||||
codetoanalyze/cpp/annotation-reachability/reachability.cpp, CheckFrom::imminent_death, 0, TEST_ANNOT_REACH, no_bucket, ERROR, []
|
||||
codetoanalyze/cpp/annotation-reachability/sources/client.cpp, client::CallLowLevelBad::CallLowLevelBad, 0, API_ACCESS_VIOLATION, no_bucket, ERROR, []
|
||||
codetoanalyze/cpp/annotation-reachability/sources/client.cpp, client::CallLowLevelBad::~CallLowLevelBad, 0, API_ACCESS_VIOLATION, no_bucket, ERROR, []
|
||||
codetoanalyze/cpp/annotation-reachability/sources/client.cpp, client::call_protected_api_bad, 0, API_ACCESS_VIOLATION, no_bucket, ERROR, []
|
||||
|
@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
#include "../forbidden/library.h"
|
||||
|
||||
namespace client {
|
||||
|
||||
void call_protected_api_bad() { details::low_level(); }
|
||||
|
||||
void call_wrapper_ok() { safewrapper::wrapper(); }
|
||||
|
||||
struct CallWrapperOk : public safewrapper::Wrapper {
|
||||
CallWrapperOk() {}
|
||||
~CallWrapperOk() {}
|
||||
};
|
||||
|
||||
struct CallLowLevelBad {
|
||||
details::LowLevel wrapped;
|
||||
|
||||
CallLowLevelBad() {}
|
||||
~CallLowLevelBad() {}
|
||||
};
|
||||
|
||||
} // namespace client
|
Loading…
Reference in new issue