forked from 5toCode/terraform-examples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprismacloud.sentinel
More file actions
23 lines (21 loc) · 912 Bytes
/
Copy pathprismacloud.sentinel
File metadata and controls
23 lines (21 loc) · 912 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import "tfrun"
import "http"
import "json"
param PRISMA_ACCESS_KEY
param PRISMA_SECRET_KEY
loginReq = http.request("https://api4.prismacloud.io/login").with_body(json.marshal({"username": PRISMA_ACCESS_KEY, "password": PRISMA_SECRET_KEY})).with_header("Content-Type", "application/json")
loginResp = json.unmarshal(http.post(loginReq).body)
print(loginResp)
req = http.request("https://api4.prismacloud.io/bridgecrew/api/v1/tfCloud/sentinel/"+tfrun.workspace.id).with_header("Authorization", loginResp.token)
resp = json.unmarshal(http.get(req).body)
if (length(resp.violations) > 0) {
print("Violations:\n")
for resp.violations as violation {
print(violation.title)
print("Resource: " + violation.resource_id)
print("Violation ID: " + violation.violation_id)
print("\n")
}
}
print("More details: " + resp.details_url)
main = rule { length(resp.violations) < 1 }