MemOpt #18

Merged
mysticmomba merged 30 commits from MemOpt into master 2025-09-02 17:53:43 -04:00
2 changed files with 14 additions and 2 deletions
Showing only changes of commit b91a61fb77 - Show all commits
+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')}
checkpoint = '000000000000000000000000'
checkpoint = str(skipback(days))
json_output = {'error': 'Success', 'response': {'exechistories': []}}
while True:
@@ -158,4 +158,16 @@ def listAllowlists(url):
#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)