From f18ead9efabe09065039c993409d7bb4f6f3a576 Mon Sep 17 00:00:00 2001 From: David Sangrey Date: Sun, 16 Feb 2025 20:49:03 -0500 Subject: [PATCH 1/3] [#1428] Implement Timestamp Checker --- EDMarketConnector.py | 9 +++++++++ config/__init__.py | 14 ++++++++++++++ plug.py | 9 +++++++++ 3 files changed, 32 insertions(+) diff --git a/EDMarketConnector.py b/EDMarketConnector.py index 80a958e1..28e83686 100755 --- a/EDMarketConnector.py +++ b/EDMarketConnector.py @@ -187,6 +187,12 @@ if __name__ == '__main__': # noqa: C901 '--killswitches-file', help='Specify a custom killswitches file', ) + + parser.add_argument( + '--skip-timecheck', + help='Skips the Time Delta check for processed events', + action='store_true' + ) ########################################################################### args: argparse.Namespace = parser.parse_args() @@ -250,6 +256,9 @@ if __name__ == '__main__': # noqa: C901 for d in conf_module.trace_on: logger.info(f'marked {d} for TRACE') + if args.skip_timecheck: + config.set_skip_timecheck() + def handle_edmc_callback_or_foregrounding() -> None: # noqa: CCR001 """Handle any edmc:// auth callback, else foreground an existing window.""" logger.trace_if('frontier-auth.windows', 'Begin...') diff --git a/config/__init__.py b/config/__init__.py index adf3e47f..05eb3f5b 100644 --- a/config/__init__.py +++ b/config/__init__.py @@ -201,6 +201,7 @@ class AbstractConfig(abc.ABC): __auth_force_edmc_protocol = False # Should we force edmc:// protocol ? __eddn_url = None # Non-default EDDN URL __eddn_tracking_ui = False # Show EDDN tracking UI ? + __skip_timecheck = False # Skip checking event timestamps? def __init__(self) -> None: self.home_path = pathlib.Path.home() @@ -270,6 +271,19 @@ class AbstractConfig(abc.ABC): """ return self.__eddn_tracking_ui + def set_skip_timecheck(self): + """Set the Event Timecheck bool.""" + self.__skip_timecheck = True + + @property + def skip_timecheck(self) -> bool: + """ + Determine if the Event Timecheck bool is enabled. + + :return: bool - Should EDMC check event timechecks? + """ + return self.__skip_timecheck + @property def app_dir(self) -> str: """Return a string version of app_dir.""" diff --git a/plug.py b/plug.py index ee53e76b..acaa006a 100644 --- a/plug.py +++ b/plug.py @@ -14,6 +14,7 @@ import operator import os import sys import tkinter as tk +from datetime import datetime, timedelta from pathlib import Path from tkinter import ttk from typing import Any, Mapping, MutableMapping @@ -331,6 +332,14 @@ def notify_journal_entry( logger.trace_if('journal.locations', 'Notifying plugins of "Location" event') error = None + + if "timestamp" in entry and not config.skip_timecheck: + # Check that timestamp is recent enough + dt = datetime.strptime(entry["timestamp"], "%Y-%m-%dT%H:%M:%SZ") + if dt > datetime.utcnow() - timedelta(minutes=60): + error = f"Event at {entry['timestamp']} beyond Time Delta of 60 minutes. Skipping." + return error + for plugin in PLUGINS: journal_entry = plugin._get_func('journal_entry') if journal_entry: From 2b95a3eece3a93ed26960c1cdd5d0fa8b34861fa Mon Sep 17 00:00:00 2001 From: David Sangrey Date: Sun, 16 Feb 2025 20:49:27 -0500 Subject: [PATCH 2/3] [Minor] Fallback to Latest 3.11 Version Why pin the specific build? Just use the lastest GitHub available 3.11 version. --- .python-version | 2 +- ChangeLog.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.python-version b/.python-version index 2419ad5b..2c073331 100644 --- a/.python-version +++ b/.python-version @@ -1 +1 @@ -3.11.9 +3.11 diff --git a/ChangeLog.md b/ChangeLog.md index f591940f..e65181d1 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,6 +1,6 @@ This is the master changelog for Elite Dangerous Market Connector. Entries are in reverse chronological order (latest first). --- -* We currently test against, and package with, Python 3.11.9, 32-bit. +* We currently test against, and package with, Python 3.11, 32-bit. * As a result, we do not support Windows 7, 8, or 8.1. * Developers can check the contents of the `.python-version` file in the source (not distributed with the Windows installer) for the From 1a93396047c1de8b9bfe5027bb6ee0928dae5ac2 Mon Sep 17 00:00:00 2001 From: David Sangrey Date: Sun, 16 Feb 2025 21:12:19 -0500 Subject: [PATCH 3/3] [Security] Remove ExecutionPolicy Command This command isn't needed and opens EDMC to a potential security bug. --- resources/EDMC_Installer_Config_template.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/EDMC_Installer_Config_template.txt b/resources/EDMC_Installer_Config_template.txt index de40630c..1a31eeca 100644 --- a/resources/EDMC_Installer_Config_template.txt +++ b/resources/EDMC_Installer_Config_template.txt @@ -80,7 +80,7 @@ begin begin PowerShellOutputFile := ExpandConstant('{tmp}\PowershellOutput.txt'); // Construct the PowerShell command and capture output to a file - Exec('powershell.exe', '-NoProfile -ExecutionPolicy Bypass -Command "Get-WmiObject -Class Win32_Product | where Name -eq ''Elite Dangerous Market Connector'' | select-object -expandproperty IdentifyingNumber" | Out-File -Encoding ASCII "' + PowerShellOutputFile + '"', '', SW_HIDE, ewWaitUntilTerminated, ResultCode); + Exec('powershell.exe', '-NoProfile -Command "Get-WmiObject -Class Win32_Product | where Name -eq ''Elite Dangerous Market Connector'' | select-object -expandproperty IdentifyingNumber" | Out-File -Encoding ASCII "' + PowerShellOutputFile + '"', '', SW_HIDE, ewWaitUntilTerminated, ResultCode); begin if LoadStringFromFile(PowerShellOutputFile, S) then S:= Trim(S);