Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [3.0.2] - 13 June 2023

### Fixed

* Handled an exception caused by `_check_token()` trying to parse the expiration date from a token that never expires

## [3.0.1] - 17 May 2023

### Changed
Expand Down
8 changes: 6 additions & 2 deletions sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,11 @@ async def _execute_query(self, query: DocumentNode, variable_values: dict = None
async def _check_token(self) -> None:
"""Send a `whoami` query to Ghostwriter to check authentication and token expiration."""
whoami = await self._execute_query(self.whoami_query)
expiry = datetime.fromisoformat(whoami["whoami"]["expires"])
try:
expiry = datetime.fromisoformat(whoami["whoami"]["expires"])
except Exception:
expiry = whoami["whoami"]["expires"]

await mythic.send_event_log_message(
mythic=self.mythic_instance,
message=f"Mythic Sync has successfully authenticated to Ghostwriter. Your configured token expires at: {expiry}",
Expand All @@ -299,7 +303,7 @@ async def _check_token(self) -> None:

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