-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat+ci: Added support for notifications via e-mail and Secrets Leaks…
… for CI
- Loading branch information
Showing
7 changed files
with
106 additions
and
6 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
name: Secret Detection | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
scan-secrets: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Run TruffleHog OSS | ||
uses: trufflesecurity/trufflehog@v3.67.6 |
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import os | ||
|
||
import yagmail | ||
from helpers import constants | ||
from logger import wbm_logger | ||
|
||
__appname__ = os.path.splitext(os.path.basename(__file__))[0] | ||
color_me = wbm_logger.ColoredLogger(__appname__) | ||
LOG = color_me.create_logger() | ||
|
||
|
||
def send_email_notification( | ||
email: str, subject: str, body: str, attachment: str = None | ||
): | ||
"""Send email notification with optional attachment. | ||
Args: | ||
email (str): Sender's email address. | ||
subject (str): Email subject. | ||
body (str): Email body. | ||
attachment (str, optional): Path to the attachment file. Defaults to None. | ||
""" | ||
|
||
if not constants.email_password: | ||
LOG.warning( | ||
color_me.yellow( | ||
f"E-mail password not found in the ENV variables! I will not be able to send you e-mails." | ||
) | ||
) | ||
return | ||
|
||
try: | ||
# Initialize yagmail SMTP connection | ||
yag = yagmail.SMTP( | ||
email, | ||
constants.email_password, | ||
smtp_starttls=True, | ||
smtp_ssl=False, | ||
smtp_skip_login=False, | ||
host="smtp-mail.outlook.com", | ||
port=587, | ||
) | ||
|
||
# Send email with attachment if provided | ||
if attachment: | ||
yag.send(to=email, subject=subject, contents=body, attachments=attachment) | ||
else: | ||
yag.send(to=email, subject=subject, contents=body) | ||
|
||
LOG.info(color_me.green(f"Email notification sent successfully to '{email}'")) | ||
except Exception as e: | ||
LOG.error( | ||
color_me.red(f"Failed to send email notification to '{email}' | {str(e)}") | ||
) |
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ colorama==0.4.6 | |
pywebcopy==7.0.2 | ||
selenium==4.17.2 | ||
webdriver_manager==4.0.1 | ||
yagmail==0.15.293 |