karton-core
Advanced tools
| import sys, types, os;has_mfs = sys.version_info > (3, 5);p = os.path.join(sys._getframe(1).f_locals['sitedir'], *('karton',));importlib = has_mfs and __import__('importlib.util');has_mfs and __import__('importlib.machinery');m = has_mfs and sys.modules.setdefault('karton', importlib.util.module_from_spec(importlib.machinery.PathFinder.find_spec('karton', [os.path.dirname(p)])));m = m or sys.modules.setdefault('karton', types.ModuleType('karton'));mp = (m or []) and m.__dict__.setdefault('__path__',[]);(p not in mp) and mp.append(p) |
@@ -1,1 +0,1 @@ | ||
| __version__ = "5.3.3" | ||
| __version__ = "5.3.4" |
@@ -15,2 +15,3 @@ """ | ||
| from .config import Config | ||
| from .exceptions import TaskTimeoutError | ||
| from .resource import LocalResource | ||
@@ -133,3 +134,6 @@ from .task import Task, TaskState | ||
| self._post_hooks: List[ | ||
| Tuple[Optional[str], Callable[[Task, Optional[Exception]], None]] | ||
| Tuple[ | ||
| Optional[str], | ||
| Callable[[Task, Optional[BaseException]], None], | ||
| ] | ||
| ] = [] | ||
@@ -184,3 +188,3 @@ | ||
| self.process(self.current_task) | ||
| except Exception as exc: | ||
| except (Exception, TaskTimeoutError) as exc: | ||
| saved_exception = exc | ||
@@ -192,3 +196,3 @@ raise | ||
| self.log.info("Task done - %s", self.current_task.uid) | ||
| except Exception: | ||
| except (Exception, TaskTimeoutError): | ||
| exc_info = sys.exc_info() | ||
@@ -267,3 +271,3 @@ exception_str = traceback.format_exception(*exc_info) | ||
| self, | ||
| callback: Callable[[Task, Optional[Exception]], None], | ||
| callback: Callable[[Task, Optional[BaseException]], None], | ||
| name: Optional[str] = None, | ||
@@ -297,3 +301,3 @@ ) -> None: | ||
| def _run_post_hooks(self, exception: Optional[Exception]) -> None: | ||
| def _run_post_hooks(self, exception: Optional[BaseException]) -> None: | ||
| """ | ||
@@ -440,3 +444,3 @@ Run registered postprocessing hooks | ||
| def _send_signaling_status_task_end( | ||
| self, task: Task, ex: Optional[Exception] | ||
| self, task: Task, ex: Optional[BaseException] | ||
| ) -> None: | ||
@@ -443,0 +447,0 @@ """Send a begin status signaling task. |
+48
-21
@@ -215,11 +215,19 @@ import enum | ||
| matches = False | ||
| for task_filter in filters: | ||
| matched = [] | ||
| for filter_key, filter_value in task_filter.items(): | ||
| # Coerce to string for comparison | ||
| header_value = self.headers.get(filter_key) | ||
| def test_filter(headers: Dict[str, Any], filter: Dict[str, Any]) -> int: | ||
| """ | ||
| Filter match follows AND logic, but it's non-boolean because filters may be | ||
| negated (task:!platform). | ||
| Result values are as follows: | ||
| - 1 - positive match, no mismatched values in headers | ||
| (all matched) | ||
| - 0 - no match, found value that doesn't match to the filter | ||
| (some are not matched) | ||
| - -1 - negative match, found value that matches negated filter value | ||
| (all matched but found negative matches) | ||
| """ | ||
| matches = 1 | ||
| for filter_key, filter_value in filter.items(): | ||
| # Coerce filter value to string | ||
| filter_value_str = str(filter_value) | ||
| header_value_str = str(header_value) | ||
| negated = False | ||
@@ -230,20 +238,39 @@ if filter_value_str.startswith("!"): | ||
| if header_value is None: | ||
| matched.append(negated) | ||
| continue | ||
| # If expected key doesn't exist in headers | ||
| if filter_key not in headers: | ||
| # Negated filter ignores non-existent values | ||
| if negated: | ||
| continue | ||
| # But positive filter doesn't | ||
| return 0 | ||
| # Coerce header value to string | ||
| header_value_str = str(headers[filter_key]) | ||
| # fnmatch is great for handling simple wildcard patterns (?, *, [abc]) | ||
| match = fnmatch.fnmatchcase(header_value_str, filter_value_str) | ||
| # if matches, but it's negated then we can return straight away | ||
| # since no matter the other filters | ||
| # If matches, but it's negated: it's negative match | ||
| if match and negated: | ||
| return False | ||
| matches = -1 | ||
| # If doesn't match but filter is not negated: it's not a match | ||
| if not match and not negated: | ||
| return 0 | ||
| # If there are no mismatched values: filter is matched | ||
| return matches | ||
| # else, apply a XOR logic to take care of negation matching | ||
| matched.append(match != negated) | ||
| # set the flag if all consumer filter fields match the task header. | ||
| # It will be set to True only if at least one filter matches the header | ||
| matches |= all(matched) | ||
| # List of filter matches follow OR logic, but -1 is special | ||
| # If there is any -1, result is False | ||
| # (any matched, but it's negative match) | ||
| # If there is any 1, but no -1's: result is True | ||
| # (any matched, no negative match) | ||
| # If there are only 0's: result is False | ||
| # (none matched) | ||
| matches = False | ||
| for task_filter in filters: | ||
| match_result = test_filter(self.headers, task_filter) | ||
| if match_result == -1: | ||
| # Any negative match results in False | ||
| return False | ||
| if match_result == 1: | ||
| # Any positive match but without negative matches results in True | ||
| matches = True | ||
| return matches | ||
@@ -250,0 +277,0 @@ |
@@ -106,3 +106,3 @@ import argparse | ||
| to_delete.append(task) | ||
| self.log.warning( | ||
| self.log.error( | ||
| "Task %s is in Dispatched state more than %d seconds. " | ||
@@ -120,3 +120,3 @@ "Killed. (origin: %s)", | ||
| to_delete.append(task) | ||
| self.log.warning( | ||
| self.log.error( | ||
| "Task %s is in Started state more than %d seconds. " | ||
@@ -123,0 +123,0 @@ "Killed. (receiver: %s)", |
+1
-1
| Metadata-Version: 2.1 | ||
| Name: karton-core | ||
| Version: 5.3.3 | ||
| Version: 5.3.4 | ||
| Summary: Distributed malware analysis orchestration framework | ||
@@ -5,0 +5,0 @@ Home-page: https://github.com/CERT-Polska/karton |
+12
-12
@@ -1,4 +0,4 @@ | ||
| karton_core-5.3.3-nspkg.pth,sha256=vHa-jm6pBTeInFrmnsHMg9AOeD88czzQy-6QCFbpRcM,539 | ||
| karton_core-5.3.4-nspkg.pth,sha256=vHa-jm6pBTeInFrmnsHMg9AOeD88czzQy-6QCFbpRcM,539 | ||
| karton/core/__init__.py,sha256=QuT0BWZyp799eY90tK3H1OD2hwuusqMJq8vQwpB3kG4,337 | ||
| karton/core/__version__.py,sha256=1nSgbQKO6KlKoDYLTNXC8iJUIO_SuORsK-CISssv5l0,22 | ||
| karton/core/__version__.py,sha256=dAiy67tSM_yYFR8Us_fQT-TDbfV34VpASYNKXfGmEnQ,22 | ||
| karton/core/backend.py,sha256=evOzlz1v1sxWusc8VojGAYyeyi9fcbVoEPm6WoNT1Xs,34696 | ||
@@ -9,3 +9,3 @@ karton/core/base.py,sha256=C6Lco3E0XCsxvEjeVOLR9fxh_IWJ1vjC9BqUYsQyewE,8083 | ||
| karton/core/inspect.py,sha256=rIa0u4u12vG_RudPfc9UAS4RZD56W8qbUa8n1dDIkX0,4868 | ||
| karton/core/karton.py,sha256=-BWsNvbL_yFFlSPjEOXlBqkENEWLTfIB0ETjowh7Mjo,14863 | ||
| karton/core/karton.py,sha256=9SOAviG42kSsPqc3EuaHzWtA_KywMtc01hmU6FaJpHo,15007 | ||
| karton/core/logger.py,sha256=J3XAyG88U0cwYC9zR6E3QD1uJenrQh7zS9-HgxhqeAs,2040 | ||
@@ -15,3 +15,3 @@ karton/core/main.py,sha256=ir1-dhn3vbwfh2YHiM6ZYfRBbjwLvJSz0d8tuK1mb_4,8310 | ||
| karton/core/resource.py,sha256=tA3y_38H9HVKIrCeAU70zHUkQUv0BuCQWMC470JLxxc,20321 | ||
| karton/core/task.py,sha256=1yyCH6A6MBJ7yuKECmsLrZDRECbKQ-48dJ31ZL7FR5Y,19644 | ||
| karton/core/task.py,sha256=WYXzVopg8VlWOc7ncEscHVKivsXHfZc5zWLHW_mxBwY,21000 | ||
| karton/core/test.py,sha256=tms-YM7sUKQDHN0vm2_W7DIvHnO_ld_VPsWHnsbKSfk,9102 | ||
@@ -21,9 +21,9 @@ karton/core/utils.py,sha256=sEVqGdVPyYswWuVn8wYXBQmln8Az826N_2HgC__pmW8,4090 | ||
| karton/system/__main__.py,sha256=QJkwIlSwaPRdzwKlNmCAL41HtDAa73db9MZKWmOfxGM,56 | ||
| karton/system/system.py,sha256=AsQLGF_8YI-o4dCOe2hyQefYlhGEguFSoPg1EcQtJyU,13791 | ||
| karton_core-5.3.3.dist-info/LICENSE,sha256=o8h7hYhn7BJC_-DmrfqWwLjaR_Gbe0TZOOQJuN2ca3I,1519 | ||
| karton_core-5.3.3.dist-info/METADATA,sha256=sumt5njKhDPynjbmFZvPxdPPSCCXR4wr3xchvowJPC8,6847 | ||
| karton_core-5.3.3.dist-info/WHEEL,sha256=G16H4A3IeoQmnOrYV4ueZGKSjhipXx8zc8nu9FGlvMA,92 | ||
| karton_core-5.3.3.dist-info/entry_points.txt,sha256=FJj5EZuvFP0LkagjX_dLbRGBUnuLjgBiSyiFfq4c86U,99 | ||
| karton_core-5.3.3.dist-info/namespace_packages.txt,sha256=X8SslCPsqXDCnGZqrYYolzT3xPzJMq1r-ZQSc0jfAEA,7 | ||
| karton_core-5.3.3.dist-info/top_level.txt,sha256=X8SslCPsqXDCnGZqrYYolzT3xPzJMq1r-ZQSc0jfAEA,7 | ||
| karton_core-5.3.3.dist-info/RECORD,, | ||
| karton/system/system.py,sha256=65c8j1Ayra_CrXA1AQPBm00bTnpQiW91iZlTTRfJJI8,13787 | ||
| karton_core-5.3.4.dist-info/LICENSE,sha256=o8h7hYhn7BJC_-DmrfqWwLjaR_Gbe0TZOOQJuN2ca3I,1519 | ||
| karton_core-5.3.4.dist-info/METADATA,sha256=w15YiCEMDZrAF_429FAx98NH3tif38vyDxI9g9heY7E,6847 | ||
| karton_core-5.3.4.dist-info/WHEEL,sha256=G16H4A3IeoQmnOrYV4ueZGKSjhipXx8zc8nu9FGlvMA,92 | ||
| karton_core-5.3.4.dist-info/entry_points.txt,sha256=FJj5EZuvFP0LkagjX_dLbRGBUnuLjgBiSyiFfq4c86U,99 | ||
| karton_core-5.3.4.dist-info/namespace_packages.txt,sha256=X8SslCPsqXDCnGZqrYYolzT3xPzJMq1r-ZQSc0jfAEA,7 | ||
| karton_core-5.3.4.dist-info/top_level.txt,sha256=X8SslCPsqXDCnGZqrYYolzT3xPzJMq1r-ZQSc0jfAEA,7 | ||
| karton_core-5.3.4.dist-info/RECORD,, |
| import sys, types, os;has_mfs = sys.version_info > (3, 5);p = os.path.join(sys._getframe(1).f_locals['sitedir'], *('karton',));importlib = has_mfs and __import__('importlib.util');has_mfs and __import__('importlib.machinery');m = has_mfs and sys.modules.setdefault('karton', importlib.util.module_from_spec(importlib.machinery.PathFinder.find_spec('karton', [os.path.dirname(p)])));m = m or sys.modules.setdefault('karton', types.ModuleType('karton'));mp = (m or []) and m.__dict__.setdefault('__path__',[]);(p not in mp) and mp.append(p) |
Alert delta unavailable
Currently unable to show alert delta for PyPI packages.