Compare commits

...

5 Commits

Author SHA1 Message Date
Sean Whalen
976a3274e6 8.15.2 2024-10-24 18:04:19 -04:00
Sean Whalen
bb722e651a Fix parsing when auth record is missing 2024-10-24 17:14:02 -04:00
PhiBo
ab280d7a34 Update Dockerfile (#571)
* Use multi-stage build to reduce image size
* Add ARGS to be more flexible during image builds
* Create user and use it instead of root
* Don't update pip in container. The Python image should have a recent
  version
2024-10-24 14:18:29 -04:00
Alexej Sidorenko
92b12eaacf issue #565 - Logfile is overwritten when parsedmarc (re)starts (#569)
Do not re-write the log file if already exists. Add a log handler in "append" mode (that should be an implicit value but it's defined explicitly for the visibility).
2024-10-10 15:27:15 -04:00
Jed Laundry
8444053476 Create optional dependency group for build, fix codecov (#567)
* Create optional dependency groups for build and cli

* revert cli optional-dependencies group
2024-10-07 13:47:35 -04:00
8 changed files with 57 additions and 61 deletions

View File

@@ -39,7 +39,7 @@ jobs:
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
pip install .[build]
- name: Test building documentation
run: |
cd docs
@@ -49,8 +49,7 @@ jobs:
ruff check .
- name: Run unit tests
run: |
coverage run tests.py
coverage json
pytest --cov --cov-report=xml tests.py
- name: Test sample DMARC reports
run: |
pip install -e .
@@ -61,3 +60,5 @@ jobs:
hatch build
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}

View File

@@ -1,6 +1,14 @@
Changelog
=========
8.15.2
------
- Require `mailsuite>=1.9.18`
- Pins `mail-parser` version at `3.15.0` due to a parsing regression in mail-parser `4.0.0`
- Parse aggregate reports with empty `<auth_results>`
- Do not overwrite the log on each run (PR #569 fixes issue #565)
8.15.1
------

View File

@@ -1,12 +1,35 @@
FROM python:3.9-slim
ARG BASE_IMAGE=python:3.9-slim
ARG USERNAME=parsedmarc
ARG USER_UID=1000
ARG USER_GID=$USER_UID
## build
FROM $BASE_IMAGE AS build
WORKDIR /app
RUN pip install hatch
COPY parsedmarc/ parsedmarc/
COPY README.md pyproject.toml ./
RUN pip install -U pip
RUN pip install hatch
RUN hatch build
RUN pip install dist/*.whl
## image
FROM $BASE_IMAGE
ARG USERNAME
ARG USER_UID
ARG USER_GID
COPY --from=build /app/dist/*.whl /tmp/dist/
RUN set -ex; \
groupadd --gid ${USER_GID} ${USERNAME}; \
useradd --uid ${USER_UID} --gid ${USER_GID} -m ${USERNAME}; \
pip install /tmp/dist/*.whl; \
rm -rf /tmp/dist
USER $USERNAME
ENTRYPOINT ["parsedmarc"]

View File

@@ -7,7 +7,7 @@ if [ ! -d "venv" ]; then
fi
. venv/bin/activate
pip install -U -r requirements.txt
pip install .[build]
ruff format .
cd docs
make clean

View File

@@ -34,7 +34,7 @@ from parsedmarc.utils import is_outlook_msg, convert_outlook_msg
from parsedmarc.utils import parse_email
from parsedmarc.utils import timestamp_to_human, human_timestamp_to_datetime
__version__ = "8.15.1"
__version__ = "8.15.2"
logger.debug("parsedmarc v{0}".format(__version__))
@@ -169,7 +169,7 @@ def _parse_report_record(
else:
lowered_from = ""
new_record["identifiers"]["header_from"] = lowered_from
if record["auth_results"] is not None:
if isinstance(record["auth_results"], dict):
auth_results = record["auth_results"].copy()
if "spf" not in auth_results:
auth_results["spf"] = []

View File

@@ -1179,9 +1179,7 @@ def _main():
logger.setLevel(logging.DEBUG)
if opts.log_file:
try:
log_file = open(opts.log_file, "w")
log_file.close()
fh = logging.FileHandler(opts.log_file)
fh = logging.FileHandler(opts.log_file, "a")
formatter = logging.Formatter(
"%(asctime)s - "
"%(levelname)s - [%(filename)s:%(lineno)d] - %(message)s"

View File

@@ -46,15 +46,27 @@ dependencies = [
"imapclient>=2.1.0",
"kafka-python-ng>=2.2.2",
"lxml>=4.4.0",
"mailsuite>=1.9.17",
"mailsuite>=1.9.18",
"msgraph-core==0.2.2",
"opensearch-py>=2.4.2,<=3.0.0",
"publicsuffixlist>=0.10.0",
"pygelf>=0.4.2",
"requests>=2.22.0",
"tqdm>=4.31.1",
"urllib3>=1.25.7",
"xmltodict>=0.12.0",
"pygelf>=0.4.2",
]
[project.optional-dependencies]
build = [
"hatch",
"myst-parser[linkify]",
"nose",
"pytest",
"pytest-cov",
"ruff",
"sphinx",
"sphinx_rtd_theme",
]
[project.scripts]

View File

@@ -1,46 +0,0 @@
tqdm>=4.31.1
pygments>=2.11.1
dnspython>=2.0.0
expiringdict>=1.1.4
urllib3>=1.25.7
requests>=2.22.0
publicsuffixlist>=0.10.0
xmltodict>=0.12.0
geoip2>=3.0.0
imapclient>=2.1.0
dateparser>=1.1.1
elasticsearch<7.14.0
elasticsearch-dsl>=7.4.0
opensearch-py>=2.4.2,<=3.0.0
kafka-python-ng>=2.2.2
mailsuite>=1.9.17
pygelf
nose>=1.3.7
wheel>=0.37.0
ruff
jinja2>=2.10.1
packaging>=19.1
imagesize>=1.1.0
alabaster>=0.7.12
Babel>=2.7.0
docutils<0.18,>=0.14
sphinx>=1.0.5
sphinx_rtd_theme>=0.4.3
codecov>=2.0.15
lxml>=4.4.0
boto3>=1.16.63
msgraph-core==0.2.2
azure-identity>=1.8.0
azure-monitor-ingestion>=1.0.0
google-api-core>=2.4.0
google-api-python-client>=2.35.0
google-auth>=2.3.3
google-auth-httplib2>=0.1.0
google-auth-oauthlib>=0.4.6
hatch>=1.5.0
myst-parser>=0.18.0
myst-parser[linkify]
requests
bs4
pytest