fix: sync setup.py version/python-requires with pyproject.toml, add logging to notifications#29
Conversation
…ogging to notifications - Update setup.py version from 1.0.0 to 1.5.0 to match pyproject.toml - Update python_requires from >=3.8 to >=3.10 to match pyproject.toml - Update setup.py classifiers: remove 3.8/3.9, add 3.12 - Fix Python version references across all docs (README, CONTRIBUTING, getting-started, index.rst, TOPICS.md, bug_report template) - Add logging to 6 silent except blocks in notifications.py that swallowed errors without any diagnostic output https://claude.ai/code/session_01W1kSjHVKvCByvEBprEyPhN
Summary of ChangesHello @AreteDriver, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request standardizes the project's declared version and Python compatibility across its configuration and documentation files. It updates Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
Code Review
This pull request updates the project's version and Python compatibility, ensuring consistency across documentation and setup.py with pyproject.toml. It also improves observability by adding logging to previously silent exception blocks in src/redops/modules/notifications.py. However, a security audit identified two vulnerabilities in src/redops/modules/notifications.py: a high-severity Server-Side Request Forgery (SSRF) due to unvalidated webhook URLs from environment variables, and a medium-severity issue where new logging changes expose full webhook URLs (potentially containing secrets) in logs.
| return response.status_code in (200, 201, 202, 204) | ||
| except Exception: | ||
| except Exception as e: | ||
| logger.warning("Failed to send webhook to %s: %s", url, e) |
There was a problem hiding this comment.
The newly added logging statement in the _send_webhook function logs the full webhook URL in case of an error. Webhook URLs often contain secrets, and logging them exposes these secrets in application logs. An attacker with access to the logs could steal these credentials.
Remediation:
Avoid logging the full URL. If the URL must be logged for debugging, parse it and log only the host or parts that do not contain secrets. For example, you could log urlparse(url).netloc.
| logger.warning("Failed to send webhook to %s: %s", url, e) | |
| logger.warning("Failed to send webhook to %s: %s", url.split('?')[0].split('/')[-1], e) |
| except Exception as e: | ||
| logger.warning("Failed to send Slack notification: %s", e) |
There was a problem hiding this comment.
To fully leverage the StructuredLogger (if adopted as suggested in the previous comment), the exception details should be passed as a keyword argument to the logging method. This allows the structured logger to include the error details in a more parseable format.
If the standard logging.getLogger is retained, the current format string approach is acceptable, but using keyword arguments is preferred for structured logging.
| except Exception as e: | |
| logger.warning("Failed to send Slack notification: %s", e) | |
| except Exception as e: | |
| logger.warning("Failed to send Slack notification", error=str(e)) |
| except Exception as e: | ||
| logger.warning("Failed to send Slack alert: %s", e) |
There was a problem hiding this comment.
To fully leverage the StructuredLogger (if adopted as suggested in the previous comment), the exception details should be passed as a keyword argument to the logging method. This allows the structured logger to include the error details in a more parseable format.
If the standard logging.getLogger is retained, the current format string approach is acceptable, but using keyword arguments is preferred for structured logging.
| except Exception as e: | |
| logger.warning("Failed to send Slack alert: %s", e) | |
| except Exception as e: | |
| logger.warning("Failed to send Slack alert", error=str(e)) |
| except Exception as e: | ||
| logger.warning("Failed to send Discord notification: %s", e) |
There was a problem hiding this comment.
To fully leverage the StructuredLogger (if adopted as suggested in the previous comment), the exception details should be passed as a keyword argument to the logging method. This allows the structured logger to include the error details in a more parseable format.
If the standard logging.getLogger is retained, the current format string approach is acceptable, but using keyword arguments is preferred for structured logging.
| except Exception as e: | |
| logger.warning("Failed to send Discord notification: %s", e) | |
| except Exception as e: | |
| logger.warning("Failed to send Discord notification", error=str(e)) |
| except Exception as e: | ||
| logger.warning("Failed to send Discord alert: %s", e) |
There was a problem hiding this comment.
To fully leverage the StructuredLogger (if adopted as suggested in the previous comment), the exception details should be passed as a keyword argument to the logging method. This allows the structured logger to include the error details in a more parseable format.
If the standard logging.getLogger is retained, the current format string approach is acceptable, but using keyword arguments is preferred for structured logging.
| except Exception as e: | |
| logger.warning("Failed to send Discord alert: %s", e) | |
| except Exception as e: | |
| logger.warning("Failed to send Discord alert", error=str(e)) |
| except Exception as e: | ||
| logger.warning("Failed to send email notification: %s", e) |
There was a problem hiding this comment.
To fully leverage the StructuredLogger (if adopted as suggested in the previous comment), the exception details should be passed as a keyword argument to the logging method. This allows the structured logger to include the error details in a more parseable format.
If the standard logging.getLogger is retained, the current format string approach is acceptable, but using keyword arguments is preferred for structured logging.
| except Exception as e: | |
| logger.warning("Failed to send email notification: %s", e) | |
| except Exception as e: | |
| logger.warning("Failed to send email notification", error=str(e)) |
getting-started, index.rst, TOPICS.md, bug_report template)
swallowed errors without any diagnostic output
https://claude.ai/code/session_01W1kSjHVKvCByvEBprEyPhN