Skip to content

Commit 7d281ba

Browse files
Cv-securityIQCv-securityIQ
authored andcommitted
Bug fixes in disable data aging playbook
1 parent a428746 commit 7d281ba

File tree

6 files changed

+508
-601
lines changed

6 files changed

+508
-601
lines changed

.github/workflows/azure-sentinel-deploy-3deaee03-d682-43b3-aa17-4df53dc98264.ps1

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,12 @@ function Deployment($fullDeploymentFlag, $remoteShaTable, $tree) {
524524
ForEach-Object { $iterationList += $_.FullName }
525525
$iterationList | ForEach-Object {
526526
$path = $_
527+
if ($path -like "invalid*") {
528+
Write-Host "[Warning] Skipping deployment for $path as it starts with 'invalid'."
529+
continue
530+
}
527531
Write-Host "[Info] Try to deploy $path"
532+
528533
if (-not (Test-Path $path)) {
529534
Write-Host "[Warning] Skipping deployment for $path. The file doesn't exist."
530535
return

Solutions/Commvault Security IQ/Analytic Rules/CommvaultSecurityIQ_Alert.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,11 @@ triggerThreshold: 0
1515
tactics:
1616
- DefenseEvasion
1717
- Impact
18-
18+
customDetails:
19+
userId: user_id_d
20+
userName: username_s
21+
client: originating_client_s
22+
subclient: subclient_id_d
1923
relevantTechniques:
2024
- T1578
2125
- T1531

Solutions/Commvault Security IQ/Data Connectors/AzureFunctionCommvaultSecurityIQ/main.py

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
logAnalyticsUri = 'https://' + customer_id + '.ods.opinsights.azure.com'
2929

3030
key_vault_name = os.environ.get("KeyVaultName","Commvault-Integration-KV")
31-
uri = None
3231
url = None
3332
qsdk_token = None
3433
headers = {
@@ -110,13 +109,15 @@ def main(mytimer: func.TimerRequest) -> None:
110109
credential = DefaultAzureCredential()
111110
client = SecretClient(vault_url=f"https://{key_vault_name}.vault.azure.net", credential=credential)
112111
secret_name = "environment-endpoint-url"
113-
uri = client.get_secret(secret_name).value
114-
url = "https://" + uri + "/commandcenter/api"
112+
url = client.get_secret(secret_name).value
113+
logging.error(f"URL : {url}")
115114
secret_name = "access-token"
116115
qsdk_token = client.get_secret(secret_name).value
117116
headers["authtoken"] = "QSDK " + qsdk_token
118117

119118
companyId_url = f"{url}/v2/WhoAmI"
119+
120+
logging.error(f"Trying to fetch company details {companyId_url}")
120121
company_response = requests.get(companyId_url, headers=headers)
121122
if company_response.status_code == 200:
122123
company_data_json = company_response.json()
@@ -169,18 +170,20 @@ def main(mytimer: func.TimerRequest) -> None:
169170
post_data = []
170171
if data:
171172
for event in data:
172-
temp = get_incident_details(event["description"])
173-
if temp:
174-
post_data.append(temp)
173+
try :
174+
temp = get_incident_details(event["description"])
175+
if temp:
176+
post_data.append(temp)
177+
except Exception as e:
178+
logging.error("Error while processing event : "+str(e))
175179
logging.info("Trying Post Data")
176180
gen_chunks(post_data)
177181
logging.info("Job Succeeded")
178182
print("***Job Succeeded*****")
179-
upload_timestamp_blob(cs, container_name, blob_name, to_time+1)
180183
logging.info("Function App Executed")
181184
else:
182185
print("No new events found.")
183-
186+
upload_timestamp_blob(cs, container_name, blob_name, to_time+1)
184187
else:
185188
logging.error("Failed to get events with status code : "+str(response.status_code))
186189
except Exception as e:
@@ -411,8 +414,8 @@ def get_user_details(client_name):
411414

412415
f_url = f"{url}/Client/byName(clientName='{client_name}')"
413416
response = requests.get(f_url, headers=headers).json()
414-
user_id = response.get('clientProperties', [{}])[0].get('clientProps', {}).get('securityAssociations', {}).get('associations', [{}])[0].get('userOrGroup', [{}])[0].get('userId')
415-
user_name = response.get('clientProperties', [{}])[0].get('clientProps', {}).get('securityAssociations', {}).get('associations', [{}])[0].get('userOrGroup', [{}])[0].get('userName')
417+
user_id = response['clientProperties'][0]['clientProps']['securityAssociations']['associations'][0]['userOrGroup'][0]['userId']
418+
user_name = response['clientProperties'][0]['clientProps']['securityAssociations']['associations'][0]['userOrGroup'][0]['userName']
416419
return user_id, user_name
417420

418421

@@ -529,7 +532,7 @@ def get_incident_details(message: str) -> dict | None:
529532
"description": description,
530533
}
531534
return details
532-
except:
535+
except Exception as e:
533536
logging.error(f"An error occurred")
534537
return None
535538

@@ -592,7 +595,7 @@ def post_data(body, chunk_count):
592595
logging.info(f"Data :- {body}")
593596
response = requests.post(uri, data=body, headers=headers)
594597
if (response.status_code >= 200 and response.status_code <= 299):
595-
logging.info("Chunk was processed{} events".format(chunk_count))
598+
logging.info("Chunk was processed {} events with status : {}".format(chunk_count, response.content))
596599
else:
597600
logging.error("Error during sending events to Microsoft Sentinel. Response code:{}".format(response.status_code))
598601

0 commit comments

Comments
 (0)