Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
SUSE:ALP:Source:Standard:Core:0.1
setools
make_networkx_optional.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File make_networkx_optional.patch of Package setools
From 716a1d9e1db6701c0b310dd7e10dc4a10656da0f Mon Sep 17 00:00:00 2001 From: Chris PeBenito <chpebeni@linux.microsoft.com> Date: Tue, 14 Dec 2021 14:24:20 -0500 Subject: [PATCH] Make NetworkX optional. The CLI tools get installed to most distros, but sedta and seinfoflow are not typically used or separated into a different package. This will allow seinfo, sesearch, and sediff to function if NetworkX is missing, since they don't require it. Signed-off-by: Chris PeBenito <chpebeni@linux.microsoft.com> --- setools/dta.py | 18 ++++++++++++++---- setools/infoflow.py | 17 +++++++++++++---- 2 files changed, 27 insertions(+), 8 deletions(-) Index: setools/setools/dta.py =================================================================== --- setools.orig/setools/dta.py +++ setools/setools/dta.py @@ -24,8 +24,11 @@ from collections import defaultdict from contextlib import suppress from typing import DefaultDict, Iterable, List, NamedTuple, Optional, Union -import networkx as nx -from networkx.exception import NetworkXError, NetworkXNoPath, NodeNotFound +try: + import networkx as nx + from networkx.exception import NetworkXError, NetworkXNoPath, NodeNotFound +except ImportError: + logging.getLogger(__name__).debug("NetworkX failed to import.") from .descriptors import EdgeAttrDict, EdgeAttrList from .policyrep import AnyTERule, SELinuxPolicy, TERuletype, Type @@ -87,8 +90,15 @@ class DomainTransitionAnalysis: self.reverse = reverse self.rebuildgraph = True self.rebuildsubgraph = True - self.G = nx.DiGraph() - self.subG = self.G.copy() + + try: + self.G = nx.DiGraph() + self.subG = self.G.copy() + except NameError: + self.log.critical("NetworkX is not available. This is " + "requried for Domain Transition Analysis.") + self.log.critical("This is typically in the python3-networkx package.") + raise @property def reverse(self) -> bool: Index: setools/setools/infoflow.py =================================================================== --- setools.orig/setools/infoflow.py +++ setools/setools/infoflow.py @@ -21,8 +21,11 @@ import logging from contextlib import suppress from typing import cast, Iterable, List, Mapping, Optional, Union -import networkx as nx -from networkx.exception import NetworkXError, NetworkXNoPath, NodeNotFound +try: + import networkx as nx + from networkx.exception import NetworkXError, NetworkXNoPath, NodeNotFound +except ImportError: + logging.getLogger(__name__).debug("NetworkX failed to import.") from .descriptors import EdgeAttrIntMax, EdgeAttrList from .permmap import PermissionMap @@ -68,8 +71,14 @@ class InfoFlowAnalysis: self.rebuildgraph = True self.rebuildsubgraph = True - self.G = nx.DiGraph() - self.subG = self.G.copy() + try: + self.G = nx.DiGraph() + self.subG = self.G.copy() + except NameError: + self.log.critical("NetworkX is not available. This is " + "requried for Information Flow Analysis.") + self.log.critical("This is typically in the python3-networkx package.") + raise @property def min_weight(self) -> int:
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor