MCPcopy Create free account
hub / github.com/GPTScan/GPTScan / run_static_check

Function run_static_check

src/static_check.py:93–205  ·  view source on GitHub ↗
(checker:str, args, function_name:str, falcon:Falcon, text:str)

Source from the content-addressed store, hash-verified

91 return pattern.lower() in text.lower()
92
93def run_static_check(checker:str, args, function_name:str, falcon:Falcon, text:str) -> bool:
94 # if there is a vulnerability, return true
95 match checker:
96 case "find_data_dependency":
97 if args[0] is None or args[0] == '' or args[0] == 'N/A':
98 return False
99 if args[1] is None or args[1] == '' or args[1] == 'N/A': # TODO 'N/A' for the case of return value
100 return False
101 if args[1] == args[0]:
102 return True
103
104 console.print(rich_utils.make_args_table(args, "find_data_dependency"))
105
106 lines = text.splitlines()
107 for line in lines:
108 # if these two variable are in the same line, they have dependency
109 if args[0] in line and args[1] in line and '=' in line:
110 return True
111 # if first parameter is in the return statement
112 if args[0] in line and 'return ' in line:
113 return True
114
115 if falcon is None:
116 logger.warning("Falcon is not initialized, skipping data dependency check")
117 return False
118
119 return falcon_adapter.find_data_dependency(args[0], args[1], function_name, falcon)
120
121 case "first_deposit_check":
122 if falcon is None:
123 logger.warning("Falcon is not initialized, skipping first deposit check")
124 return False
125 varB = args[0]
126 varC = args[1]
127 varA = args[2]
128 logger.info(f"first_deposit_check: VariableA: {varA}; VariableB: {varB}; VariableC: {varC}")
129 # check Variable C
130 if varC == "" or varC == "N/A":
131 return False
132
133 console.print(rich_utils.make_args_table(args, "first_deposit_check"))
134
135 # check if (VariableB == 0) or in the else branch via __has_larger_check(varB, "0", text)) but need if
136 checkB = __has_eq_check(varB, "0", text)
137 # check VariableA = VariableC or mint(VariableC)
138 return checkB and falcon_adapter.first_deposit_check(varB, varC, varA, function_name, falcon)
139
140 case "has_check":
141 init_value = None
142 for arg in args:
143 if arg is None:
144 continue
145 new_value = __has_check(arg, text)
146 if new_value is None:
147 continue
148 if init_value == None:
149 init_value = not new_value
150 else:

Callers

nothing calls this directly

Calls 7

__has_eq_checkFunction · 0.85
__has_checkFunction · 0.85
__has_noneq_checkFunction · 0.85
__order_first_bFunction · 0.85
__call_arg_checkFunction · 0.85
__emit_at_endFunction · 0.85
__in_codeFunction · 0.85

Tested by

no test coverage detected