Fuzzy DL OWL 2 v1.0.17
fix: harden security, correctness, and ergonomics
Security
- knowledge_base: restrict pickle.load via allowlist Unpickler;
convert read_object_from_file to https://github.com/classmethod; document RCE risk - owl2_xml_parser: swap stdlib xml.etree for defusedxml to prevent
billion-laughs / quadratic-blowup attacks on untrusted OWL2 XML
Bugs
- knowledge_base.save_to_file: replace broken
with open(...) if name else None as fwith contextlib.nullcontext(sys.stdout); stdout
fallback now works instead of crashing with AttributeError - dl_parser.get_kb: stop returning None on error; re-raise typed
FuzzyOntologyException with chained cause; remove double Util.error
call that triggered a second raise during cleanup - utils.debugging_wrapper: replace bare
except:with AttributeError - config_reader.load_parameters: raise FileNotFoundError on missing
CONFIG.ini and ValueError on malformed overrides instead of
printing and continuing with half-initialized state; treat args[0]
as filename and args[1:] as override pairs - dl_parser.parse_string_opt: add parse_all=True to non-debug branch
and close the log file handle that was previously leaked
Architecture
- util / constants / dl_parser: stop creating ./logs and ./results
and calling logging.basicConfig at import time; expose lazy
setup_logging(), ensure_results_dir(), _ensure_parser_log_path();
install NullHandler so library import is side-effect free - utils.recursion_unlimited: cap sys.setrecursionlimit doubling at
1<<20 to prevent interpreter segfault on true infinite recursion;
restore original limit in finally on the success path too - concrete_feature / milp.term / milp.solution: replace runtime
assert isinstance(...)with explicit TypeError raises so type
contracts survivepython -O
Performance
- milp_helper.__get_graph: precompute {Variable: index} dict to drop
per-term self.variables.index() lookup from O(V) to O(1) - milp_helper.__remove_nominal_variables: switch removal collections
from list to set for O(1) membership in the filter comprehensions
Packaging
- pyproject: add defusedxml ^0.7.1; drop runtime setuptools (build-
time only); move dev deps under [tool.poetry.group.dev.dependencies]
and bump pytest ^8.3, flake8 ^7.1, pytest-cov ^5.0
Test runner
- add run_tests.sh (gitignored): poetry lock + install, install
python-mip into the venv (CONFIG.ini selects milpProvider=mip),
activate the resolved venv directly, run unittest from test/ so
the suite's ../examples/... relative paths resolve
All 128 unit tests pass.