lexicalspace commited on
Commit
8117458
·
verified ·
1 Parent(s): 89bab68

Update phases/phase3_static.py

Browse files
Files changed (1) hide show
  1. phases/phase3_static.py +14 -27
phases/phase3_static.py CHANGED
@@ -1,27 +1,14 @@
1
- import ast, os, json
2
-
3
- def static_scan(root="artifacts/code"):
4
- findings = []
5
-
6
- for dirpath, _, files in os.walk(root):
7
- for f in files:
8
- if f.endswith(".py"):
9
- path = os.path.join(dirpath, f)
10
- try:
11
- tree = ast.parse(open(path, "r", encoding="utf-8").read())
12
- for node in ast.walk(tree):
13
- if isinstance(node, ast.Assign):
14
- src = ast.unparse(node)
15
- if "socket_timeout" in src:
16
- findings.append({
17
- "file": path,
18
- "issue": "socket_timeout_detected",
19
- "line": node.lineno
20
- })
21
- except Exception as e:
22
- findings.append({"file": path, "error": str(e)})
23
-
24
- with open("artifacts/static_findings.json", "w") as f:
25
- json.dump(findings, f, indent=2)
26
-
27
- return findings
 
1
+ import json
2
+ from analyzers.rule_matcher import match_rule
3
+
4
+ def static_scan(rules):
5
+ all_findings = []
6
+
7
+ for rule in rules["rules"]:
8
+ result = match_rule(rule)
9
+ all_findings.extend(result)
10
+
11
+ with open("artifacts/rule_findings.json", "w") as f:
12
+ json.dump(all_findings, f, indent=2)
13
+
14
+ return all_findings