-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Type
refactor
Severity
medium
Area
nmapui/google_drive.py, nmapui/settings.py
Description
Both google_drive.py and settings.py contain nearly identical implementations of:
_set_owner_only_permissions()— sets file to0o600_load_or_create_encryption_key()— creates/loads Fernet keys with atomic file operations
The implementations have the same structure but have drifted slightly. Bug fixes applied to one copy may not be applied to the other.
Additionally, both have a TOCTOU race condition in key creation: between the exists() check and read_bytes(), another process could delete or modify the key file. Two processes starting simultaneously could both generate different keys, making tokens encrypted with one key undecryptable.
Proposed Fix
- Create
nmapui/crypto_utils.pywith the shared implementations - Use
fcntl.flockorO_CREAT | O_EXCLfor atomic key creation - Have both
google_drive.pyandsettings.pyimport from the shared module
Related Issues
#182 (Duplicate encryption helpers — closed, but apparently not fully resolved)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request