Skip to content
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

The smtplib starttls context arg is always a kwarg #603

Merged
merged 1 commit into from
Sep 26, 2024
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
5 changes: 1 addition & 4 deletions precli/rules/python/stdlib/smtplib_unverified_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,7 @@ def analyze_call(self, context: dict, call: Call) -> Result | None:
]:
return

if call.name_qualified == "smtplib.SMTP_SSL":
ssl_context = call.get_argument(name="context")
else:
ssl_context = call.get_argument(position=0, name="context")
ssl_context = call.get_argument(name="context")
if ssl_context.value is not None:
return

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# level: WARNING
# start_line: 31
# end_line: 31
# start_column: 16
# end_column: 20
# start_column: 24
# end_column: 28
import smtplib


Expand All @@ -28,7 +28,7 @@ def prompt(prompt):
print("Message length is", len(msg))

server = smtplib.SMTP("localhost", timeout=5)
server.starttls(None)
server.starttls(context=None)
server.login("user", "password")
server.set_debuglevel(1)
server.sendmail(fromaddr, toaddrs, msg)
Expand Down