DigitalTrustCenter / sectxt

security.txt parser and validator
European Union Public License 1.2
17 stars 6 forks source link

Parser can not handle timestamps without timezones #33

Closed mxsasha closed 1 year ago

mxsasha commented 2 years ago

https://grapheneos.org/.well-known/security.txt has (at time of writing) Expires: 2023-10-19, which causes the parser to throw an exception:

>>> sectxt.SecurityTXT('https://grapheneos.org/')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/sasha/dev/internet.nl/.venv/lib/python3.9/site-packages/sectxt/__init__.py", line 337, in __init__
    super().__init__('', recommend_unknown_fields=recommend_unknown_fields)
  File "/Users/sasha/dev/internet.nl/.venv/lib/python3.9/site-packages/sectxt/__init__.py", line 79, in __init__
    self._process()
  File "/Users/sasha/dev/internet.nl/.venv/lib/python3.9/site-packages/sectxt/__init__.py", line 395, in _process
    super()._process()
  File "/Users/sasha/dev/internet.nl/.venv/lib/python3.9/site-packages/sectxt/__init__.py", line 85, in _process
    self._line_info.append(self._parse_line(line))
  File "/Users/sasha/dev/internet.nl/.venv/lib/python3.9/site-packages/sectxt/__init__.py", line 139, in _parse_line
    return self._parse_field(line)
  File "/Users/sasha/dev/internet.nl/.venv/lib/python3.9/site-packages/sectxt/__init__.py", line 190, in _parse_field
    self._parse_expires(value)
  File "/Users/sasha/dev/internet.nl/.venv/lib/python3.9/site-packages/sectxt/__init__.py", line 231, in _parse_expires
    if date_value > max_value:
TypeError: can't compare offset-naive and offset-aware datetimes

I assume this is because the Expires value does not have a timezone in this file. My quick read of RFC 3339 5.6 says this is invalid - but then it should just be detected as a regular error.

DigitalTrustCenter commented 1 year ago

New version 0.7 is published that fixes this: https://pypi.org/project/sectxt/0.7/