MCPcopy Create free account
hub / github.com/blocksecteam/rustle / findGlobalVar

Function findGlobalVar

utils/core.py:298–312  ·  view source on GitHub ↗
(filename)

Source from the content-addressed store, hash-verified

296
297
298def findGlobalVar(filename) -> dict:
299 results = dict()
300 with open(filename, "r") as file:
301 pattern = r"\n(pub\s+)?(const\s+)?(static\s+)?(mut\s+)?(?P<name1>\w+)\s*(:\s*(?P<type2>[^=]+))?\s*(=\s*(?P<value3>[^;]+))?;"
302 for var in re.findall(pattern, re.sub("//.+\n", "", file.read())): # remove comment
303 if var[0] == "" and var[1] == "" and var[2] == "" and var[3] == "":
304 continue
305 # print(var)
306 name = var[4]
307 results[name] = {
308 "value": var[-1].strip(),
309 "type": var[-3].strip(),
310 "visibility": "public" if "pub" in var[0] else "private",
311 }
312 return results
313
314
315def findStruct(filename, only_near_bindgen=False) -> list:

Callers 2

audit.pyFile · 0.85
inconsistency.pyFile · 0.85

Calls 1

subMethod · 0.80

Tested by

no test coverage detected