Skip to content

Commit

Permalink
proxy fix for o365 script
Browse files Browse the repository at this point in the history
  • Loading branch information
aholzel committed Oct 5, 2023
1 parent 216f3fe commit 45a3e45
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion bin/TA-dmarc/mail-client.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ def pop3_mailbox():
# Save the attachement in the given directory
filename = part.get_filename()
if filename != None and (filename[-3:] == '.gz' or filename[-4:] == '.zip' or filename[-5:] == '.gzip'):
script_logger.debug(f"Message id: {actual_email_id}, Attachment found, name: {filename}"")
script_logger.debug(f"Message id: {actual_email_id}, Attachment found, name: {filename}")
# Replace the '!' for a '_' so is doesn't need to be escaped later on
filename = re.sub(r'(\!)', r'_', filename)

Expand Down
4 changes: 3 additions & 1 deletion bin/TA-dmarc/mail-o365.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@
proxy_username = args.proxy_user
proxy_pwd = args.proxy_pwd

if proxy_use or proxy_use == 1 or proxy_use.lower() == 't' or proxy_use.lower() == 'true':
if proxy_use is True or proxy_use == 1 or proxy_use.lower() == 't' or proxy_use.lower() == 'true':
script_logger.debug(f"A proxy needs to be used to connect to internet. The following will be used: {proxy_server}")
proxy_use = True
proxy_regex = re.search(r"(?:^([htps]*)(?=[:]+)(?:\:\/\/)|^)(.*)", proxy_server)
Expand All @@ -191,6 +191,8 @@
proxy_server = f"http://{proxy_username}@{proxy_regex.group(2)}"

proxies = { 'http': proxy_server, 'https': proxy_server }
else:
proxy_use = False

if client_id is None or tenant_id is None or client_secret is None or user is None:
script_logger.error("Not all the needed o365 fields are configured or accessable.")
Expand Down
2 changes: 1 addition & 1 deletion default/app.conf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
[launcher]
author = Arnold
description = App to collect dmarc reports from a POP3/POP3S/IMAP/IMAPS/o365 mailbox and process the attachements
version = 5.1.0
version = 5.1.1

[package]
check_for_updates = 0
Expand Down
9 changes: 6 additions & 3 deletions readme/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ This file will contain the changes to the script files. The file is split up in
## General app changes
| Date | Version | Author | **[Type]** Description |
|:-----------|:--------|:--------|:--------------------------------------------------------------------------------------|
| 2023-04-14 | 5.1.0 | Arnold | **[ADD]** Proxy support for the o365 script.<br />**[MOD]** Setup page to add proxy config.
| 2023-10-05 | 5.1.1 | Arnold | **[FIX]** Proxy problems with the o365 script.<br />**[FIX]** Wrong double quote in `mail-client.py`

## dmarc-parser.py
| Date | Version | Author | **[Type]** Description |
Expand All @@ -21,12 +21,12 @@ This use to be the `dmarc_converter.py` script.
## mail-client.py
| Date | Version | Author | **[Type]** Description |
|:-----------|:--------|:--------|:--------------------------------------------------------------------------------------|
| 2023-03-24 | 3.3.0 | Arnold | **[MOD]** Adapted the script for the new Splunk app layout. <br /> **[MOD]** Made a list for the allowed content types to make it easier to change.<br /> **[MOD]** Changed all the logging strings to python3 f-strings to make them more readable.
| 2023-10-05 | 3.3.1 | Arnold | **[FIX]** Removed wrong double quote

## mail-o365.py
| Date | Version | Author | **[Type]** Description |
|:-----------|:--------|:--------|:--------------------------------------------------------------------------------------|
| 2023-04-14 | 1.2.0 | Arnold | **[ADD]** Made the script proxy aware
| 2023-10-05 | 1.2.1 | Arnold | **[FIX]** Proxy problems

## ta-dmarc_setup.py
This use to be the `setup_handler.py` script.
Expand Down Expand Up @@ -71,6 +71,7 @@ This use to be the `setup_handler.py` script.
| 2023-03-31 | 5.0.1 | Arnold | **[FIX]** Minor typo fix in the `dmarc-parser.py`
| 2023-04-04 | 5.0.2 | Arnold | **[FIX]** Put the `lib` dir back that because of .gitignore didn't made it in the previous version.
| 2023-04-05 | 5.0.3 | Arnold | **[MOD]** Added `[trigger]` stanza to `app.conf` to prevent unnecessary restart after install
| 2023-04-14 | 5.1.0 | Arnold | **[ADD]** Proxy support for the o365 script.<br />**[MOD]** Setup page to add proxy config.

## dmarc-parser.py
| Date | Version | Author | **[Type]** Description |
Expand Down Expand Up @@ -146,12 +147,14 @@ This use to be the `setup_handler.py` script.
| 2021-10-14 | 3.0.1 | Arnold | **[FIX]** referenced before assignment error<br />**[ADD]** Microsoft is sending DMARC report (finally!) with a different subject... added this to the allowed subject list<br />
| 2022-10-06 | 3.1.0 | Arnold | **[FIX]** The mail subject is now always decoded before furter processing.<br />
| 2022-10-18 | 3.2.0 | Arnold | **[FIX]** Fixed problem where there where to many emails in a IMAP mailbox to fetch in 1 run.
| 2023-03-24 | 3.3.0 | Arnold | **[MOD]** Adapted the script for the new Splunk app layout. <br /> **[MOD]** Made a list for the allowed content types to make it easier to change.<br /> **[MOD]** Changed all the logging strings to python3 f-strings to make them more readable.

## mail-o365.py
| Date | Version | Author | **[Type]** Description |
|:-----------|:--------|:--------|:--------------------------------------------------------------------------------------|
| 2023-03-24 | 1.0.0 | Arnold | **[NEW]** initial version
| 2023-04-04 | 1.1.0 | Arnold | **[FIX]** Not all folders where reviewed when checking if a folder already existed
| 2023-04-14 | 1.2.0 | Arnold | **[ADD]** Made the script proxy aware

## ta-dmarc_setup.py
This use to be the `setup_handler.py` script.
Expand Down

0 comments on commit 45a3e45

Please sign in to comment.