Bug#1067598: wfuzz: FTBFS with Python 3.12 as default

2024-07-15 Thread Emmanuel Arias
Control: tag -1 + pending

Hi,

I've just applied your patch to fix also [0], I made a NMU in
DELAYED/2-days. 

[0] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1066009

-- 
cheers,
Emmanuel Arias

 ⢀⣴⠾⠻⢶⣦⠀
 ⣾⠁⢠⠒⠀⣿⡁  eam...@debian.org
 ⢿⡄⠘⠷⠚⠋⠀  OpenPGP: 13796755BBC72BB8ABE2AEB5 FA9DEC5DE11C63F1
 
 ⠈⠳⣄


signature.asc
Description: PGP signature


Bug#1067598: wfuzz: FTBFS with Python 3.12 as default

2024-03-26 Thread Graham Inggs
Control: tags -1 + patch

The attached patch avoids the use of distutils and imp which are no
longer available in Python 3.12.  I believe this will close this bug
(#1067598) as well as #1066009 [1].

I did not test the package exhaustively, but was able to get similar
output to that described in #1015016 [2], when running the following
command with only Python 3.12 installed:

wfuzz --dry-run -w /usr/share/wfuzz/wordlist/general/test.txt -u
http://127.0.0.1/FUZZ


[1] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1066009
[2] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1015016
Description: Avoid the use of distutils and imp
 No longer available in Python 3.12
Bug-Debian: https://bugs.debian.org/1066009
Bug-Debian: https://bugs.debian.org/1067598
Author: Graham Inggs 
Last-Update: 2024-03-25

--- a/src/wfuzz/externals/moduleman/loader.py
+++ b/src/wfuzz/externals/moduleman/loader.py
@@ -1,6 +1,6 @@
 import inspect
 import logging
-import imp
+import importlib
 import os.path
 
 
@@ -52,14 +52,13 @@
 """
 self.__logger.debug("__load_py_from_file. START, file=%s" % (filename,))
 
-dirname, filename = os.path.split(filename)
-fn = os.path.splitext(filename)[0]
-exten_file = None
+fn = os.path.splitext(os.path.split(filename)[1])[0]
 module = None
 
 try:
-exten_file, filename, description = imp.find_module(fn, [dirname])
-module = imp.load_module(fn, exten_file, filename, description)
+spec = importlib.util.spec_from_file_location(fn, filename)
+module = importlib.util.module_from_spec(spec)
+spec.loader.exec_module(module)
 except ImportError as msg:
 self.__logger.critical(
 "__load_py_from_file. Filename: %s Exception, msg=%s" % (filename, msg)
@@ -73,9 +72,6 @@
 )
 # raise msg
 pass
-finally:
-if exten_file:
-exten_file.close()
 
 if module is None:
 return
--- a/src/wfuzz/plugin_api/base.py
+++ b/src/wfuzz/plugin_api/base.py
@@ -10,11 +10,24 @@
 
 import sys
 import os
-from distutils import util
 
 # python 2 and 3: iterator
 from builtins import object
 
+def strtobool(val):
+"""Convert a string representation of truth to true (1) or false (0).
+
+True values are 'y', 'yes', 't', 'true', 'on', and '1'; false values
+are 'n', 'no', 'f', 'false', 'off', and '0'.  Raises ValueError if
+'val' is anything else.
+"""
+val = val.lower()
+if val in ('y', 'yes', 't', 'true', 'on', '1'):
+return 1
+elif val in ('n', 'no', 'f', 'false', 'off', '0'):
+return 0
+else:
+raise ValueError("invalid truth value {!r}".format(val))
 
 # Util methods for accessing search results
 class BasePlugin:
@@ -74,7 +87,7 @@
 )
 
 def _bool(self, value):
-return bool(util.strtobool(value))
+return bool(strtobool(value))
 
 
 class BasePrinter:


Bug#1067598: wfuzz: FTBFS with Python 3.12 as default

2024-03-24 Thread Graham Inggs
Source: wfuzz
Version: 3.1.0-4
Severity: important
Tags: ftbfs
User: debian-pyt...@lists.debian.org
Usertags: python3.12

Hi Maintainer

wfuzz FTBFS with Python 3.12 as the default version (i.e. with
python3-defaults/3.12.1-1 from experimental).  I've copied what I hope
is the relevant part of the log below.

Regards
Graham


   dh_auto_test -O--buildsystem=pybuild
I: pybuild base:305: cd
/<>/.pybuild/cpython3_3.12_wfuzz/build; python3.12 -m
unittest discover -v
wfuzz (unittest.loader._FailedTest.wfuzz) ... ERROR

==
ERROR: wfuzz (unittest.loader._FailedTest.wfuzz)
--
ImportError: Failed to import test module: wfuzz
Traceback (most recent call last):
  File "/usr/lib/python3.12/unittest/loader.py", line 427, in _find_test_path
package = self._get_module_from_name(name)
  
  File "/usr/lib/python3.12/unittest/loader.py", line 337, in
_get_module_from_name
__import__(name)
  File "/<>/.pybuild/cpython3_3.12_wfuzz/build/wfuzz/__init__.py",
line 55, in 
from .options import FuzzSession
  File "/<>/.pybuild/cpython3_3.12_wfuzz/build/wfuzz/options.py",
line 6, in 
from .facade import (
  File "/<>/.pybuild/cpython3_3.12_wfuzz/build/wfuzz/facade.py",
line 5, in 
from .externals.moduleman.loader import DirLoader
  File 
"/<>/.pybuild/cpython3_3.12_wfuzz/build/wfuzz/externals/moduleman/loader.py",
line 3, in 
import imp
ModuleNotFoundError: No module named 'imp'


--
Ran 1 test in 0.000s

FAILED (errors=1)
E: pybuild pybuild:391: test: plugin distutils failed with: exit
code=1: cd /<>/.pybuild/cpython3_3.12_wfuzz/build;
python3.12 -m unittest discover -v
dh_auto_test: error: pybuild --test -i python{version} -p 3.12
returned exit code 13