@@ -36,7 +36,7 @@ def alert_rule_examples(j1):
36
36
severity = "HIGH" ,
37
37
j1ql = "FIND Database WITH encrypted = false"
38
38
)
39
- print (f"Created basic alert rule: { basic_rule ['rule' ][ '_id ' ]} \n " )
39
+ print (f"Created basic alert rule: { basic_rule ['id ' ]} \n " )
40
40
41
41
# 2. Complex alert rule with multiple conditions
42
42
print ("2. Creating a complex alert rule:" )
@@ -55,7 +55,7 @@ def alert_rule_examples(j1):
55
55
AND u.tag.Role != 'admin'
56
56
"""
57
57
)
58
- print (f"Created complex alert rule: { complex_rule ['rule' ][ '_id ' ]} \n " )
58
+ print (f"Created complex alert rule: { complex_rule ['id ' ]} \n " )
59
59
60
60
return basic_rule , complex_rule
61
61
@@ -135,7 +135,7 @@ def alert_rule_with_actions_examples(j1):
135
135
j1ql = "FIND Finding WITH severity = 'HIGH'" ,
136
136
action_configs = webhook_action_config
137
137
)
138
- print (f"Created webhook alert rule: { webhook_rule ['rule' ][ '_id ' ]} \n " )
138
+ print (f"Created webhook alert rule: { webhook_rule ['id ' ]} \n " )
139
139
140
140
# Create alert rule with multiple actions
141
141
print ("2. Creating alert rule with multiple actions:" )
@@ -149,7 +149,7 @@ def alert_rule_with_actions_examples(j1):
149
149
j1ql = "FIND Finding WITH severity = ('HIGH' OR 'CRITICAL')" ,
150
150
action_configs = multiple_actions
151
151
)
152
- print (f"Created multi-action alert rule: { multi_action_rule ['rule' ][ '_id ' ]} \n " )
152
+ print (f"Created multi-action alert rule: { multi_action_rule ['id ' ]} \n " )
153
153
154
154
return webhook_rule , multi_action_rule
155
155
@@ -162,16 +162,16 @@ def alert_rule_management_examples(j1, rule_id):
162
162
print ("1. Getting alert rule details:" )
163
163
try :
164
164
rule_details = j1 .get_alert_rule_details (rule_id = rule_id )
165
- print (f"Rule: { rule_details ['rule' ][ ' name' ]} " )
166
- print (f"Description: { rule_details ['rule' ][ ' description' ]} " )
167
- print (f"J1QL: { rule_details [ 'rule' ][ 'j1ql' ] } " )
168
- print (f"Severity: { rule_details [ 'rule' ][ 'severity' ] } " )
169
- print (f"Polling Interval: { rule_details [ 'rule' ][ 'pollingInterval' ] } " )
165
+ print (f"Rule: { rule_details ['name' ]} " )
166
+ print (f"Description: { rule_details ['description' ]} " )
167
+ print (f"J1QL: { rule_details . get ( 'j1ql' , 'N/A' ) } " )
168
+ print (f"Severity: { rule_details . get ( 'severity' , 'N/A' ) } " )
169
+ print (f"Polling Interval: { rule_details . get ( 'pollingInterval' , 'N/A' ) } " )
170
170
171
171
# Check action configurations
172
- if 'actionConfigs' in rule_details [ 'rule' ] :
172
+ if 'actionConfigs' in rule_details :
173
173
print ("Action Configurations:" )
174
- for action in rule_details ['rule' ][ ' actionConfigs' ]:
174
+ for action in rule_details ['actionConfigs' ]:
175
175
print (f" Type: { action ['type' ]} " )
176
176
if action ['type' ] == 'WEBHOOK' :
177
177
print (f" Endpoint: { action ['endpoint' ]} " )
@@ -208,7 +208,7 @@ def alert_rule_management_examples(j1, rule_id):
208
208
tag_op = "OVERWRITE" ,
209
209
severity = "INFO"
210
210
)
211
- print (f"Updated alert rule: { updated_rule ['rule' ][ '_id ' ]} " )
211
+ print (f"Updated alert rule: { updated_rule ['id ' ]} " )
212
212
except Exception as e :
213
213
print (f"Error updating alert rule: { e } " )
214
214
print ()
@@ -240,7 +240,7 @@ def smartclass_examples(j1):
240
240
smartclass_name = 'ProductionServers' ,
241
241
smartclass_description = 'All production servers across cloud providers'
242
242
)
243
- smartclass_id = smartclass ['smartclass' ][ '_id ' ]
243
+ smartclass_id = smartclass ['id ' ]
244
244
print (f"Created SmartClass: { smartclass_id } \n " )
245
245
246
246
# 2. Add queries to SmartClass
@@ -267,8 +267,8 @@ def smartclass_examples(j1):
267
267
print ("3. Getting SmartClass details:" )
268
268
try :
269
269
smartclass_details = j1 .get_smartclass_details (smartclass_id = smartclass_id )
270
- print (f"SmartClass: { smartclass_details ['smartclass' ][ 'name ' ]} " )
271
- print (f"Description: { smartclass_details ['smartclass' ][ ' description' ]} " )
270
+ print (f"SmartClass: { smartclass_details ['tagName ' ]} " )
271
+ print (f"Description: { smartclass_details ['description' ]} " )
272
272
print (f"Queries: { len (smartclass_details .get ('queries' , []))} " )
273
273
274
274
# List all queries in the SmartClass
@@ -410,7 +410,7 @@ def main():
410
410
webhook_rule , multi_action_rule = alert_rule_with_actions_examples (j1 )
411
411
412
412
# Alert rule management (using the basic rule)
413
- alert_rule_management_examples (j1 , basic_rule ['rule' ][ '_id ' ])
413
+ alert_rule_management_examples (j1 , basic_rule ['id ' ])
414
414
415
415
# SmartClass examples
416
416
smartclass_id = smartclass_examples (j1 )
@@ -419,7 +419,7 @@ def main():
419
419
natural_language_to_j1ql_examples (j1 )
420
420
421
421
# Alert rule evaluation examples
422
- alert_rule_evaluation_examples (j1 , basic_rule ['rule' ][ '_id ' ])
422
+ alert_rule_evaluation_examples (j1 , basic_rule ['id ' ])
423
423
424
424
# Compliance framework examples
425
425
compliance_framework_examples (j1 )
0 commit comments