-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathiac_tool.py
More file actions
32 lines (24 loc) · 965 Bytes
/
iac_tool.py
File metadata and controls
32 lines (24 loc) · 965 Bytes
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
"""
iac_tool.py — backward-compatible shim.
The real implementation now lives in scanner.engine.
This file keeps the original API intact so backend_server.py
and finops_fame_agent.py continue to work unchanged.
"""
import json
from scanner.engine import scan_content_legacy, scan_file
def scan_terraform_content(content: str, file_name: str = "infra.tf") -> str:
"""Scan Terraform content string. Returns structured JSON string."""
return scan_content_legacy(content, file_name)
def scan_terraform_code(file_path: str) -> str:
"""
Scan a Terraform file from disk.
Simulates an MCP Tool for the 'Actor' agent.
"""
try:
with open(file_path, "r", encoding="utf-8") as f:
content = f.read()
except FileNotFoundError:
return json.dumps({"error": f"File {file_path} not found."})
return scan_content_legacy(content, file_path)
if __name__ == "__main__":
print(scan_terraform_code("infra.tf"))