restrict downloader and postprocessor module imports

This commit is contained in:
Mike Fährmann
2019-04-16 18:09:30 +02:00
parent 70be494161
commit 7973419b54
2 changed files with 18 additions and 4 deletions

View File

@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# Copyright 2018 Mike Fährmann
# Copyright 2018-2019 Mike Fährmann
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
@@ -11,6 +11,14 @@
import importlib
import logging
modules = [
"classify",
"exec",
"metadata",
"ugoira",
"zip",
]
log = logging.getLogger("postprocessor")
@@ -21,7 +29,7 @@ def find(name):
except KeyError:
klass = None
try:
if "." not in name: # prevent relative imports
if name in modules: # prevent unwanted imports
module = importlib.import_module("." + name, __package__)
klass = module.__postprocessor__
except (ImportError, AttributeError, TypeError):