forked from CloudDefenseAI/AWSZeroTrustPolicy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
36 lines (31 loc) · 1.03 KB
/
app.py
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
import json
from fastapi import FastAPI, HTTPException, Depends, Request
from fastapi.middleware.cors import CORSMiddleware
from schemas import Script
from runner import runner
from datetime import datetime
app = FastAPI()
@app.post("/run")
def run_script(script: Script):
print(f"Timestamp: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}")
print("Payload:")
print(json.dumps(script.dict(), indent=4))
try:
resp = runner(
script.accountType,
script.accessKey,
script.secretKey,
script.accountId,
script.days,
script.bucketData,
script.roleArn,
script.externalId,
)
except Exception as e:
raise HTTPException(status_code=500, detail=str(e))
return {
"accountId": resp["accountId"],
"generatedPolicies": resp["generatedPolicies"],
"consolidatedPolicies": resp["consolidatedPolicies"],
"excessivePolicies": resp["excessivePolicies"],
}