MCPcopy Create free account
hub / github.com/ParzivalHack/PySpector / run

Function run

tests/unit/test_a_sink_rules.py:13–28  ·  view source on GitHub ↗
(code, filename="app.py")

Source from the content-addressed store, hash-verified

11
12
13def run(code, filename="app.py"):
14 from pyspector._rust_core import run_scan
15 from pyspector.config import get_default_rules
16 import ast as _ast, json as _json
17 from pyspector.cli import AstEncoder
18 wrapped = _wrap(code)
19 rules = get_default_rules()
20 with tempfile.TemporaryDirectory() as d:
21 p = os.path.join(d, filename)
22 Path(p).write_text(wrapped)
23 with warnings.catch_warnings():
24 warnings.filterwarnings("ignore")
25 try: aj = _json.dumps(_ast.parse(wrapped), cls=AstEncoder)
26 except: aj = "{}"
27 files = [{"file_path": filename, "content": wrapped, "ast_json": aj}]
28 return [{"rule_id": r.rule_id} for r in run_scan(d, rules, {"exclude": []}, files)]
29
30
31def fires(code, rule_id): return [f for f in run(code) if f["rule_id"] == rule_id]

Callers 1

firesFunction · 0.70

Calls 2

get_default_rulesFunction · 0.90
_wrapFunction · 0.70

Tested by

no test coverage detected