koenbuyens / securityheaders

Check any website (or set of websites) for insecure security headers.
Apache License 2.0
244 stars 50 forks source link

Needs to be update the tabulate on python 3.10 #13

Open miszterx opened 1 year ago

miszterx commented 1 year ago

Hi,

If somebody is still using this, and needs to use python 3.10, then this will popup:

python3 ./securityheaders.py                                                                                                                                                  ─╯
Traceback (most recent call last):
  File "/root/securityheaders/./securityheaders.py", line 6, in <module>
    import securityheaders.command_line
  File "/root/securityheaders/securityheaders/__init__.py", line 11, in <module>
    from .securityheader import SecurityHeaders
  File "/root/securityheaders/securityheaders/securityheader.py", line 22, in <module>
    from securityheaders.formatters import FindingFormatterFactory
  File "/root/securityheaders/securityheaders/formatters/__init__.py", line 1, in <module>
    from .findingformatterfactory import FindingFormatterFactory, FindingFormatter, FindingFormatterTabulated, FindingFormatterCSV
  File "/root/securityheaders/securityheaders/formatters/findingformatterfactory.py", line 5, in <module>
    from tabulate import tabulate
  File "/usr/local/lib/python3.10/dist-packages/tabulate.py", line 16, in <module>
    from collections import Iterable
ImportError: cannot import name 'Iterable' from 'collections' (/usr/lib/python3.10/collections/__init__.py)

You needs to update the requirements.txt and install tabulate 0.9.0. It fix the problem:

diff --git a/requirements.txt b/requirements.txt
index 6b25e6e..41a1b17 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -3,4 +3,4 @@ argcomplete==1.9.4
 enum34==1.1.6
 ipaddress==1.0.22
 six==1.11.0
-tabulate==0.8.2
+tabulate==0.9.0
pip install -r requirements.txt                                                                                                                                               ─╯
Requirement already satisfied: anytree==2.4.3 in /usr/local/lib/python3.10/dist-packages (from -r requirements.txt (line 1)) (2.4.3)
Requirement already satisfied: argcomplete==1.9.4 in /usr/local/lib/python3.10/dist-packages (from -r requirements.txt (line 2)) (1.9.4)
Requirement already satisfied: enum34==1.1.6 in /usr/local/lib/python3.10/dist-packages (from -r requirements.txt (line 3)) (1.1.6)
Requirement already satisfied: ipaddress==1.0.22 in /usr/local/lib/python3.10/dist-packages (from -r requirements.txt (line 4)) (1.0.22)
Requirement already satisfied: six==1.11.0 in /usr/local/lib/python3.10/dist-packages (from -r requirements.txt (line 5)) (1.11.0)
Collecting tabulate==0.9.0
  Downloading tabulate-0.9.0-py3-none-any.whl (35 kB)
Installing collected packages: tabulate
  Attempting uninstall: tabulate
    Found existing installation: tabulate 0.8.5
    Uninstalling tabulate-0.8.5:
      Successfully uninstalled tabulate-0.8.5
Successfully installed tabulate-0.9.0
python ./securityheaders.py                                                                                                                                                   ─╯
usage: securityheaders.py [-h] [--listcheckers] [--listformatters] [--listheaders] [--headers HEADERS] [--response RESPONSE] [--defaultscheme https] [--max-redirects 2]
                          [--config ./conf/app.conf] [--urlcolumn 0] [--startrow 0] [--screen] [--file ./tmp] [--formatter Tabulate] [--flatten]
                          [--skipcheckers [checkername ...]] [--checkers [Checker ...]]
                          [URL ...]
Miesvanderlippe commented 1 year ago

I partially fixed this in this commit: https://github.com/koenbuyens/securityheaders/commit/541080342e5ffd45c06d117af1da1b8648c7c9bc

I guess we should explicitly install > 0.9 for systems which have existing installations of tabulate 0.8.x.