Added Skipback to speed checkpoint hunting

This commit is contained in:
=
2025-09-01 22:24:21 -04:00
parent b3a67b1b93
commit b91a61fb77
2 changed files with 14 additions and 2 deletions
+1 -1
View File
File diff suppressed because one or more lines are too long
+13 -1
View File
@@ -37,7 +37,7 @@ def pullPolicyExechistories(url, policiesnames, days, outputjson: bool):
headers = {"X-APIKey": os.getenv('APIKEY')} headers = {"X-APIKey": os.getenv('APIKEY')}
checkpoint = '000000000000000000000000' checkpoint = str(skipback(days))
json_output = {'error': 'Success', 'response': {'exechistories': []}} json_output = {'error': 'Success', 'response': {'exechistories': []}}
while True: while True:
@@ -158,4 +158,16 @@ def listAllowlists(url):
#Need else and catch for upper bound #Need else and catch for upper bound
def skipback(days):
"""
Generate a MongoDB ObjectId for a given number of days ago from today.
Adds 1 extra day to the input to look further back.
"""
adjusted_days = days + 1
date_days_ago = datetime.datetime.now(datetime.UTC) - datetime.timedelta(days=adjusted_days)
timestamp = int(date_days_ago.timestamp())
hex_timestamp = format(timestamp, '08x')
objectid_hex = hex_timestamp + '0000000000000000'
return ObjectId(objectid_hex)