Ted Kremenek | dbfb5f8 | 2009-07-23 01:07:19 +0000 | [diff] [blame] | 1 | //==- CheckSecuritySyntaxOnly.cpp - Basic security checks --------*- C++ -*-==// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This file defines a set of flow-insensitive security checks. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
Argyrios Kyrtzidis | 7dd445e | 2011-02-17 21:39:33 +0000 | [diff] [blame] | 14 | #include "ClangSACheckers.h" |
Argyrios Kyrtzidis | ec8605f | 2011-03-01 01:16:21 +0000 | [diff] [blame] | 15 | #include "clang/StaticAnalyzer/Core/Checker.h" |
Ted Kremenek | 9b66371 | 2011-02-10 01:03:03 +0000 | [diff] [blame] | 16 | #include "clang/StaticAnalyzer/Core/BugReporter/BugReporter.h" |
Argyrios Kyrtzidis | 7dd445e | 2011-02-17 21:39:33 +0000 | [diff] [blame] | 17 | #include "clang/Basic/TargetInfo.h" |
Ted Kremenek | dbfb5f8 | 2009-07-23 01:07:19 +0000 | [diff] [blame] | 18 | #include "clang/AST/StmtVisitor.h" |
Ted Kremenek | 8baf86d | 2009-07-23 21:34:35 +0000 | [diff] [blame] | 19 | #include "llvm/Support/raw_ostream.h" |
Lenny Maiorani | c2dace1 | 2011-04-03 05:07:11 +0000 | [diff] [blame^] | 20 | #include "llvm/ADT/StringSwitch.h" |
Ted Kremenek | dbfb5f8 | 2009-07-23 01:07:19 +0000 | [diff] [blame] | 21 | |
| 22 | using namespace clang; |
Ted Kremenek | 9ef6537 | 2010-12-23 07:20:52 +0000 | [diff] [blame] | 23 | using namespace ento; |
Ted Kremenek | dbfb5f8 | 2009-07-23 01:07:19 +0000 | [diff] [blame] | 24 | |
Ted Kremenek | 88c8bc8 | 2010-01-15 08:20:31 +0000 | [diff] [blame] | 25 | static bool isArc4RandomAvailable(const ASTContext &Ctx) { |
| 26 | const llvm::Triple &T = Ctx.Target.getTriple(); |
| 27 | return T.getVendor() == llvm::Triple::Apple || |
Douglas Gregor | 0f56559 | 2011-01-17 19:16:24 +0000 | [diff] [blame] | 28 | T.getOS() == llvm::Triple::FreeBSD || |
| 29 | T.getOS() == llvm::Triple::NetBSD || |
| 30 | T.getOS() == llvm::Triple::OpenBSD || |
| 31 | T.getOS() == llvm::Triple::DragonFly; |
Ted Kremenek | 88c8bc8 | 2010-01-15 08:20:31 +0000 | [diff] [blame] | 32 | } |
| 33 | |
Ted Kremenek | dbfb5f8 | 2009-07-23 01:07:19 +0000 | [diff] [blame] | 34 | namespace { |
Kovarththanan Rajaratnam | ba5fb5a | 2009-11-28 06:07:30 +0000 | [diff] [blame] | 35 | class WalkAST : public StmtVisitor<WalkAST> { |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 36 | BugReporter &BR; |
Ted Kremenek | 2465047 | 2009-09-02 02:47:41 +0000 | [diff] [blame] | 37 | enum { num_setids = 6 }; |
| 38 | IdentifierInfo *II_setid[num_setids]; |
Ted Kremenek | 2c01676 | 2010-03-24 22:39:47 +0000 | [diff] [blame] | 39 | |
Ted Kremenek | 88c8bc8 | 2010-01-15 08:20:31 +0000 | [diff] [blame] | 40 | const bool CheckRand; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 41 | |
Ted Kremenek | dbfb5f8 | 2009-07-23 01:07:19 +0000 | [diff] [blame] | 42 | public: |
Lenny Maiorani | c2dace1 | 2011-04-03 05:07:11 +0000 | [diff] [blame^] | 43 | WalkAST(BugReporter &br) : BR(br), II_setid(), |
Ted Kremenek | 88c8bc8 | 2010-01-15 08:20:31 +0000 | [diff] [blame] | 44 | CheckRand(isArc4RandomAvailable(BR.getContext())) {} |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 45 | |
Ted Kremenek | dbfb5f8 | 2009-07-23 01:07:19 +0000 | [diff] [blame] | 46 | // Statement visitor methods. |
Ted Kremenek | efcbb15 | 2009-07-23 22:29:41 +0000 | [diff] [blame] | 47 | void VisitCallExpr(CallExpr *CE); |
Ted Kremenek | dbfb5f8 | 2009-07-23 01:07:19 +0000 | [diff] [blame] | 48 | void VisitForStmt(ForStmt *S); |
Ted Kremenek | 65a81a9 | 2009-08-28 00:08:09 +0000 | [diff] [blame] | 49 | void VisitCompoundStmt (CompoundStmt *S); |
Ted Kremenek | 8baf86d | 2009-07-23 21:34:35 +0000 | [diff] [blame] | 50 | void VisitStmt(Stmt *S) { VisitChildren(S); } |
Ted Kremenek | dbfb5f8 | 2009-07-23 01:07:19 +0000 | [diff] [blame] | 51 | |
| 52 | void VisitChildren(Stmt *S); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 53 | |
Ted Kremenek | efcbb15 | 2009-07-23 22:29:41 +0000 | [diff] [blame] | 54 | // Helpers. |
| 55 | IdentifierInfo *GetIdentifier(IdentifierInfo *& II, const char *str); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 56 | |
Lenny Maiorani | c2dace1 | 2011-04-03 05:07:11 +0000 | [diff] [blame^] | 57 | typedef void (WalkAST::*FnCheck)(const CallExpr *, |
| 58 | const FunctionDecl *); |
| 59 | |
Ted Kremenek | dbfb5f8 | 2009-07-23 01:07:19 +0000 | [diff] [blame] | 60 | // Checker-specific methods. |
Ted Kremenek | 8baf86d | 2009-07-23 21:34:35 +0000 | [diff] [blame] | 61 | void CheckLoopConditionForFloat(const ForStmt *FS); |
Ted Kremenek | efcbb15 | 2009-07-23 22:29:41 +0000 | [diff] [blame] | 62 | void CheckCall_gets(const CallExpr *CE, const FunctionDecl *FD); |
Zhongxing Xu | bd842e3 | 2009-11-09 12:19:26 +0000 | [diff] [blame] | 63 | void CheckCall_getpw(const CallExpr *CE, const FunctionDecl *FD); |
Zhongxing Xu | 1bf4056 | 2009-12-03 09:15:23 +0000 | [diff] [blame] | 64 | void CheckCall_mktemp(const CallExpr *CE, const FunctionDecl *FD); |
Lenny Maiorani | 5b67a82 | 2011-03-31 22:09:14 +0000 | [diff] [blame] | 65 | void CheckCall_strcpy(const CallExpr *CE, const FunctionDecl *FD); |
Lenny Maiorani | c2dace1 | 2011-04-03 05:07:11 +0000 | [diff] [blame^] | 66 | void CheckCall_strcat(const CallExpr *CE, const FunctionDecl *FD); |
Ted Kremenek | 2465047 | 2009-09-02 02:47:41 +0000 | [diff] [blame] | 67 | void CheckCall_rand(const CallExpr *CE, const FunctionDecl *FD); |
| 68 | void CheckCall_random(const CallExpr *CE, const FunctionDecl *FD); |
Ted Kremenek | 65a81a9 | 2009-08-28 00:08:09 +0000 | [diff] [blame] | 69 | void CheckUncheckedReturnValue(CallExpr *CE); |
Ted Kremenek | dbfb5f8 | 2009-07-23 01:07:19 +0000 | [diff] [blame] | 70 | }; |
| 71 | } // end anonymous namespace |
| 72 | |
| 73 | //===----------------------------------------------------------------------===// |
Ted Kremenek | efcbb15 | 2009-07-23 22:29:41 +0000 | [diff] [blame] | 74 | // Helper methods. |
| 75 | //===----------------------------------------------------------------------===// |
| 76 | |
| 77 | IdentifierInfo *WalkAST::GetIdentifier(IdentifierInfo *& II, const char *str) { |
| 78 | if (!II) |
| 79 | II = &BR.getContext().Idents.get(str); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 80 | |
| 81 | return II; |
Ted Kremenek | efcbb15 | 2009-07-23 22:29:41 +0000 | [diff] [blame] | 82 | } |
| 83 | |
| 84 | //===----------------------------------------------------------------------===// |
Ted Kremenek | dbfb5f8 | 2009-07-23 01:07:19 +0000 | [diff] [blame] | 85 | // AST walking. |
| 86 | //===----------------------------------------------------------------------===// |
| 87 | |
| 88 | void WalkAST::VisitChildren(Stmt *S) { |
| 89 | for (Stmt::child_iterator I = S->child_begin(), E = S->child_end(); I!=E; ++I) |
| 90 | if (Stmt *child = *I) |
| 91 | Visit(child); |
| 92 | } |
| 93 | |
Ted Kremenek | efcbb15 | 2009-07-23 22:29:41 +0000 | [diff] [blame] | 94 | void WalkAST::VisitCallExpr(CallExpr *CE) { |
Lenny Maiorani | c2dace1 | 2011-04-03 05:07:11 +0000 | [diff] [blame^] | 95 | // Get the callee. |
| 96 | const FunctionDecl *FD = CE->getDirectCallee(); |
| 97 | |
| 98 | if (!FD) |
| 99 | return; |
| 100 | |
| 101 | // Get the name of the callee. If it's a builtin, strip off the prefix. |
| 102 | IdentifierInfo *II = FD->getIdentifier(); |
| 103 | if (!II) // if no identifier, not a simple C function |
| 104 | return; |
| 105 | llvm::StringRef Name = II->getName(); |
| 106 | if (Name.startswith("__builtin_")) |
| 107 | Name = Name.substr(10); |
| 108 | |
| 109 | // Set the evaluation function by switching on the callee name. |
| 110 | FnCheck evalFunction = llvm::StringSwitch<FnCheck>(Name) |
| 111 | .Case("gets", &WalkAST::CheckCall_gets) |
| 112 | .Case("getpw", &WalkAST::CheckCall_getpw) |
| 113 | .Case("mktemp", &WalkAST::CheckCall_mktemp) |
| 114 | .Cases("strcpy", "__strcpy_chk", &WalkAST::CheckCall_strcpy) |
| 115 | .Case("drand48", &WalkAST::CheckCall_rand) |
| 116 | .Case("erand48", &WalkAST::CheckCall_rand) |
| 117 | .Case("jrand48", &WalkAST::CheckCall_rand) |
| 118 | .Case("lrand48", &WalkAST::CheckCall_rand) |
| 119 | .Case("mrand48", &WalkAST::CheckCall_rand) |
| 120 | .Case("nrand48", &WalkAST::CheckCall_rand) |
| 121 | .Case("lcong48", &WalkAST::CheckCall_rand) |
| 122 | .Case("rand", &WalkAST::CheckCall_rand) |
| 123 | .Case("rand_r", &WalkAST::CheckCall_rand) |
| 124 | .Case("random", &WalkAST::CheckCall_random) |
| 125 | .Default(NULL); |
| 126 | |
| 127 | // If the callee isn't defined, it is not of security concern. |
| 128 | // Check and evaluate the call. |
| 129 | if (evalFunction) |
| 130 | (this->*evalFunction)(CE, FD); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 131 | |
Ted Kremenek | efcbb15 | 2009-07-23 22:29:41 +0000 | [diff] [blame] | 132 | // Recurse and check children. |
| 133 | VisitChildren(CE); |
| 134 | } |
| 135 | |
Ted Kremenek | 65a81a9 | 2009-08-28 00:08:09 +0000 | [diff] [blame] | 136 | void WalkAST::VisitCompoundStmt(CompoundStmt *S) { |
| 137 | for (Stmt::child_iterator I = S->child_begin(), E = S->child_end(); I!=E; ++I) |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 138 | if (Stmt *child = *I) { |
| 139 | if (CallExpr *CE = dyn_cast<CallExpr>(child)) |
| 140 | CheckUncheckedReturnValue(CE); |
| 141 | Visit(child); |
| 142 | } |
Ted Kremenek | 65a81a9 | 2009-08-28 00:08:09 +0000 | [diff] [blame] | 143 | } |
| 144 | |
Ted Kremenek | 8baf86d | 2009-07-23 21:34:35 +0000 | [diff] [blame] | 145 | void WalkAST::VisitForStmt(ForStmt *FS) { |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 146 | CheckLoopConditionForFloat(FS); |
Ted Kremenek | dbfb5f8 | 2009-07-23 01:07:19 +0000 | [diff] [blame] | 147 | |
Ted Kremenek | 8baf86d | 2009-07-23 21:34:35 +0000 | [diff] [blame] | 148 | // Recurse and check children. |
| 149 | VisitChildren(FS); |
Ted Kremenek | dbfb5f8 | 2009-07-23 01:07:19 +0000 | [diff] [blame] | 150 | } |
| 151 | |
| 152 | //===----------------------------------------------------------------------===// |
Ted Kremenek | 8baf86d | 2009-07-23 21:34:35 +0000 | [diff] [blame] | 153 | // Check: floating poing variable used as loop counter. |
Ted Kremenek | 5abeb52 | 2009-07-23 21:44:18 +0000 | [diff] [blame] | 154 | // Originally: <rdar://problem/6336718> |
| 155 | // Implements: CERT security coding advisory FLP-30. |
Ted Kremenek | dbfb5f8 | 2009-07-23 01:07:19 +0000 | [diff] [blame] | 156 | //===----------------------------------------------------------------------===// |
| 157 | |
Ted Kremenek | 8baf86d | 2009-07-23 21:34:35 +0000 | [diff] [blame] | 158 | static const DeclRefExpr* |
| 159 | GetIncrementedVar(const Expr *expr, const VarDecl *x, const VarDecl *y) { |
| 160 | expr = expr->IgnoreParenCasts(); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 161 | |
| 162 | if (const BinaryOperator *B = dyn_cast<BinaryOperator>(expr)) { |
Ted Kremenek | 8baf86d | 2009-07-23 21:34:35 +0000 | [diff] [blame] | 163 | if (!(B->isAssignmentOp() || B->isCompoundAssignmentOp() || |
John McCall | 2de56d1 | 2010-08-25 11:45:40 +0000 | [diff] [blame] | 164 | B->getOpcode() == BO_Comma)) |
Ted Kremenek | 8baf86d | 2009-07-23 21:34:35 +0000 | [diff] [blame] | 165 | return NULL; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 166 | |
Ted Kremenek | 8baf86d | 2009-07-23 21:34:35 +0000 | [diff] [blame] | 167 | if (const DeclRefExpr *lhs = GetIncrementedVar(B->getLHS(), x, y)) |
| 168 | return lhs; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 169 | |
Ted Kremenek | 8baf86d | 2009-07-23 21:34:35 +0000 | [diff] [blame] | 170 | if (const DeclRefExpr *rhs = GetIncrementedVar(B->getRHS(), x, y)) |
| 171 | return rhs; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 172 | |
Ted Kremenek | 8baf86d | 2009-07-23 21:34:35 +0000 | [diff] [blame] | 173 | return NULL; |
Ted Kremenek | dbfb5f8 | 2009-07-23 01:07:19 +0000 | [diff] [blame] | 174 | } |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 175 | |
Ted Kremenek | 8baf86d | 2009-07-23 21:34:35 +0000 | [diff] [blame] | 176 | if (const DeclRefExpr *DR = dyn_cast<DeclRefExpr>(expr)) { |
| 177 | const NamedDecl *ND = DR->getDecl(); |
| 178 | return ND == x || ND == y ? DR : NULL; |
| 179 | } |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 180 | |
Ted Kremenek | 8baf86d | 2009-07-23 21:34:35 +0000 | [diff] [blame] | 181 | if (const UnaryOperator *U = dyn_cast<UnaryOperator>(expr)) |
| 182 | return U->isIncrementDecrementOp() |
| 183 | ? GetIncrementedVar(U->getSubExpr(), x, y) : NULL; |
| 184 | |
Ted Kremenek | dbfb5f8 | 2009-07-23 01:07:19 +0000 | [diff] [blame] | 185 | return NULL; |
| 186 | } |
| 187 | |
Ted Kremenek | 8baf86d | 2009-07-23 21:34:35 +0000 | [diff] [blame] | 188 | /// CheckLoopConditionForFloat - This check looks for 'for' statements that |
| 189 | /// use a floating point variable as a loop counter. |
| 190 | /// CERT: FLP30-C, FLP30-CPP. |
| 191 | /// |
| 192 | void WalkAST::CheckLoopConditionForFloat(const ForStmt *FS) { |
| 193 | // Does the loop have a condition? |
| 194 | const Expr *condition = FS->getCond(); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 195 | |
Ted Kremenek | 8baf86d | 2009-07-23 21:34:35 +0000 | [diff] [blame] | 196 | if (!condition) |
| 197 | return; |
| 198 | |
| 199 | // Does the loop have an increment? |
| 200 | const Expr *increment = FS->getInc(); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 201 | |
Ted Kremenek | 8baf86d | 2009-07-23 21:34:35 +0000 | [diff] [blame] | 202 | if (!increment) |
| 203 | return; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 204 | |
Ted Kremenek | 8baf86d | 2009-07-23 21:34:35 +0000 | [diff] [blame] | 205 | // Strip away '()' and casts. |
| 206 | condition = condition->IgnoreParenCasts(); |
| 207 | increment = increment->IgnoreParenCasts(); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 208 | |
Ted Kremenek | 8baf86d | 2009-07-23 21:34:35 +0000 | [diff] [blame] | 209 | // Is the loop condition a comparison? |
| 210 | const BinaryOperator *B = dyn_cast<BinaryOperator>(condition); |
| 211 | |
| 212 | if (!B) |
| 213 | return; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 214 | |
Ted Kremenek | cad9f41 | 2009-07-24 20:26:31 +0000 | [diff] [blame] | 215 | // Is this a comparison? |
| 216 | if (!(B->isRelationalOp() || B->isEqualityOp())) |
Ted Kremenek | 8baf86d | 2009-07-23 21:34:35 +0000 | [diff] [blame] | 217 | return; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 218 | |
Ted Kremenek | 8baf86d | 2009-07-23 21:34:35 +0000 | [diff] [blame] | 219 | // Are we comparing variables? |
John McCall | f6a1648 | 2010-12-04 03:47:34 +0000 | [diff] [blame] | 220 | const DeclRefExpr *drLHS = |
| 221 | dyn_cast<DeclRefExpr>(B->getLHS()->IgnoreParenLValueCasts()); |
| 222 | const DeclRefExpr *drRHS = |
| 223 | dyn_cast<DeclRefExpr>(B->getRHS()->IgnoreParenLValueCasts()); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 224 | |
Ted Kremenek | cad9f41 | 2009-07-24 20:26:31 +0000 | [diff] [blame] | 225 | // Does at least one of the variables have a floating point type? |
Douglas Gregor | 0c293ea | 2010-06-22 23:07:26 +0000 | [diff] [blame] | 226 | drLHS = drLHS && drLHS->getType()->isRealFloatingType() ? drLHS : NULL; |
| 227 | drRHS = drRHS && drRHS->getType()->isRealFloatingType() ? drRHS : NULL; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 228 | |
Ted Kremenek | 8baf86d | 2009-07-23 21:34:35 +0000 | [diff] [blame] | 229 | if (!drLHS && !drRHS) |
| 230 | return; |
| 231 | |
| 232 | const VarDecl *vdLHS = drLHS ? dyn_cast<VarDecl>(drLHS->getDecl()) : NULL; |
| 233 | const VarDecl *vdRHS = drRHS ? dyn_cast<VarDecl>(drRHS->getDecl()) : NULL; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 234 | |
Ted Kremenek | 8baf86d | 2009-07-23 21:34:35 +0000 | [diff] [blame] | 235 | if (!vdLHS && !vdRHS) |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 236 | return; |
| 237 | |
Ted Kremenek | 8baf86d | 2009-07-23 21:34:35 +0000 | [diff] [blame] | 238 | // Does either variable appear in increment? |
| 239 | const DeclRefExpr *drInc = GetIncrementedVar(increment, vdLHS, vdRHS); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 240 | |
Ted Kremenek | 8baf86d | 2009-07-23 21:34:35 +0000 | [diff] [blame] | 241 | if (!drInc) |
| 242 | return; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 243 | |
Ted Kremenek | 8baf86d | 2009-07-23 21:34:35 +0000 | [diff] [blame] | 244 | // Emit the error. First figure out which DeclRefExpr in the condition |
| 245 | // referenced the compared variable. |
| 246 | const DeclRefExpr *drCond = vdLHS == drInc->getDecl() ? drLHS : drRHS; |
| 247 | |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 248 | llvm::SmallVector<SourceRange, 2> ranges; |
Ted Kremenek | 2c01676 | 2010-03-24 22:39:47 +0000 | [diff] [blame] | 249 | llvm::SmallString<256> sbuf; |
| 250 | llvm::raw_svector_ostream os(sbuf); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 251 | |
Daniel Dunbar | 4087f27 | 2010-08-17 22:39:59 +0000 | [diff] [blame] | 252 | os << "Variable '" << drCond->getDecl()->getName() |
Ted Kremenek | 8baf86d | 2009-07-23 21:34:35 +0000 | [diff] [blame] | 253 | << "' with floating point type '" << drCond->getType().getAsString() |
| 254 | << "' should not be used as a loop counter"; |
| 255 | |
| 256 | ranges.push_back(drCond->getSourceRange()); |
| 257 | ranges.push_back(drInc->getSourceRange()); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 258 | |
Ted Kremenek | 8baf86d | 2009-07-23 21:34:35 +0000 | [diff] [blame] | 259 | const char *bugType = "Floating point variable used as loop counter"; |
Benjamin Kramer | f017173 | 2009-11-29 18:27:55 +0000 | [diff] [blame] | 260 | BR.EmitBasicReport(bugType, "Security", os.str(), |
Ted Kremenek | 8baf86d | 2009-07-23 21:34:35 +0000 | [diff] [blame] | 261 | FS->getLocStart(), ranges.data(), ranges.size()); |
Ted Kremenek | dbfb5f8 | 2009-07-23 01:07:19 +0000 | [diff] [blame] | 262 | } |
| 263 | |
| 264 | //===----------------------------------------------------------------------===// |
Ted Kremenek | efcbb15 | 2009-07-23 22:29:41 +0000 | [diff] [blame] | 265 | // Check: Any use of 'gets' is insecure. |
| 266 | // Originally: <rdar://problem/6335715> |
| 267 | // Implements (part of): 300-BSI (buildsecurityin.us-cert.gov) |
Zhongxing Xu | aa30b3b | 2009-11-09 08:13:04 +0000 | [diff] [blame] | 268 | // CWE-242: Use of Inherently Dangerous Function |
Ted Kremenek | efcbb15 | 2009-07-23 22:29:41 +0000 | [diff] [blame] | 269 | //===----------------------------------------------------------------------===// |
| 270 | |
| 271 | void WalkAST::CheckCall_gets(const CallExpr *CE, const FunctionDecl *FD) { |
Abramo Bagnara | 723df24 | 2010-12-14 22:11:44 +0000 | [diff] [blame] | 272 | const FunctionProtoType *FPT |
| 273 | = dyn_cast<FunctionProtoType>(FD->getType().IgnoreParens()); |
Zhongxing Xu | bd842e3 | 2009-11-09 12:19:26 +0000 | [diff] [blame] | 274 | if (!FPT) |
Ted Kremenek | efcbb15 | 2009-07-23 22:29:41 +0000 | [diff] [blame] | 275 | return; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 276 | |
Ted Kremenek | efcbb15 | 2009-07-23 22:29:41 +0000 | [diff] [blame] | 277 | // Verify that the function takes a single argument. |
Zhongxing Xu | bd842e3 | 2009-11-09 12:19:26 +0000 | [diff] [blame] | 278 | if (FPT->getNumArgs() != 1) |
Ted Kremenek | efcbb15 | 2009-07-23 22:29:41 +0000 | [diff] [blame] | 279 | return; |
| 280 | |
| 281 | // Is the argument a 'char*'? |
Zhongxing Xu | bd842e3 | 2009-11-09 12:19:26 +0000 | [diff] [blame] | 282 | const PointerType *PT = dyn_cast<PointerType>(FPT->getArgType(0)); |
Ted Kremenek | efcbb15 | 2009-07-23 22:29:41 +0000 | [diff] [blame] | 283 | if (!PT) |
| 284 | return; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 285 | |
Ted Kremenek | efcbb15 | 2009-07-23 22:29:41 +0000 | [diff] [blame] | 286 | if (PT->getPointeeType().getUnqualifiedType() != BR.getContext().CharTy) |
| 287 | return; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 288 | |
Ted Kremenek | efcbb15 | 2009-07-23 22:29:41 +0000 | [diff] [blame] | 289 | // Issue a warning. |
| 290 | SourceRange R = CE->getCallee()->getSourceRange(); |
| 291 | BR.EmitBasicReport("Potential buffer overflow in call to 'gets'", |
| 292 | "Security", |
| 293 | "Call to function 'gets' is extremely insecure as it can " |
| 294 | "always result in a buffer overflow", |
| 295 | CE->getLocStart(), &R, 1); |
| 296 | } |
| 297 | |
| 298 | //===----------------------------------------------------------------------===// |
Zhongxing Xu | bd842e3 | 2009-11-09 12:19:26 +0000 | [diff] [blame] | 299 | // Check: Any use of 'getpwd' is insecure. |
| 300 | // CWE-477: Use of Obsolete Functions |
| 301 | //===----------------------------------------------------------------------===// |
| 302 | |
| 303 | void WalkAST::CheckCall_getpw(const CallExpr *CE, const FunctionDecl *FD) { |
Abramo Bagnara | 723df24 | 2010-12-14 22:11:44 +0000 | [diff] [blame] | 304 | const FunctionProtoType *FPT |
| 305 | = dyn_cast<FunctionProtoType>(FD->getType().IgnoreParens()); |
Zhongxing Xu | bd842e3 | 2009-11-09 12:19:26 +0000 | [diff] [blame] | 306 | if (!FPT) |
| 307 | return; |
| 308 | |
| 309 | // Verify that the function takes two arguments. |
| 310 | if (FPT->getNumArgs() != 2) |
| 311 | return; |
| 312 | |
| 313 | // Verify the first argument type is integer. |
| 314 | if (!FPT->getArgType(0)->isIntegerType()) |
| 315 | return; |
| 316 | |
| 317 | // Verify the second argument type is char*. |
| 318 | const PointerType *PT = dyn_cast<PointerType>(FPT->getArgType(1)); |
| 319 | if (!PT) |
| 320 | return; |
| 321 | |
| 322 | if (PT->getPointeeType().getUnqualifiedType() != BR.getContext().CharTy) |
| 323 | return; |
| 324 | |
| 325 | // Issue a warning. |
| 326 | SourceRange R = CE->getCallee()->getSourceRange(); |
| 327 | BR.EmitBasicReport("Potential buffer overflow in call to 'getpw'", |
| 328 | "Security", |
| 329 | "The getpw() function is dangerous as it may overflow the " |
| 330 | "provided buffer. It is obsoleted by getpwuid().", |
| 331 | CE->getLocStart(), &R, 1); |
| 332 | } |
| 333 | |
| 334 | //===----------------------------------------------------------------------===// |
Zhongxing Xu | 1bf4056 | 2009-12-03 09:15:23 +0000 | [diff] [blame] | 335 | // Check: Any use of 'mktemp' is insecure.It is obsoleted by mkstemp(). |
| 336 | // CWE-377: Insecure Temporary File |
| 337 | //===----------------------------------------------------------------------===// |
| 338 | |
| 339 | void WalkAST::CheckCall_mktemp(const CallExpr *CE, const FunctionDecl *FD) { |
Abramo Bagnara | 723df24 | 2010-12-14 22:11:44 +0000 | [diff] [blame] | 340 | const FunctionProtoType *FPT |
| 341 | = dyn_cast<FunctionProtoType>(FD->getType().IgnoreParens()); |
Zhongxing Xu | 1bf4056 | 2009-12-03 09:15:23 +0000 | [diff] [blame] | 342 | if(!FPT) |
| 343 | return; |
Ted Kremenek | 2c01676 | 2010-03-24 22:39:47 +0000 | [diff] [blame] | 344 | |
Lenny Maiorani | ea4411e | 2011-03-31 21:26:55 +0000 | [diff] [blame] | 345 | // Verify that the function takes a single argument. |
Zhongxing Xu | 1bf4056 | 2009-12-03 09:15:23 +0000 | [diff] [blame] | 346 | if (FPT->getNumArgs() != 1) |
| 347 | return; |
| 348 | |
| 349 | // Verify that the argument is Pointer Type. |
| 350 | const PointerType *PT = dyn_cast<PointerType>(FPT->getArgType(0)); |
| 351 | if (!PT) |
| 352 | return; |
| 353 | |
| 354 | // Verify that the argument is a 'char*'. |
| 355 | if (PT->getPointeeType().getUnqualifiedType() != BR.getContext().CharTy) |
| 356 | return; |
Ted Kremenek | 431a2cb | 2010-03-24 22:39:45 +0000 | [diff] [blame] | 357 | |
Zhongxing Xu | 1bf4056 | 2009-12-03 09:15:23 +0000 | [diff] [blame] | 358 | // Issue a waring. |
| 359 | SourceRange R = CE->getCallee()->getSourceRange(); |
| 360 | BR.EmitBasicReport("Potential insecure temporary file in call 'mktemp'", |
Eli Friedman | a7e6845 | 2010-08-22 01:00:03 +0000 | [diff] [blame] | 361 | "Security", |
| 362 | "Call to function 'mktemp' is insecure as it always " |
| 363 | "creates or uses insecure temporary file. Use 'mkstemp' instead", |
| 364 | CE->getLocStart(), &R, 1); |
Zhongxing Xu | 1bf4056 | 2009-12-03 09:15:23 +0000 | [diff] [blame] | 365 | } |
| 366 | |
Zhongxing Xu | 1bf4056 | 2009-12-03 09:15:23 +0000 | [diff] [blame] | 367 | //===----------------------------------------------------------------------===// |
Lenny Maiorani | 5b67a82 | 2011-03-31 22:09:14 +0000 | [diff] [blame] | 368 | // Check: Any use of 'strcpy' is insecure. |
| 369 | // |
| 370 | // CWE-119: Improper Restriction of Operations within |
| 371 | // the Bounds of a Memory Buffer |
| 372 | //===----------------------------------------------------------------------===// |
| 373 | void WalkAST::CheckCall_strcpy(const CallExpr *CE, const FunctionDecl *FD) { |
Lenny Maiorani | 5b67a82 | 2011-03-31 22:09:14 +0000 | [diff] [blame] | 374 | const FunctionProtoType *FPT |
| 375 | = dyn_cast<FunctionProtoType>(FD->getType().IgnoreParens()); |
| 376 | if (!FPT) |
| 377 | return; |
| 378 | |
| 379 | // Verify the function takes two arguments |
| 380 | int numArgs = FPT->getNumArgs(); |
| 381 | if (numArgs != 2 && numArgs != 3) |
| 382 | return; |
| 383 | |
| 384 | // Verify the type for both arguments |
| 385 | for (int i = 0; i < 2; i++) { |
| 386 | // Verify that the arguments are pointers |
| 387 | const PointerType *PT = dyn_cast<PointerType>(FPT->getArgType(i)); |
| 388 | if (!PT) |
| 389 | return; |
| 390 | |
| 391 | // Verify that the argument is a 'char*'. |
| 392 | if (PT->getPointeeType().getUnqualifiedType() != BR.getContext().CharTy) |
| 393 | return; |
| 394 | } |
| 395 | |
| 396 | // Issue a warning |
| 397 | SourceRange R = CE->getCallee()->getSourceRange(); |
| 398 | BR.EmitBasicReport("Potential insecure memory buffer bounds restriction in " |
| 399 | "call 'strcpy'", |
| 400 | "Security", |
| 401 | "Call to function 'strcpy' is insecure as it does not " |
| 402 | "provide bounding of the memory buffer. Replace " |
| 403 | "unbounded copy functions with analogous functions that " |
| 404 | "support length arguments such as 'strncpy'. CWE-119.", |
| 405 | CE->getLocStart(), &R, 1); |
| 406 | } |
| 407 | |
| 408 | //===----------------------------------------------------------------------===// |
Ted Kremenek | 2465047 | 2009-09-02 02:47:41 +0000 | [diff] [blame] | 409 | // Check: Linear congruent random number generators should not be used |
| 410 | // Originally: <rdar://problem/63371000> |
| 411 | // CWE-338: Use of cryptographically weak prng |
| 412 | //===----------------------------------------------------------------------===// |
| 413 | |
| 414 | void WalkAST::CheckCall_rand(const CallExpr *CE, const FunctionDecl *FD) { |
Lenny Maiorani | c2dace1 | 2011-04-03 05:07:11 +0000 | [diff] [blame^] | 415 | if (!CheckRand) |
Ted Kremenek | 2465047 | 2009-09-02 02:47:41 +0000 | [diff] [blame] | 416 | return; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 417 | |
Abramo Bagnara | 723df24 | 2010-12-14 22:11:44 +0000 | [diff] [blame] | 418 | const FunctionProtoType *FTP |
| 419 | = dyn_cast<FunctionProtoType>(FD->getType().IgnoreParens()); |
Ted Kremenek | 2465047 | 2009-09-02 02:47:41 +0000 | [diff] [blame] | 420 | if (!FTP) |
| 421 | return; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 422 | |
Ted Kremenek | 2465047 | 2009-09-02 02:47:41 +0000 | [diff] [blame] | 423 | if (FTP->getNumArgs() == 1) { |
| 424 | // Is the argument an 'unsigned short *'? |
| 425 | // (Actually any integer type is allowed.) |
| 426 | const PointerType *PT = dyn_cast<PointerType>(FTP->getArgType(0)); |
| 427 | if (!PT) |
| 428 | return; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 429 | |
Ted Kremenek | 2465047 | 2009-09-02 02:47:41 +0000 | [diff] [blame] | 430 | if (! PT->getPointeeType()->isIntegerType()) |
| 431 | return; |
| 432 | } |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 433 | else if (FTP->getNumArgs() != 0) |
Ted Kremenek | 2465047 | 2009-09-02 02:47:41 +0000 | [diff] [blame] | 434 | return; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 435 | |
Ted Kremenek | 2465047 | 2009-09-02 02:47:41 +0000 | [diff] [blame] | 436 | // Issue a warning. |
Ted Kremenek | 2c01676 | 2010-03-24 22:39:47 +0000 | [diff] [blame] | 437 | llvm::SmallString<256> buf1; |
| 438 | llvm::raw_svector_ostream os1(buf1); |
Benjamin Kramer | 900fc63 | 2010-04-17 09:33:03 +0000 | [diff] [blame] | 439 | os1 << '\'' << FD << "' is a poor random number generator"; |
Ted Kremenek | 2465047 | 2009-09-02 02:47:41 +0000 | [diff] [blame] | 440 | |
Ted Kremenek | 2c01676 | 2010-03-24 22:39:47 +0000 | [diff] [blame] | 441 | llvm::SmallString<256> buf2; |
| 442 | llvm::raw_svector_ostream os2(buf2); |
Benjamin Kramer | 900fc63 | 2010-04-17 09:33:03 +0000 | [diff] [blame] | 443 | os2 << "Function '" << FD |
Ted Kremenek | 2465047 | 2009-09-02 02:47:41 +0000 | [diff] [blame] | 444 | << "' is obsolete because it implements a poor random number generator." |
| 445 | << " Use 'arc4random' instead"; |
| 446 | |
| 447 | SourceRange R = CE->getCallee()->getSourceRange(); |
Ted Kremenek | 2c01676 | 2010-03-24 22:39:47 +0000 | [diff] [blame] | 448 | BR.EmitBasicReport(os1.str(), "Security", os2.str(),CE->getLocStart(), &R, 1); |
Ted Kremenek | 2465047 | 2009-09-02 02:47:41 +0000 | [diff] [blame] | 449 | } |
| 450 | |
| 451 | //===----------------------------------------------------------------------===// |
| 452 | // Check: 'random' should not be used |
| 453 | // Originally: <rdar://problem/63371000> |
| 454 | //===----------------------------------------------------------------------===// |
| 455 | |
| 456 | void WalkAST::CheckCall_random(const CallExpr *CE, const FunctionDecl *FD) { |
Lenny Maiorani | c2dace1 | 2011-04-03 05:07:11 +0000 | [diff] [blame^] | 457 | if (!CheckRand) |
Ted Kremenek | 2465047 | 2009-09-02 02:47:41 +0000 | [diff] [blame] | 458 | return; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 459 | |
Abramo Bagnara | 723df24 | 2010-12-14 22:11:44 +0000 | [diff] [blame] | 460 | const FunctionProtoType *FTP |
| 461 | = dyn_cast<FunctionProtoType>(FD->getType().IgnoreParens()); |
Ted Kremenek | 2465047 | 2009-09-02 02:47:41 +0000 | [diff] [blame] | 462 | if (!FTP) |
| 463 | return; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 464 | |
Ted Kremenek | 2465047 | 2009-09-02 02:47:41 +0000 | [diff] [blame] | 465 | // Verify that the function takes no argument. |
| 466 | if (FTP->getNumArgs() != 0) |
| 467 | return; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 468 | |
Ted Kremenek | 2465047 | 2009-09-02 02:47:41 +0000 | [diff] [blame] | 469 | // Issue a warning. |
| 470 | SourceRange R = CE->getCallee()->getSourceRange(); |
| 471 | BR.EmitBasicReport("'random' is not a secure random number generator", |
| 472 | "Security", |
| 473 | "The 'random' function produces a sequence of values that " |
| 474 | "an adversary may be able to predict. Use 'arc4random' " |
Ted Kremenek | 2c01676 | 2010-03-24 22:39:47 +0000 | [diff] [blame] | 475 | "instead", CE->getLocStart(), &R, 1); |
Ted Kremenek | 2465047 | 2009-09-02 02:47:41 +0000 | [diff] [blame] | 476 | } |
| 477 | |
| 478 | //===----------------------------------------------------------------------===// |
Ted Kremenek | 65a81a9 | 2009-08-28 00:08:09 +0000 | [diff] [blame] | 479 | // Check: Should check whether privileges are dropped successfully. |
| 480 | // Originally: <rdar://problem/6337132> |
| 481 | //===----------------------------------------------------------------------===// |
| 482 | |
| 483 | void WalkAST::CheckUncheckedReturnValue(CallExpr *CE) { |
| 484 | const FunctionDecl *FD = CE->getDirectCallee(); |
| 485 | if (!FD) |
| 486 | return; |
| 487 | |
| 488 | if (II_setid[0] == NULL) { |
Ted Kremenek | 2465047 | 2009-09-02 02:47:41 +0000 | [diff] [blame] | 489 | static const char * const identifiers[num_setids] = { |
Ted Kremenek | 65a81a9 | 2009-08-28 00:08:09 +0000 | [diff] [blame] | 490 | "setuid", "setgid", "seteuid", "setegid", |
| 491 | "setreuid", "setregid" |
| 492 | }; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 493 | |
Ted Kremenek | 2465047 | 2009-09-02 02:47:41 +0000 | [diff] [blame] | 494 | for (size_t i = 0; i < num_setids; i++) |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 495 | II_setid[i] = &BR.getContext().Idents.get(identifiers[i]); |
Ted Kremenek | 65a81a9 | 2009-08-28 00:08:09 +0000 | [diff] [blame] | 496 | } |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 497 | |
Ted Kremenek | 65a81a9 | 2009-08-28 00:08:09 +0000 | [diff] [blame] | 498 | const IdentifierInfo *id = FD->getIdentifier(); |
| 499 | size_t identifierid; |
| 500 | |
Ted Kremenek | 2465047 | 2009-09-02 02:47:41 +0000 | [diff] [blame] | 501 | for (identifierid = 0; identifierid < num_setids; identifierid++) |
Ted Kremenek | 65a81a9 | 2009-08-28 00:08:09 +0000 | [diff] [blame] | 502 | if (id == II_setid[identifierid]) |
| 503 | break; |
| 504 | |
Ted Kremenek | 2465047 | 2009-09-02 02:47:41 +0000 | [diff] [blame] | 505 | if (identifierid >= num_setids) |
Ted Kremenek | 65a81a9 | 2009-08-28 00:08:09 +0000 | [diff] [blame] | 506 | return; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 507 | |
Abramo Bagnara | 723df24 | 2010-12-14 22:11:44 +0000 | [diff] [blame] | 508 | const FunctionProtoType *FTP |
| 509 | = dyn_cast<FunctionProtoType>(FD->getType().IgnoreParens()); |
Ted Kremenek | 65a81a9 | 2009-08-28 00:08:09 +0000 | [diff] [blame] | 510 | if (!FTP) |
| 511 | return; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 512 | |
Ted Kremenek | a818783 | 2009-08-28 00:24:55 +0000 | [diff] [blame] | 513 | // Verify that the function takes one or two arguments (depending on |
| 514 | // the function). |
Ted Kremenek | 65a81a9 | 2009-08-28 00:08:09 +0000 | [diff] [blame] | 515 | if (FTP->getNumArgs() != (identifierid < 4 ? 1 : 2)) |
| 516 | return; |
| 517 | |
| 518 | // The arguments must be integers. |
| 519 | for (unsigned i = 0; i < FTP->getNumArgs(); i++) |
| 520 | if (! FTP->getArgType(i)->isIntegerType()) |
| 521 | return; |
| 522 | |
| 523 | // Issue a warning. |
Ted Kremenek | 2c01676 | 2010-03-24 22:39:47 +0000 | [diff] [blame] | 524 | llvm::SmallString<256> buf1; |
| 525 | llvm::raw_svector_ostream os1(buf1); |
Benjamin Kramer | 900fc63 | 2010-04-17 09:33:03 +0000 | [diff] [blame] | 526 | os1 << "Return value is not checked in call to '" << FD << '\''; |
Ted Kremenek | 65a81a9 | 2009-08-28 00:08:09 +0000 | [diff] [blame] | 527 | |
Ted Kremenek | 2c01676 | 2010-03-24 22:39:47 +0000 | [diff] [blame] | 528 | llvm::SmallString<256> buf2; |
| 529 | llvm::raw_svector_ostream os2(buf2); |
Benjamin Kramer | 900fc63 | 2010-04-17 09:33:03 +0000 | [diff] [blame] | 530 | os2 << "The return value from the call to '" << FD |
| 531 | << "' is not checked. If an error occurs in '" << FD |
Ted Kremenek | 65a81a9 | 2009-08-28 00:08:09 +0000 | [diff] [blame] | 532 | << "', the following code may execute with unexpected privileges"; |
| 533 | |
| 534 | SourceRange R = CE->getCallee()->getSourceRange(); |
Ted Kremenek | 2c01676 | 2010-03-24 22:39:47 +0000 | [diff] [blame] | 535 | BR.EmitBasicReport(os1.str(), "Security", os2.str(),CE->getLocStart(), &R, 1); |
Ted Kremenek | 65a81a9 | 2009-08-28 00:08:09 +0000 | [diff] [blame] | 536 | } |
| 537 | |
| 538 | //===----------------------------------------------------------------------===// |
Argyrios Kyrtzidis | 7dd445e | 2011-02-17 21:39:33 +0000 | [diff] [blame] | 539 | // SecuritySyntaxChecker |
Ted Kremenek | dbfb5f8 | 2009-07-23 01:07:19 +0000 | [diff] [blame] | 540 | //===----------------------------------------------------------------------===// |
| 541 | |
Argyrios Kyrtzidis | 7dd445e | 2011-02-17 21:39:33 +0000 | [diff] [blame] | 542 | namespace { |
Argyrios Kyrtzidis | ec8605f | 2011-03-01 01:16:21 +0000 | [diff] [blame] | 543 | class SecuritySyntaxChecker : public Checker<check::ASTCodeBody> { |
Argyrios Kyrtzidis | 7dd445e | 2011-02-17 21:39:33 +0000 | [diff] [blame] | 544 | public: |
| 545 | void checkASTCodeBody(const Decl *D, AnalysisManager& mgr, |
| 546 | BugReporter &BR) const { |
| 547 | WalkAST walker(BR); |
| 548 | walker.Visit(D->getBody()); |
| 549 | } |
| 550 | }; |
| 551 | } |
| 552 | |
| 553 | void ento::registerSecuritySyntaxChecker(CheckerManager &mgr) { |
| 554 | mgr.registerChecker<SecuritySyntaxChecker>(); |
Ted Kremenek | dbfb5f8 | 2009-07-23 01:07:19 +0000 | [diff] [blame] | 555 | } |