Skip to content

Commit 343e48c

Browse files
Merge pull request #13 from breakid/token_error_handling
Handled expiration date parsing exception
2 parents 1ce1f31 + 2fba564 commit 343e48c

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [3.0.2] - 13 June 2023
9+
10+
### Fixed
11+
12+
* Handled an exception caused by `_check_token()` trying to parse the expiration date from a token that never expires
13+
814
## [3.0.1] - 17 May 2023
915

1016
### Changed

sync.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,11 @@ async def _execute_query(self, query: DocumentNode, variable_values: dict = None
289289
async def _check_token(self) -> None:
290290
"""Send a `whoami` query to Ghostwriter to check authentication and token expiration."""
291291
whoami = await self._execute_query(self.whoami_query)
292-
expiry = datetime.fromisoformat(whoami["whoami"]["expires"])
292+
try:
293+
expiry = datetime.fromisoformat(whoami["whoami"]["expires"])
294+
except Exception:
295+
expiry = whoami["whoami"]["expires"]
296+
293297
await mythic.send_event_log_message(
294298
mythic=self.mythic_instance,
295299
message=f"Mythic Sync has successfully authenticated to Ghostwriter. Your configured token expires at: {expiry}",
@@ -299,7 +303,7 @@ async def _check_token(self) -> None:
299303

300304
# Check if the token will expire within 24 hours
301305
now = datetime.now(timezone.utc)
302-
if expiry - now < timedelta(hours=24):
306+
if isinstance(expiry, datetime) and expiry - now < timedelta(hours=24):
303307
mythic_sync_log.debug(f"The provided Ghostwriter API token expires in less than 24 hours ({expiry})!")
304308
await mythic.send_event_log_message(
305309
mythic=self.mythic_instance,

0 commit comments

Comments
 (0)