Skip to content

Commit bc69d12

Browse files
content-botwolyslageradi88d
authored
Update incident occurred time (demisto#31522)
* Update incident occurred time (demisto#31404) * updating occurred time for incidents * release notes * validation fixes * nit * fix formatting * update RN --------- Co-authored-by: Adi Daud <[email protected]> Co-authored-by: adi88d <[email protected]> * add new line * update RN * remove whitespace from blank line --------- Co-authored-by: William Olyslager <[email protected]> Co-authored-by: Adi Daud <[email protected]> Co-authored-by: adi88d <[email protected]>
1 parent dec5d2b commit bc69d12

File tree

7 files changed

+104
-26
lines changed

7 files changed

+104
-26
lines changed

Packs/AbnormalSecurity/Integrations/AbnormalSecurity/AbnormalSecurity.py

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -730,37 +730,39 @@ def get_a_list_of_unanalyzed_abuse_mailbox_campaigns_command(client, args):
730730
return command_results
731731

732732

733-
def generate_threat_incidents(client, threats, current_iso_format_time):
733+
def generate_threat_incidents(client, threats):
734734
incidents = []
735735
for threat in threats:
736736
threat_details = client.get_details_of_a_threat_request(threat["threatId"])
737737
incident = {
738738
"dbotMirrorId": str(threat["threatId"]),
739739
"name": "Threat",
740-
"occurred": current_iso_format_time,
740+
"occurred": threat_details["messages"][0].get("receivedTime"),
741741
"details": "Threat",
742742
"rawJSON": json.dumps(threat_details) if threat_details else {}
743743
}
744744
incidents.append(incident)
745745
return incidents
746746

747747

748-
def generate_abuse_campaign_incidents(client, campaigns, current_iso_format_time):
748+
def generate_abuse_campaign_incidents(client, campaigns):
749749
incidents = []
750750
for campaign in campaigns:
751751
campaign_details = client.get_details_of_an_abuse_mailbox_campaign_request(campaign["campaignId"])
752-
incident = {"dbotMirrorId": str(campaign["campaignId"]), "name": "Abuse Campaign", "occurred": current_iso_format_time,
753-
'details': "Abuse Campaign", "rawJSON": json.dumps(campaign_details) if campaign_details else {}}
752+
incident = {"dbotMirrorId": str(campaign["campaignId"]), "name": "Abuse Campaign",
753+
"occurred": campaign_details["firstReported"], 'details': "Abuse Campaign",
754+
"rawJSON": json.dumps(campaign_details) if campaign_details else {}}
754755
incidents.append(incident)
755756
return incidents
756757

757758

758-
def generate_account_takeover_cases_incidents(client, cases, current_iso_format_time):
759+
def generate_account_takeover_cases_incidents(client, cases):
759760
incidents = []
760761
for case in cases:
761762
case_details = client.get_details_of_an_abnormal_case_request(case["caseId"])
762-
incident = {"dbotMirrorId": str(case["caseId"]), "name": "Account Takeover Case", "occurred": current_iso_format_time,
763-
'details': case['description'], "rawJSON": json.dumps(case_details) if case_details else {}}
763+
incident = {"dbotMirrorId": str(case["caseId"]), "name": "Account Takeover Case",
764+
"occurred": case_details["firstObserved"], 'details': case['description'],
765+
"rawJSON": json.dumps(case_details) if case_details else {}}
764766
incidents.append(incident)
765767
return incidents
766768

@@ -799,21 +801,20 @@ def fetch_incidents(
799801
if fetch_threats:
800802
threats_filter = f"receivedTime gte {last_fetch}"
801803
threats_response = client.get_a_list_of_threats_request(filter_=threats_filter, page_size=100)
802-
all_incidents += generate_threat_incidents(client, threats_response.get('threats', []), current_iso_format_time)
804+
all_incidents += generate_threat_incidents(client, threats_response.get('threats', []))
803805

804806
if fetch_abuse_campaigns:
805807
abuse_campaigns_filter = f"lastReportedTime gte {last_fetch}"
806808
abuse_campaigns_response = client.get_a_list_of_campaigns_submitted_to_abuse_mailbox_request(
807809
filter_=abuse_campaigns_filter, page_size=100)
808-
all_incidents += generate_abuse_campaign_incidents(client, abuse_campaigns_response.get('campaigns', []),
809-
current_iso_format_time)
810+
all_incidents += generate_abuse_campaign_incidents(client, abuse_campaigns_response.get('campaigns', []))
810811

811812
if fetch_account_takeover_cases:
812813
account_takeover_cases_filter = f"lastModifiedTime gte {last_fetch}"
813814
account_takeover_cases_response = client.get_a_list_of_abnormal_cases_identified_by_abnormal_security_request(
814815
filter_=account_takeover_cases_filter, page_size=100)
815816
all_incidents += generate_account_takeover_cases_incidents(
816-
client, account_takeover_cases_response.get('cases', []), current_iso_format_time)
817+
client, account_takeover_cases_response.get('cases', []))
817818

818819
except Exception as e:
819820
logging.error(f"Failed fetching incidents: {e}")

Packs/AbnormalSecurity/Integrations/AbnormalSecurity/AbnormalSecurity_test.py

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ def test_get_a_list_of_threats_command(mocker):
150150
"""
151151
client = mock_client(mocker, util_load_json('test_data/test_get_list_of_abnormal_threats.json'))
152152
results = get_a_list_of_threats_command(client, {})
153-
assert results.outputs.get('threats')[0].get('threatId') == '184712ab-6d8b-47b3-89d3-a314efef79e2'
153+
assert results.outputs.get('threats')[0].get('threatId') == 'asdf097sdf907'
154154
assert results.outputs_prefix == 'AbnormalSecurity.inline_response_200'
155155

156156

@@ -473,18 +473,46 @@ def test_provides_the_analysis_and_timeline_details_of_a_case_command(mocker):
473473
assert results.outputs_prefix == 'AbnormalSecurity.CaseAnalysis'
474474

475475

476-
def test_fetch_incidents(mocker, mock_get_a_list_of_threats_request,
477-
mock_get_a_list_of_campaigns_submitted_to_abuse_mailbox_request,
478-
mock_get_a_list_of_abnormal_cases_identified_by_abnormal_security_request):
479-
client = mock_client(mocker, util_load_json('test_data/test_get_case_analysis_and_timeline.json'))
476+
def test_fetch_threat_incidents(mocker, mock_get_a_list_of_threats_request):
477+
client = mock_client(mocker, util_load_json('test_data/test_get_details_of_a_threat.json'))
478+
first_fetch_time = datetime.now().strftime(ISO_8601_FORMAT)
479+
next_run, incidents = fetch_incidents(
480+
client=client,
481+
last_run={"last_fetch": "2023-09-17T14:43:09Z"},
482+
first_fetch_time=first_fetch_time,
483+
max_incidents_to_fetch=200,
484+
fetch_account_takeover_cases=False,
485+
fetch_abuse_campaigns=False,
486+
fetch_threats=True
487+
)
488+
assert len(incidents) == 1
489+
490+
491+
def test_fetch_cases_incidents(mocker, mock_get_a_list_of_abnormal_cases_identified_by_abnormal_security_request):
492+
client = mock_client(mocker, util_load_json('test_data/test_get_details_of_an_abnormal_case.json'))
480493
first_fetch_time = datetime.now().strftime(ISO_8601_FORMAT)
481494
next_run, incidents = fetch_incidents(
482495
client=client,
483496
last_run={"last_fetch": "2023-09-17T14:43:09Z"},
484497
first_fetch_time=first_fetch_time,
485498
max_incidents_to_fetch=200,
486499
fetch_account_takeover_cases=True,
500+
fetch_abuse_campaigns=False,
501+
fetch_threats=False
502+
)
503+
assert len(incidents) == 1
504+
505+
506+
def test_fetch_abuse_campaign_incidents(mocker, mock_get_a_list_of_campaigns_submitted_to_abuse_mailbox_request):
507+
client = mock_client(mocker, util_load_json('test_data/test_get_details_of_abuse_campaign.json'))
508+
first_fetch_time = datetime.now().strftime(ISO_8601_FORMAT)
509+
next_run, incidents = fetch_incidents(
510+
client=client,
511+
last_run={"last_fetch": "2023-09-17T14:43:09Z"},
512+
first_fetch_time=first_fetch_time,
513+
max_incidents_to_fetch=200,
514+
fetch_account_takeover_cases=False,
487515
fetch_abuse_campaigns=True,
488-
fetch_threats=True
516+
fetch_threats=False
489517
)
490-
assert len(incidents) == 4
518+
assert len(incidents) == 1
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
{
2+
"threatId": "asdf097sdf907",
3+
"messages": [
4+
{
5+
"abxMessageId": -123456789,
6+
"abxPortalUrl": "https://someurl.com",
7+
"attachmentCount": 0,
8+
"attachmentNames": [],
9+
"attackStrategy": "Some attack strategy",
10+
"attackType": "Some attack type",
11+
"attackVector": "Some attack vector",
12+
"attackedParty": "Some attacked party",
13+
"autoRemediated": false,
14+
"fromAddress": "[email protected]",
15+
"fromName": "some name",
16+
"impersonatedParty": "Some impersonated party",
17+
"internetMessageId": "Some internet message id",
18+
"isRead": false,
19+
"postRemediated": false,
20+
"receivedTime": "2023-12-03T19:26:36Z",
21+
"recipientAddress": "some recipient address",
22+
"remediationStatus": "some remediation status",
23+
"remediationTimestamp": "2023-12-09T23:06:16.066762Z",
24+
"sentTime": "2023-12-03T19:26:36Z",
25+
"subject": "some subject",
26+
"threatId": "asdf097sdf907",
27+
"toAddresses": ["[email protected]"],
28+
"ccEmails": [],
29+
"replyToEmails": [],
30+
"returnPath": null,
31+
"senderDomain": "some.com",
32+
"senderIpAddress": null,
33+
"summaryInsights": [
34+
"Insight #1",
35+
"Insight #2",
36+
"Insight #3",
37+
"Insight #4"
38+
],
39+
"urlCount": 10,
40+
"urls": [
41+
"https://someurl.com",
42+
"https://someurl.com",
43+
"https://someurl.com",
44+
"https://someurl.com",
45+
"https://someurl.com"
46+
]
47+
}
48+
]
49+
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
22
"threats": [
33
{
4-
"threatId": "184712ab-6d8b-47b3-89d3-a314efef79e2"
4+
"threatId": "asdf097sdf907"
55
}
66
],
77
"pageNumber": 1,
88
"nextPageNumber": 2
9-
}
9+
}

Packs/AbnormalSecurity/Integrations/AbnormalSecurity/test_data/test_get_list_of_abuse_campaigns.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,8 @@
22
"campaigns": [
33
{
44
"campaignId": "fff51768-c446-34e1-97a8-9802c29c3ebd"
5-
},
6-
{
7-
"campaignId": "07434ea5-df7b-3ff4-8d07-4a82df0c655d"
85
}
96
],
107
"pageNumber": 1,
118
"nextPageNumber": 2
12-
}
9+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#### Integrations
2+
##### Abnormal Security
3+
- Modified the occurred time source for incidents.

Packs/AbnormalSecurity/pack_metadata.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "Abnormal Security",
33
"description": "Abnormal Security detects and protects against the whole spectrum of email attacks",
44
"support": "partner",
5-
"currentVersion": "2.2.1",
5+
"currentVersion": "2.2.2",
66
"author": "Abnormal Security",
77
"url": "",
88
"email": "[email protected]",

0 commit comments

Comments
 (0)