Skip to content

Ngawa tafe/issue18 #25

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

Open
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

ngawa-tafe
Copy link

@ngawa-tafe ngawa-tafe commented Jun 25, 2025

Modularize the code by breaking it down into smaller functional parts.

  • still left to write tests and documents
  • pull request can be left and not accepted until test and documents are done
    update docs and refactor #18

@ngawa-tafe
Copy link
Author

@coderatul Please review before i progress further to write tests

@ngawa-tafe ngawa-tafe marked this pull request as draft June 25, 2025 00:07
@ngawa-tafe ngawa-tafe marked this pull request as ready for review June 25, 2025 00:12
@coderatul coderatul requested a review from Copilot June 25, 2025 08:57
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Modularizes the email bomber script by extracting functionality into dedicated modules and updating the Docker setup.

  • Extract SMTP connection, authentication, email construction, and credential management into separate files
  • Replace monolithic emailbomber.py with email_bomber() entrypoint and update main.py
  • Update Dockerfile to reflect new project structure

Reviewed Changes

Copilot reviewed 9 out of 10 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/server.py Added get_server to centralize SMTP connection logic
src/load_welcome.py Added display_welcome to handle loading and printing welcome
src/emailbomber.py New orchestration function tying together all modules
src/e_mail.py Split email detail input, message creation, and bulk sending
src/crendentials.py Added credential load/save utilities
src/authentication.py Added login_to_smtp to handle authentication errors
main.py Updated entrypoint to use email_bomber()
Dockerfile Adjusted COPY/CMD to accommodate new module layout
Comments suppressed due to low confidence (2)

src/crendentials.py:1

  • Filename 'crendentials.py' appears misspelled; rename to 'credentials.py' and update imports accordingly to avoid confusion.
import getpass

src/server.py:1

  • No tests have been added for 'get_server'; consider adding unit tests to cover successful connections and handled exceptions.
import smtplib

raise ValueError("Count must be positive.")
break
except ValueError as e:
raise ValueError(f"Invalid input: {e}")
Copy link
Preview

Copilot AI Jun 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This except block re-raises a ValueError on invalid count input, exiting instead of re-prompting; consider printing the error and using 'continue' to allow the user to retry.

Suggested change
raise ValueError(f"Invalid input: {e}")
print(f"Error: {e}. Please try again.")
continue

Copilot uses AI. Check for mistakes.

with open(f"{file_path}/sender.txt", "w") as sender_file:
sender_file.write(sender)
with open(f"{file_path}/app_password.txt", "w") as password_file:
password_file.write(app_password)
Copy link
Preview

Copilot AI Jun 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Storing application passwords in plaintext poses a security risk; consider using an OS keyring or encrypting the credentials on disk.

Copilot uses AI. Check for mistakes.

Comment on lines +9 to +10
server = smtplib.SMTP(smtp_server, smtp_port)
server.starttls()
Copy link
Preview

Copilot AI Jun 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] It’s recommended to call 'server.ehlo()' before and after 'starttls()' to ensure proper SMTP handshake and compliance with server requirements.

Suggested change
server = smtplib.SMTP(smtp_server, smtp_port)
server.starttls()
server = smtplib.SMTP(smtp_server, smtp_port)
server.ehlo()
server.starttls()
server.ehlo()

Copilot uses AI. Check for mistakes.


def display_welcome(filepath=WELCOME_FILE):
"""Displays the welcome message from a file."""
parent_dir = os.path.abspath(os.getcwd())
Copy link
Preview

Copilot AI Jun 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolving the welcome file relative to the current working directory may break if run elsewhere; consider using 'os.path.dirname(file)' or pathlib to reference the module's directory.

Suggested change
parent_dir = os.path.abspath(os.getcwd())
parent_dir = os.path.abspath(os.path.dirname(__file__))

Copilot uses AI. Check for mistakes.

@coderatul
Copy link
Owner

@ngawa-tafe you may work upon the suggestion given by copilot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants