-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathai_engine.py
More file actions
44 lines (37 loc) · 1.2 KB
/
Copy pathai_engine.py
File metadata and controls
44 lines (37 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
from typing import Dict
from triage import Finding
def build_prompt(finding: Finding) -> str:
"""
Build a clear prompt string from one Finding.
"""
prompt = f"""
You are a security assistant.
Semgrep found a potential issue.
Rule ID: {finding.rule_id}
File: {finding.file_path}
Lines: {finding.start_line}-{finding.end_line}
Message: {finding.message}
Code:
----------------
{finding.code_snippet}
----------------
Tasks:
1. Decide if this issue is actually exploitable in this specific context.
2. If it is exploitable, propose a safer fixed version of the code.
3. Explain briefly (2-3 sentences) why your fix is safer.
Respond in JSON with the keys:
- "is_exploitable": true/false
- "fix": string with fixed code (or empty if not needed)
- "explanation": short text
"""
return prompt.strip()
def mock_ai_analyze(finding: Finding) -> Dict[str, str]:
"""
Fake AI analysis for now (no real LLM).
"""
prompt = build_prompt(finding)
return {
"is_exploitable": "unknown",
"fix": "# TODO: AI-generated fix will go here\n" + finding.code_snippet,
"explanation": "This is a mock analysis. In the real version, an LLM will read the prompt and return a real fix."
}