Skip to content

Commit

Permalink
5.7.9
Browse files Browse the repository at this point in the history
- Add an error message to `["bimi"]["image]["error"]` instead of `["bimi"]["warnings"]` when a BIMI image download fails
- Add an error message to `["bimi"]["certificate]["error"]` instead of `["bimi"]["warnings"]` when a BIMI certificate download fails
  • Loading branch information
seanthegeek committed Nov 2, 2024
1 parent 4c7e6f9 commit 1e6fd6b
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/python-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
make html
- name: Check code style
run: |
black --check .
black -V --check .
- name: Run unit tests
run: |
coverage run tests.py
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
Changelog
=========

5.7.9
-----

- Add an error message to `["bimi"]["image]["error"]` instead of `["bimi"]["warnings"]` when a BIMI image download fails
- Add an error message to `["bimi"]["certificate]["error"]` instead of `["bimi"]["warnings"]` when a BIMI certificate download fails

5.7.8
-----

- Move SVG validation errors from `["bimi"]["warnings"]` to `["bimi"]["image"]["validation_errors"]` (#150)


5.7.7
-----

Expand Down
2 changes: 1 addition & 1 deletion checkdmarc/_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
See the License for the specific language governing permissions and
limitations under the License."""

__version__ = "5.7.8"
__version__ = "5.7.9"

OS = platform.system()
OS_RELEASE = platform.release()
Expand Down
12 changes: 9 additions & 3 deletions checkdmarc/bimi.py
Original file line number Diff line number Diff line change
Expand Up @@ -567,15 +567,19 @@ def parse_bimi_record(
response.raise_for_status()
raw_xml = response.content
except Exception as e:
warnings.append(f"Failed to download BIMI image at {tag_value} - {str(e)}")
results["certificate"] = dict(
error=f"Failed to download BIMI image at {tag_value} - {str(e)}"
)
if raw_xml is not None:
try:
image_metadata = get_svg_metadata(raw_xml)
svg_validation_errors = check_svg_requirements(image_metadata)
if len(svg_validation_errors) > 0:
image_metadata["validation_errors"] = svg_validation_errors
except Exception as e:
warnings.append(f"Failed to process BIMI image at {tag_value} - {str(e)}")
results["image"] = dict(
error=f"Failed to process BIMI image at {tag_value} - {str(e)}"
)
elif tag == "a" and tag_value != "":
cert_metadata = None
try:
Expand All @@ -591,7 +595,9 @@ def parse_bimi_record(
"The image at the l= tag URL does not match the image embedded in the certificate"
)
except Exception as e:
warnings.append(f"Unable to download mark certificate - {str(e)}")
results["certificate"] = dict(
error=f"Failed to download the mark certificate at {tag_value} - {str(e)}"
)
certificate_provided = hash_match and cert_metadata["valid"]
if not certificate_provided:
warnings.append(
Expand Down

0 comments on commit 1e6fd6b

Please sign in to comment.