feat: allow pass hostname in docker env#144
Open
tomerqodo wants to merge 2 commits intoqodo_action_req_1_base_feat_allow_pass_hostname_in_docker_env_pr6from
Conversation
Code Review by Qodo
1. Unvalidated SMTP_LOCAL_HOSTNAME used
|
Comment on lines
+25
to
+36
| local_host = dify_config.SMTP_LOCAL_HOSTNAME or "" | ||
| try: | ||
| if self.use_tls: | ||
| if self.opportunistic_tls: | ||
| smtp = smtplib.SMTP(self.server, self.port, timeout=10) | ||
| # Send EHLO command with the HELO domain name as the server address | ||
| smtp.ehlo(self.server) | ||
| smtp.starttls() | ||
| # Resend EHLO command to identify the TLS session | ||
| smtp.ehlo(self.server) | ||
| else: | ||
| smtp = smtplib.SMTP_SSL(self.server, self.port, timeout=10) | ||
| else: | ||
| smtp = smtplib.SMTP(self.server, self.port, timeout=10) | ||
| # Use ternary to select SMTP class based on TLS mode | ||
| smtp = (smtplib.SMTP_SSL if (self.use_tls and not self.opportunistic_tls) else smtplib.SMTP)( | ||
| self.server, self.port, timeout=10, local_hostname=local_host or None | ||
| ) | ||
|
|
||
| assert smtp is not None | ||
| if self.use_tls and self.opportunistic_tls: | ||
| smtp.ehlo(local_host) | ||
| smtp.starttls() | ||
| smtp.ehlo(local_host) |
There was a problem hiding this comment.
1. Unvalidated smtp_local_hostname used 📘 Rule violation ⛨ Security
• SMTP_LOCAL_HOSTNAME is treated as an arbitrary external input and is used directly for EHLO without any validation/sanitization. • When unset, local_host becomes an empty string and is still passed to smtp.ehlo(local_host), which can trigger SMTP protocol errors depending on server behavior. • This violates the requirement to handle edge cases and validate external inputs before use.
Agent prompt
## Issue description
`SMTP_LOCAL_HOSTNAME` (external config input) is used directly for `EHLO` and can be empty/invalid, causing SMTP handshake errors and failing the input validation requirement.
## Issue Context
Current behavior sets `local_host = dify_config.SMTP_LOCAL_HOSTNAME or ""` and then calls `smtp.ehlo(local_host)` even when it is empty.
## Fix Focus Areas
- api/libs/smtp.py[23-36]
- api/configs/feature/__init__.py[952-956]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Benchmark PR from agentic-review-benchmarks#6