33 TaintMapTy TM = State->get<TaintMap>();
36 Out <<
"Tainted symbols:" << NL;
38 for (
const auto &I : TM)
39 Out << I.first <<
" : " << I.second << NL;
49 return addTaint(State, State->getSVal(S, LCtx), Kind);
68 if (std::optional<SVal> binding =
69 State->getStateManager().getStoreManager().getDefaultBinding(
71 if (
SymbolRef Sym = binding->getAsSymbol())
82 if (
const SymbolicRegion *SR = dyn_cast_or_null<SymbolicRegion>(R))
83 return addTaint(State, SR->getSymbol(), Kind);
91 while (
const SymbolCast *SC = dyn_cast<SymbolCast>(Sym))
92 Sym = SC->getOperand();
109 if (
const SymbolicRegion *SR = dyn_cast_or_null<SymbolicRegion>(R))
117 while (
const SymbolCast *SC = dyn_cast<SymbolCast>(Sym))
118 Sym = SC->getOperand();
136 return addTaint(State, ParentSym, Kind);
138 const TaintedSubRegions *SavedRegs = State->get<DerivedSymTaint>(ParentSym);
139 TaintedSubRegions::Factory &F = State->get_context<TaintedSubRegions>();
140 TaintedSubRegions Regs = SavedRegs ? *SavedRegs : F.getEmptyMap();
143 ProgramStateRef NewState = State->set<DerivedSymTaint>(ParentSym, Regs);
198 bool returnFirstOnly) {
199 SVal val = State->getSVal(S, LCtx);
205 bool returnFirstOnly) {
216 bool returnFirstOnly) {
217 std::vector<SymbolRef> TaintedSymbols;
219 return TaintedSymbols;
222 if (
const ElementRegion *ER = dyn_cast<ElementRegion>(Reg)) {
223 std::vector<SymbolRef> TaintedIndex =
225 llvm::append_range(TaintedSymbols, TaintedIndex);
226 if (returnFirstOnly && !TaintedSymbols.empty())
227 return TaintedSymbols;
232 std::vector<SymbolRef> TaintedRegions =
234 llvm::append_range(TaintedSymbols, TaintedRegions);
235 if (returnFirstOnly && !TaintedSymbols.empty())
236 return TaintedSymbols;
241 if (
const SubRegion *ER = dyn_cast<SubRegion>(Reg)) {
242 std::vector<SymbolRef> TaintedSubRegions =
244 llvm::append_range(TaintedSymbols, TaintedSubRegions);
245 if (returnFirstOnly && !TaintedSymbols.empty())
246 return TaintedSymbols;
249 return TaintedSymbols;
255 bool returnFirstOnly) {
256 std::vector<SymbolRef> TaintedSymbols;
258 return TaintedSymbols;
261 if (
const auto &Opts = State->getAnalysisManager().getAnalyzerOptions();
268 if (!isa<SymbolData>(SubSym))
271 if (
const TaintTagType *Tag = State->get<TaintMap>(SubSym)) {
273 TaintedSymbols.push_back(SubSym);
275 return TaintedSymbols;
279 if (
const auto *SD = dyn_cast<SymbolDerived>(SubSym)) {
282 State, SD->getParentSymbol(), Kind, returnFirstOnly);
283 llvm::append_range(TaintedSymbols, TaintedParents);
284 if (returnFirstOnly && !TaintedSymbols.empty())
285 return TaintedSymbols;
290 if (
const TaintedSubRegions *Regs =
291 State->get<DerivedSymTaint>(SD->getParentSymbol())) {
293 for (
auto I : *Regs) {
299 TaintedSymbols.push_back(SD->getParentSymbol());
300 if (returnFirstOnly && !TaintedSymbols.empty())
301 return TaintedSymbols;
308 if (
const auto *SRV = dyn_cast<SymbolRegionValue>(SubSym)) {
309 std::vector<SymbolRef> TaintedRegions =
311 llvm::append_range(TaintedSymbols, TaintedRegions);
312 if (returnFirstOnly && !TaintedSymbols.empty())
313 return TaintedSymbols;
317 if (
const auto *SC = dyn_cast<SymbolCast>(SubSym)) {
318 std::vector<SymbolRef> TaintedCasts =
320 llvm::append_range(TaintedSymbols, TaintedCasts);
321 if (returnFirstOnly && !TaintedSymbols.empty())
322 return TaintedSymbols;
325 return TaintedSymbols;
#define REGISTER_MAP_WITH_PROGRAMSTATE(Name, Key, Value)
Declares an immutable map of type NameTy, suitable for placement into the ProgramState.
#define REGISTER_MAP_FACTORY_WITH_PROGRAMSTATE(Name, Key, Value)
Declares an immutable map type Name and registers the factory for such maps in the program state,...
It wraps the AnalysisDeclContext to represent both the call stack with the help of StackFrameContext ...
Stmt - This represents one statement.
ElementRegion is used to represent both array elements and casts.
MemRegion - The root abstract class for all memory regions.
LLVM_ATTRIBUTE_RETURNS_NONNULL const MemRegion * getBaseRegion() const
SVal - This represents a symbolic expression, which can be either an L-value or an R-value.
SubRegion - A region that subsets another larger region.
bool isSubRegionOf(const MemRegion *R) const override
Check if the region is a subregion of the given region.
llvm::iterator_range< symbol_iterator > symbols() const
virtual unsigned computeComplexity() const =0
Represents a cast expression.
SymbolicRegion - A special, "non-concrete" region.
TypedValueRegion - An abstract class representing regions having a typed value.
While nonloc::CompoundVal covers a few simple use cases, nonloc::LazyCompoundVal is a more performant...
std::vector< SymbolRef > getTaintedSymbolsImpl(ProgramStateRef State, const Stmt *S, const LocationContext *LCtx, TaintTagType Kind, bool returnFirstOnly)
ProgramStateRef addTaint(ProgramStateRef State, const Stmt *S, const LocationContext *LCtx, TaintTagType Kind=TaintTagGeneric)
Create a new state in which the value of the statement is marked as tainted.
std::vector< SymbolRef > getTaintedSymbols(ProgramStateRef State, const Stmt *S, const LocationContext *LCtx, TaintTagType Kind=TaintTagGeneric)
Returns the tainted Symbols for a given Statement and state.
bool isTainted(ProgramStateRef State, const Stmt *S, const LocationContext *LCtx, TaintTagType Kind=TaintTagGeneric)
Check if the statement has a tainted value in the given state.
ProgramStateRef removeTaint(ProgramStateRef State, SVal V)
void printTaint(ProgramStateRef State, raw_ostream &Out, const char *nl="\n", const char *sep="")
ProgramStateRef addPartialTaint(ProgramStateRef State, SymbolRef ParentSym, const SubRegion *SubRegion, TaintTagType Kind=TaintTagGeneric)
Create a new state in a which a sub-region of a given symbol is tainted.
LLVM_DUMP_METHOD void dumpTaint(ProgramStateRef State)
The JSON file list parser is used to communicate input to InstallAPI.
const FunctionProtoType * T