ESBMC
Efficient SMT-based Context-Bounded Model Checker
Loading...
Searching...
No Matches
pattern_check.h
Go to the documentation of this file.
1
8
9#ifndef SOLIDITY_FRONTEND_PATTERN_CHECK_H_
10#define SOLIDITY_FRONTEND_PATTERN_CHECK_H_
11
12#include <memory>
13#include <iomanip>
14#include <util/symtab/context.h>
16#include <util/irep/std_types.h>
17#include <fmt/core.h>
18#include <nlohmann/json.hpp>
20
22{
23 // There are two types of vulnerabilities:
24 // - pattern-based vulnerability (e.g. Authorization via TxOrigin)
25 // - reasoning-based vulnerability (e.g. array out-of-bound access)
26 // This class implements the detection of pattern-based vulnerability.
27 // The reasoning-based vulnerability is handled by ESBMC verification
28 // pipeline.
29public:
31 const nlohmann::json &_ast_nodes,
32 const std::string &_target_func);
33 virtual ~pattern_checker() = default;
34
35 void do_pattern_check();
36 void start_pattern_based_check(const nlohmann::json &func);
37
38 // Authorization through Tx origin
39 void check_authorization_through_tx_origin(const nlohmann::json &func);
40 void check_require_call(const nlohmann::json &expr);
41 void check_require_argument(const nlohmann::json &call_args);
42 void check_tx_origin(const nlohmann::json &left_expr);
43
44protected:
45 const nlohmann::json &ast_nodes;
46 const std::string target_func; // function to be verified
47};
48
49#endif /* SOLIDITY_FRONTEND_PATTERN_CHECK_H_ */
void check_authorization_through_tx_origin(const nlohmann::json &func)
Definition pattern_check.cpp:62
pattern_checker(const nlohmann::json &_ast_nodes, const std::string &_target_func)
Definition pattern_check.cpp:12
void do_pattern_check()
Definition pattern_check.cpp:19
const std::string target_func
Definition pattern_check.h:46
void check_require_argument(const nlohmann::json &call_args)
Definition pattern_check.cpp:115
void start_pattern_based_check(const nlohmann::json &func)
Definition pattern_check.cpp:55
virtual ~pattern_checker()=default
void check_require_call(const nlohmann::json &expr)
Definition pattern_check.cpp:95
void check_tx_origin(const nlohmann::json &left_expr)
Definition pattern_check.cpp:140
const nlohmann::json & ast_nodes
Definition pattern_check.h:45
Solidity grammar enumerations and classification helpers.