-
-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: INTERCOM messages RSA #32
Conversation
these were still using the removed pgpy
Warning Rate limit exceeded@JarbasAl has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 8 minutes and 57 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📒 Files selected for processing (1)
WalkthroughThe changes in the Changes
Sequence DiagramsequenceDiagram
participant Client
participant HiveMindListener
participant RSADecryptor
Client->>HiveMindListener: Send encrypted message
HiveMindListener->>RSADecryptor: Unhexlify message
RSADecryptor->>HiveMindListener: Load private key
HiveMindListener->>RSADecryptor: Decrypt message
RSADecryptor-->>HiveMindListener: Decrypted message
HiveMindListener-->>Client: Process message
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
these were still using the removed pgpy
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (3)
hivemind_core/protocol.py (3)
14-14
: Remove unused imports or leverage them for RSA operations
The importsverify_RSA
andencrypt_RSA
are currently unused. Consider removing them, or use them for signature verification and message encryption to align with the new RSA-based approach.-from poorman_handshake.asymmetric.utils import verify_RSA, decrypt_RSA, encrypt_RSA, load_RSA_key +from poorman_handshake.asymmetric.utils import decrypt_RSA, load_RSA_key🧰 Tools
🪛 Ruff (0.8.2)
14-14:
poorman_handshake.asymmetric.utils.verify_RSA
imported but unusedRemove unused import
(F401)
14-14:
poorman_handshake.asymmetric.utils.encrypt_RSA
imported but unusedRemove unused import
(F401)
674-676
: Eliminate unused variable 'signature' or integrate signature verification
Currently,signature
is not used. This could be intentional for future signature verification, but if not, removing it will avoid confusion.-signature = unhexlify(pload["signature"])
🧰 Tools
🪛 Ruff (0.8.2)
676-676: Local variable
signature
is assigned to but never usedRemove assignment to unused variable
signature
(F841)
678-680
: Revisit commented-out signature verification
These lines suggest planned signature verification. If signature verification is imminent, consider implementing it; otherwise, remove the commented code to reduce clutter.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
hivemind_core/protocol.py
(2 hunks)
🧰 Additional context used
🪛 Ruff (0.8.2)
hivemind_core/protocol.py
14-14: poorman_handshake.asymmetric.utils.verify_RSA
imported but unused
Remove unused import
(F401)
14-14: poorman_handshake.asymmetric.utils.encrypt_RSA
imported but unused
Remove unused import
(F401)
676-676: Local variable signature
is assigned to but never used
Remove assignment to unused variable signature
(F841)
🔇 Additional comments (1)
hivemind_core/protocol.py (1)
682-684
: Validate RSA key loading and decryption
Loading the private key and decrypting within the same try block is appropriate, but ensure any decryption failure is handled consistently. Currently, higher-level error handling catches exceptions, which is good.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🧹 Nitpick comments (1)
hivemind_core/protocol.py (1)
682-684
: Enhance error handling for decryption failures.The current error handling is too broad and catches all exceptions. Consider handling specific exceptions (e.g., ValueError, CryptoError) to provide better error messages and debugging information.
private_key = load_RSA_key(self.identity.private_key) -decrypted: str = decrypt_RSA(private_key, ciphertext).decode("utf-8") -message._payload = HiveMessage.deserialize(decrypted) +try: + decrypted: str = decrypt_RSA(private_key, ciphertext).decode("utf-8") + message._payload = HiveMessage.deserialize(decrypted) +except ValueError as e: + LOG.error(f"Failed to decrypt message: Invalid format - {str(e)}") + return False +except Exception as e: + LOG.error(f"Failed to decrypt message: Unexpected error - {str(e)}") + return False
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
hivemind_core/protocol.py
(3 hunks)
🧰 Additional context used
🪛 Ruff (0.8.2)
hivemind_core/protocol.py
676-676: Local variable signature
is assigned to but never used
Remove assignment to unused variable signature
(F841)
🔇 Additional comments (1)
hivemind_core/protocol.py (1)
4-4
: LGTM! Imports are correctly updated for RSA encryption.
The new imports support the transition from pgpy to RSA encryption for INTERCOM messages.
Also applies to: 26-27
these were still using the removed pgpy
these were still using the removed pgpy
Same as JarbasHiveMind/hivemind-websocket-client#44
Summary by CodeRabbit
Security Improvements
Changes
handle_intercom_message
method to return a boolean status