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

Function run

tests/unit/test_semantic_provenance.py:10–24  ·  view source on GitHub ↗
(code, filename="app.py")

Source from the content-addressed store, hash-verified

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

Callers 1

firesFunction · 0.70

Calls 1

get_default_rulesFunction · 0.90

Tested by

no test coverage detected