Skip to content

Commit aa4ed3f

Browse files
jochmanItay4
authored andcommitted
Archer: Skipping old incidents in fetch (#10758)
* Archer: Skipped old incidents * fix incidents times * Update Packs/ArcherRSA/ReleaseNotes/1_1_9.md Co-authored-by: Itay Keren <ikeren@paloaltonetworks.com>
1 parent 2ac67db commit aa4ed3f

File tree

4 files changed

+40
-5
lines changed

4 files changed

+40
-5
lines changed

Packs/ArcherRSA/Integrations/ArcherV2/ArcherV2.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -1147,18 +1147,20 @@ def fetch_incidents(
11471147
# Build incidents
11481148
incidents = list()
11491149
# Encountered that sometimes, somehow, on of next_fetch is not UTC.
1150-
next_fetch = from_time.replace(tzinfo=timezone.utc)
1150+
last_fetch_time = from_time.replace(tzinfo=timezone.utc)
1151+
next_fetch = last_fetch_time
11511152
for record in records:
11521153
incident, incident_created_time = client.record_to_incident(record, app_id, fetch_param_id)
11531154
# Encountered that sometimes, somehow, incident_created_time is not UTC.
11541155
incident_created_time = incident_created_time.replace(tzinfo=timezone.utc)
1155-
if next_fetch <= incident_created_time:
1156-
next_fetch = incident_created_time
1156+
if last_fetch_time <= incident_created_time:
1157+
incidents.append(incident)
1158+
if next_fetch < incident_created_time:
1159+
next_fetch = incident_created_time
11571160
else:
11581161
demisto.debug(
11591162
f'The newly fetched incident is older than last fetch. {incident_created_time=} {next_fetch=}'
11601163
)
1161-
incidents.append(incident)
11621164
demisto.debug(f'Going out fetch incidents with {next_fetch=}, {len(incidents)=}')
11631165
return incidents, next_fetch
11641166

Packs/ArcherRSA/Integrations/ArcherV2/ArcherV2_test.py

+29
Original file line numberDiff line numberDiff line change
@@ -471,3 +471,32 @@ def test_two_fetches(self, mocker):
471471
assert last_fetch < next_fetch
472472
assert next_fetch == datetime(2020, 3, 18, 15, 30, tzinfo=timezone.utc)
473473
assert incidents[0]['occurred'] == '2020-03-18T15:30:00.000Z'
474+
475+
def test_fetch_got_old_incident(self, mocker):
476+
"""
477+
Given:
478+
last_fetch is newer than new incident
479+
480+
When:
481+
Fetching incidents
482+
483+
Then:
484+
Check that the next fetch is equals last fetch (no new incident)
485+
Check that no incidents brought back
486+
"""
487+
client = Client(BASE_URL, '', '', '', '')
488+
date_time_reported = '2018-03-01T10:02:00.000Z'
489+
params = {
490+
'applicationId': '75',
491+
'applicationDateField': 'Date/Time Reported'
492+
}
493+
record = copy.deepcopy(INCIDENT_RECORD)
494+
record['record']['Date/Time Reported'] = date_time_reported
495+
record['raw']['Field'][1]['@xmlConvertedValue'] = date_time_reported
496+
last_fetch = get_fetch_time(
497+
{'last_fetch': '2018-03-01T10:03:00Z'}, params.get('fetch_time', '3 days')
498+
)
499+
mocker.patch.object(client, 'search_records', return_value=([record], {}))
500+
incidents, next_fetch = fetch_incidents(client, params, last_fetch, '305')
501+
assert last_fetch == next_fetch
502+
assert not incidents, 'Should not get new incidents.'

Packs/ArcherRSA/ReleaseNotes/1_1_9.md

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
#### Integrations
3+
##### RSA Archer v2
4+
Fixed an issue where duplicate incidents were fetched.

Packs/ArcherRSA/pack_metadata.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "RSA Archer",
33
"description": "The RSA Archer GRC Platform provides a common foundation for managing policies, controls, risks, assessments and deficiencies across lines of business.",
44
"support": "xsoar",
5-
"currentVersion": "1.1.8",
5+
"currentVersion": "1.1.9",
66
"author": "Cortex XSOAR",
77
"url": "https://www.paloaltonetworks.com/cortex",
88
"email": "",

0 commit comments

Comments
 (0)